Velocity Template debugging and Catch exceptions - java

How to print the exact line no of exception in Velocity Template at runtime?
I am using Veloeclipse for development to validate syntax related problems.. This works, but for Runtime based Exceptions information is missing.
I am sending a logging object to context of VT so when I want to log something I use the $logging.log(contenttobelogged)
If some exception occurs during runtime, the exception trace does not contain any line numer details of Velocity template.
For that I have to put my log for each lines , so log makes code nasty. Can you guide me to log errors with proper line number?
Exception Trace :
Template Name #################### yes/po/POSSellerRSPGridData_JSON.vm
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'get' in class java.util.ArrayList threw exception class java.lang.IndexOutOfBoundsException : Index: 1, Size: 1
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:308)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:202)
at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:345)
at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:135)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:344)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:344)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at ecnet.rd.core.template.TemplateResolver.merge(TemplateResolver.java:81)
at ecnet.rd.helper.YES_PO_Helper.mergerTemplateDetails(YES_PO_Helper.java:166)

Velocity tools 3.0 have a new tool, LogTool enable you to log error message inside template with error method

Related

Issue in addPlugInSingleRowFunction upgrading Esper version from 5.3 to 8.3

In our existing application we are using Esper Version 5.3.
We have added few addPlugInSingleRowFunction() to use it in EPL as below --
final Configuration cepConfiguration = new Configuration();
cepConfiguration.addPlugInSingleRowFunction("toNumber", Double.class.getName(), "parseDouble");
cepConfiguration.addPlugInSingleRowFunction("toBoolean", Boolean.class.getName(), "parseBoolean");
This was working fine in 5.3 version.
Post upgrading to 8.3 above code changed as per Esper documentation --
cepConfiguration.getCompiler().addPlugInSingleRowFunction("toNumber", Double.class.getName(), "parseDouble");
cepConfiguration.getCompiler().addPlugInSingleRowFunction("toBoolean", Boolean.class.getName(), "parseBoolean");
But once the sendEventBean() method is called to send a Event to runtime we are seeing below exception every time.
Surprisingly events are getting matched as per the statements present in runtime even if below exception are coming. Though we are not sure whether some events are not matching or not.
Can someone please help on this?
applog.cls=com.espertech.esper.common.internal.epl.expression.dot.core.ExprDotNodeForgeStaticMethodEval,applog.mthd=staticMethodEvalHandleInvocationException,applog.line=228,applog.msg=Invocation exception when invoking method 'parseDouble' of class 'java.lang.Double' passing parameters [null] for statement 'stmt-0': NullPointerException : null,exc.stack=java.lang.NullPointerException\n\tat sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)\n\tat sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)\n\tat java.lang.Double.parseDouble(Double.java:538)\n\tat generated.StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.m8(StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.java:161)\n\tat generated.StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450$2.get(ANONYMOUS.java:148)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterParamIndexEquals.matchEvent(FilterParamIndexEquals.java:32)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterHandleSetNode.matchEvent(FilterHandleSetNode.java:100)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.EventTypeIndex.matchType(EventTypeIndex.java:178)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.EventTypeIndex.matchEvent(EventTypeIndex.java:124)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceBase.retryableMatchEvent(FilterServiceBase.java:179)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceBase.evaluateInternal(FilterServiceBase.java:96)\n\tat com.espertech.esper.runtime.internal.filtersvcimpl.FilterServiceLockCoarse.evaluate(FilterServiceLockCoarse.java:52)\n\tat com.espertech.esper.runtime.internal.kernel.service.EPEventServiceImpl.processMatches(EPEventServiceImpl.java:610)\n\tat com.espertech.esper.runtime.internal.kernel.service.EPEventServiceImpl.processWrappedEvent(EPEventServiceImpl.java:450)\n\tat com.espertech.esper.runtime.internal.kernel.thread.InboundUnitSendEvent.run(InboundUnitSendEvent.java:43)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)
You could turn on compiler logging (config.getCompiler().getLogging().setEnableCode(true);) and make sure you have INFO level logging. You can inspect "StatementAIFactoryProvider_a4bd241445010f45474e4598e34521ca1b2836db_stmt450.m8" at line 161 to see what the problem is. Sounds like a null value gets passed to Double.parseDouble. But since I don't have the complete code its hard to say.

