JRun Servlet Error when attepting to use java object - servlets

We have a site in ColdFusion which integrates with a credit card provider using java components.
When calling a particular function on a java object:
<cfset ResponseObject = AgentObject.request(RequestObject, LogObject)>
Where ResponseObject, AgentObject and LogObject are java object created like:
<cftry>
<cfset AgentObject = createObject("java","com.providername.client.Agent")>
<cfcatch type="any">
Do something.
</cfcatch>
</cftry>
The following is outputted on the page and execution is halted.
<head>
<title>JRun Servlet Error</title>
</head>
<h1>500 Transaction fails verification<br>
BadRequest: Request fails verification checks<br>
BadCardNumber: Card length was 16, but we were expecting 0<br>
</h1>
<body>
Transaction fails verification<br>
BadRequest: Request fails verification checks<br>
BadCardNumber: Card length was 16, but we were expecting 0<br>
</body>
The error is expected (we're checking card details), but I don't seem to be able to catch it. A cftry and cfcatch has no effect, so I'm totally at a loss as to how I can handle this error and continue execution.
Can anyone help?
Cheers,
Tom
Edit - additional error information
I thought it may also be useful to post this stack trace. It's not accessible via Coldfusion, but instead is logged to a file as part of LogObject above presumably in the Java code:
com.providername.client.errors.VerifyErrorReport: Transaction fails verification
com.providername.client.errors.BadRequest: Request fails verification checks
com.providername.client.errors.BadCardNumber: Card length was 16, but we were expecting 0
at com.providername.util.CardInfo.verifyCardNumber(CardInfo.java:412)
at com.providername.util.CardInfo.validateCardInfo(CardInfo.java:789)
at com.providername.util.CardInfo.validateCardInfo(CardInfo.java:838)
at com.providername.client.Agent.setupTransaction(Agent.java:681)
at com.providername.client.Agent.setupTransaction(Agent.java:692)
at com.providername.client.Agent.request(Agent.java:281)
at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:74)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1634)
at cfprovidername2ecfc526409752$funcSENDXMLOBJECT.runFunction(D:\site\components\providername.cfc:210)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344)
at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169)
at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:1807)
at cftransactions2ecfc114461696$funcTRANSACTION.runFunction(D:\site\components\transactions.cfc:175)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344)
at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:366)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:198)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:157)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1594)
at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:341)
at cfauthorise2dprovidername2ecfm1546743078._factor7(D:\site\payment\authorise-providername.cfm:224)
at cfauthorise2dprovidername2ecfm1546743078._factor27(D:\site\payment\authorise-providername.cfm:164)
at cfauthorise2dprovidername2ecfm1546743078._factor30(D:\site\payment\authorise-providername.cfm:91)
at cfauthorise2dprovidername2ecfm1546743078.runPage(D:\site\payment\authorise-providername.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
at cfauthorise2ecfm767248619.runPage(D:\site\payment\authorise.cfm:10)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
at cftemplate2ecfm1091873885._factor4(D:\site\server\template.cfm:247)
at cftemplate2ecfm1091873885.runPage(D:\site\server\template.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
at cfapplication2ecfm1526755454._factor31(D:\site\application.cfm:673)
at cfapplication2ecfm1526755454.runPage(D:\site\application.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
at cfApplication2ecfm1608241748.runPage(D:\site\payment\Application.cfm:30)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.CfincludeFilter.include(CfincludeFilter.java:33)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:172)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
at coldfusion.CfmServlet.service(CfmServlet.java:107)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

I'm a bit late to the party on this, but what you're getting is not a JRun error per se. It seems that the error is thrown in the JRE and JRun is showing it as a "Servlet Error". Notice the lines in your stack trace:
com.providername.client.errors.VerifyErrorReport: Transaction fails verification
com.providername.client.errors.BadRequest: Request fails verification checks
com.providername.client.errors.BadCardNumber: Card length was 16, but we were expecting 0
at com.providername.util.CardInfo.verifyCardNumber(CardInfo.java:412)
That looks like an error thrown by the CardInfo class within verifyCardNumber() on line 412. I think JRun just serves the error as a "Servlet Error" because there's a hard stop in com.providername.client.errors.VerifyErrorReport.
This also might be the reason your <cfcatch> won't catch that exception. The Java class might catch that error and throw that exception within Java which causes that ugly JRun 500 error.
If you don't have the source of the Java to inspect why you're getting that exception in CardInfo, then you should contact the people who own the source to see if they have any insight.
I hope this is in some way helpful to you.

Related

Strange ZQuery behavior

I'm using Zeos and SQLite3 DB in Delphi
ZQuery2.Close;
ZQuery2.SQL.Clear;
ZQuery2.SQL.Add('SELECT * FROM users WHERE un = ' + QuotedStr( UserName ) );
ZQuery2.Open;
OutputDebugString(PWideChar( ZQuery2.FieldDefList.CommaText )); // log : id,un,pw
OutputDebugString(PWideChar(ZQuery2.FieldByName('pw').AsString)); //causes error sometimes
the code is working but sometimes I get the following error message
Exception class EDatabaseError with message 'ZQuery2:Field'pw' not found'.
This is odd because a field of a dataset shouldn't just disappear while the app is in the middle of running, especially if other fields are still operating normally. So, I would suspect something like a memory overwrite being the cause.
Memory overwrites usually happen when something is written to the wrong place in memory, overwriting what is there, usually because of an incorrect pointer value or a so-called "buffer overrun" where the writing operation carries on beyond where is should stop. Usually, the pointer value is so wildly wrong that the OS can detect it and raise an AV, but sometimes it is less obvious.
Delphi's memory manager has a 'full debug mode' which adds special checks for this condition, see here.
I suggest you enable full debug mode as per the linked document and wait for the exception to occur.

Getting a parameter from ServletRequest throws illegalStateException

I have this code in one of the filter which is called on every request.
httpRequest.getParameter(tabId);
My request was failing continuiosly after filters. On debugging I found that this code throws this exception on the first time, now say if I execute this code using "inspect" it throws this exception and if I execute it again using "inspect" or "forward debug" it give "null" and completes the flow. I dont understand why it works like this on first execution of this code as there is not "tabId" in request.
18:44:03,443 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/workbench].[action]] (http-0.0.0.0:8090-5) JBWEB000236: Servlet.service() for servlet action threw exception: java.lang.IllegalStateException: JBWEB002004: More than the maximum number of request parameters (GET plus POST) for a single request (128) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.
at org.apache.tomcat.util.http.Parameters.addParameter(Parameters.java:184) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:356) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:213) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
at org.apache.catalina.connector.Request.parseParameters(Request.java:2885) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
at org.apache.catalina.connector.Request.getParameter(Request.java:1303) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:350) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
**at com.xyz.IdentityFilter.doFilter(IdentityFilter.java:58) [projectX.jar:]**
The request body has already been consumed, you have to wrap it in your filter (before the doFilter(...) call) if you need to do business logic on it. See here for an example.

What is causing the exception HRESULT: 0xC0C01B22 when attempting to enlist a send port with a filter?

This is a simple send port, in which I'm trying to setup a filter over a promoted property. Whenever I attempt to enlist this port, I get the following error:
===================================
Could not update Send Port 'SendPort1' in Message Box. Exception from HRESULT: 0xC0C01B22 (Microsoft.BizTalk.ExplorerOM)
------------------------------
For help, click: http://go.microsoft.com/fwlink/?LinkId=47400&ProdName=Microsoft+BizTalk+Server+2013&ProdVer=3.10.229.0&EvtSrc=Microsoft.BizTalk.ExplorerOM.Resources&EvtID=IDS_ERR_SENDPORT_UPDATE
------------------------------
Program Location:
at Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer.SaveChangesWithTransaction(Object transactionObj)
at Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer.SaveChanges()
at Microsoft.BizTalk.Administration.SnapIn.Forms.Common.ExplorerPropertyPagesContainer.CommitChanges()
at Microsoft.BizTalk.SnapIn.Framework.Forms.PropertyPagesContainer.Store()
at Microsoft.BizTalk.SnapIn.Framework.Forms.SheetFramework.Store()
The filter simply checks for existence of the promoted property in the incoming message. There's only one post in MSDN forums about this exception: HRESULT 0xC0C01B22
Any idea what is causing this?
The answer is in this page: https://learn.microsoft.com/en-us/biztalk/core/promoting-properties
The note there says the following:
XSD Data Type of base64Binary, duration, ENTITES, hexBinary, IDREFS, long, NMTOKENS, and unsignedLong are not supported for promotion.
Turns out, in our case, the promoted property is of xs:long type. I changed the element type to xs:string then the issue in the question went away.
It would make sense to prevent the promotion of the elements if they are of unsupported type, in the beginning itself. But we don't get to see any alerts during the promotion phase for such elements.
Hope this helps someone.