GSP Exception thrown for "Method code too large"?

I am getting the exception below when I try to access my Grails application. What is the problem?
Error | 2019-10-10 16:24:39,538 [http-bio-8080-exec-10] ERROR
pages.GroovyPagesTemplateEngine - Compilation error compiling GSP
[C__praveen_HOTS_grails_app_views_main_monetarystatusdet_gsp]:startup
failed: General error during class generation: Method code too large!
java.lang.RuntimeException: Method code too large! at
groovyjarjarasm.asm.MethodWriter.a(Unknown Source) at
groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source) at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:796)
at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:811)
at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:811)
at
The issue is that your GSP has too much code within it and exceeds the 65K (or so) lines per script block. The "workaround" is to add a comment in the GSP to break up the script block size like this:
<%
// just a comment
%>
Placing that somewhere in the middle or in several spots in your GSP file will resolve this issue.

Dataimport in Solr 5.1.0 is not indexing few fields which are to be fetched through makepair function

Schema.xml has all fields mentioned to be indexed. it was working all this time and i am facing this issue all of a sudden. What is wrong. Please advise.
Error :
Line 2458: WARN - 2016-10-10 19:53:56.757; [ iccCore]
org.apache.solr.handler.dataimport.EntityProcessorWrapper; transformer
threw error Line 2459:
org.apache.solr.handler.dataimport.DataImportHandlerException: Error
invoking script for entity icMetadataProcessed Processing Document #
2594 Line 2472: Caused by: javax.script.ScriptException: TypeError:
null has no such function "split" in <eval> at line number 8 Line
2478: Caused by: <eval>:8 TypeError: null has no such function "split"
Looks like a Javascript error in your custom script. Possibly about the script expecting a string (to split) and getting null. I would fix the javascript to ignore that field or add debug to see which record is causing that problem, must likely by missing a value.

Why some stacktrace do not have line number in java

I have a bug from my customer and when I look into the log we trace the exception, some of the stacktrace do not have line number:
at xxxx.xxx.xx.x.xx.DayIntervalRule.getInterval(DayIntervalRule.java)
at xxxx.xxx.xx.x.xx.XXSchedule.getNextDueDate(XXSchedule.java)
at xxxx.xxx.xx.x.xx.XXSchedule.evaluateRules(XXSchedule.java)
Please note that:
I have replace the package name into something like"xx"),and all of the class and method are defined in our application:
The full stack trace are as below:
java.lang.NullPointerException
at xxxx.xxx.xx.x.xx.DayIntervalRule.getInterval(DayIntervalRule.java)
at xxxx.xxx.xx.x.xx.XXSchedule.getNextDueDate(XXSchedule.java)
at xxxx.xxx.xx.x.xx.XXSchedule.evaluateRules(XXSchedule.java)
at xxxx.xxx.xx.x.xx.EvaluateRulesVistor.visitXXNode(EvaluateRulesVistor.java:56)
at xxxx.xxx.xx.x.xx.XXNode.accept(XXNode.java:396)
at xxxx.xxx.xx.x.xx.AssetXX.traverseForest(AssetXX.java:351)
at xxxx.xxx.xx.x.xx.AssetXX.run(AssetXX.java:70)
at xxxx.xxx.xx.x.xx.XXEngine.doForecast(XXEngine.java:437)
at xxxx.xxx.xx.x.xx.XXEngine.forecastWorkOrders2(XXEngine.java:380)
I am interested in why this happens?Is it possible that my customer do something to the existing code(customization)?
The code that does not display line numbers was compiled without debug information.

how to solve Exception in Ical4j?

I am using ical4j for parsing outlook calendar file.When i parse the file it gives the exception as follows
Error at line 60:Illegal character in opaque part at index 4: CID:<FFFF__=0ABBFDFEDFCB93A98f9e8a9#medicraft.com.au>
How to solve this problem without changing the calendar file.
If you enable the NOTES_COMPATIBILITY CompatibilityHint this exception should go away. You can do this either programmatically:
CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_NOTES_COMPATIBILITY, true);
or via the following line in the ical.properties added to the classpath:
ical4j.compatibility.notes=true
See the ical4j wiki for further details:
http://wiki.modularity.net.au/ical4j/index.php?title=Compatibility

Categories

Resources