how to force scrapy exit when there is an exception

I wrote a crawler with Scrapy.
There is a function in the pipeline where I write my data to a database. I use the logging module to log runtime logs.
I found that when my string have Chinese logging.error() will throw an exception. But the crawler keeps running!
I know this is a minor error but if there is a critical exception I will miss it if crawler keeps running.
My question is: Is there a setting that I can force Scrapy stop when there is an exception?
You can use CLOSESPIDER_ERRORCOUNT
An integer which specifies the maximum number of errors to receive
before closing the spider. If the spider generates more than that
number of errors, it will be closed with the reason
closespider_errorcount. If zero (or non set), spiders won’t be closed
by number of errors.
By default it is set to 0
CLOSESPIDER_ERRORCOUNT = 0
you can change it to 1 if you want to exit when you have the first error.
UPDATE
Read the answers of this question, you can also use:
crawler.engine.close_spider(self, 'log message')
for more information read :
Close spider extension
In the process_item function of your spider you have an instance of spider.
To solve your problem you could catch the exceptions when you insert your data, then neatly stop you spider if you catch a certain exeption like this:
def process_item(self, item, spider):
try:
#Insert your item here
except YourExceptionName:
spider.crawler.engine.close_spider(self, reason='finished')
I don't know of a setting that would close the crawler on any exception, but you have at least a couple of options:
you can raise CloseSpider exception in a spider callback, maybe when you catch that exception you mention
you can call crawler.engine.close_spider(spider, 'some reason') if you have a reference to the crawler and spider object, for example in an extension. See how the CloseSpider extension is implemented (it's not the same as the CloseSpider exception).
You could hook this with the spider_error signal for example.

catching the warning message from aif web service

I have a aif service in ax 2012. I pass information into it from .net applications. basically i'm posting to the general journal. But when there is an error, say bad information being passed in, it returns a general error usually "error validating record". But the warning message displays the actual reason why it caused an error such as the bad data.
Is there a way to catch and display the warning message. I tried exception::warning but it just goes right to the exception::error.
catch (Exception::Error)
{
throw Global::error("need to get warning");
}
I hope to understok the question.
If you ant get all Warning message from Infolog, I have a little solution.
You can take all Infolog created by system, look like :
InfologData msg;
catch (Exception::Error)
{
msg = infolog.infologData();
infolog.import(msg); // HERE show all infolog - with INFO - Warning - Errors
throw Global::error("Process Error");
}
It's not exactly request, but with this way can find all InfoLog displayed and warning too.
Good Work.
References : Infolog-INFO - Infolog2String
From memory, but have you tried:
throw error(AifUtil::getClrErrorMessage());
Perhaps this can help throw error(CLRInterop::getLastException().ToString());

Resources