GSP Exception thrown for "Method code too large"? - java

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.

Related

Facing some unknown issue some backend jvm internal error

I am facing some unknown issue looks like it is some internal compiler error:
these are the error when building apk:
Error:org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't transform method node: doResume (Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;:
Error:org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction #375 L0: Incompatible stack heights
Error:org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Incompatible stack heights
Any help would be appreciated.
After struggling for a long time I found the solution, the code which causes the problem is this:
if (investorType=="Institutional")
{linSignUp
if (firmName.isEmpty()) {
There is a problem in first if block which a linSignUp a reference of linear layout which accidentally placed here, which should not be here.
So the View just here alone with no use, when I removed it, the build generated successfully.
This was one of the most frustrating errors to track down.
Here is the error I was getting:
java.lang.IllegalStateException: Backend Internal error: Exception during code generation
Cause: Back-end (JVM) Internal error: wrong code generated
org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node:
.....
If your stack trace further on is related to views and strings, the main culprit for me was that the xml view id was too long.
This name caused the error: team_management_players_recycler_view_layout
I reduced it to this: team_man_players_recycler_layout
BOOM ERROR WAS GONE!
Hope this helps someone else out!
I had the same error in kotlin 1.3.72 and the code that was causing it was a recursive suspend function contained in a suspend function:
suspend fun function1(){
suspend fun internalFun(){
// does something
internalFun() //<-- this was causing the problem
}
internalFun()
}
I fixed by rearranging the code in such a way that i hadn't to call internalFun() inside itself.
I don't know if the fact that they were suspend functions was relevant.
Error message: "e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated"
In my case, I used runBlocking{} in one of MainViewModel.kt's methods.
The app was compiling successfully with runBlocking{} (which I shouldn't use anyway)) until I changed the name of a parameter in that method.
I replaced runBlocking{} with viewModelScope.launch {} in order to get ride of this error message.
In case this helps others in the future, my issue was due to using my custom extension:
suspend operator fun <T> MutableLiveData<T>.plusAssign(newValue: T) = ...
It was used like this:
init {
job = GlobalScope.launch {
while (true) {
delay(1000)
foo += bar // This is the error.
}
}
}
Using it like this, is however, completely fine:
suspend fun refreshNextJob() {
foo += bar
}
Not sure why this happens, but maybe this will help someone later.
In my case I got this exception:
java.lang.IllegalStateException: Backend Internal error: Exception
during code generation Cause: Back-end (JVM) Internal error: wrong
code generated org.jetbrains.kotlin.codegen.CompilationException
Back-end (JVM) Internal error: Couldn't transform method node: getS
()Ljava/lang/String;: #Lorg/jetbrains/annotations/NotNull;() //
invisible L0
LINENUMBER 9 L0
NEW com/example/GsonConverter
DUP
INVOKESPECIAL com/example/GsonConverter. ()V
ASTORE 1 L1
LINENUMBER 10 L1 ...
Cause: UTF8 string too large Element is unknownThe root cause was
thrown at: ByteVector.java:246 Cause: Back-end (JVM) Internal error:
Couldn't transform method node: getS ()Ljava/lang/String;:
#Lorg/jetbrains/annotations/NotNull;() // invisible L0 ...
Cause: UTF8 string too large Element is unknownThe root cause was
thrown at: ByteVector.java:246 File being compiled at position: (8,5)
in
C:/Users/user/AndroidStudioProjects/MyApplication03/app/src/main/java/com/example/myapplication/ATest.kt
The root cause was thrown at: TransformationMethodVisitor.kt:92 File
being compiled at position:
file://C:/Users/user/AndroidStudioProjects/MyApplication03/app/src/main/java/com/example/myapplication/ATest.kt
The root cause was thrown at: FunctionCodegen.java:1043 ...
Cause: UTF8 string too large Element is unknownThe root cause was
thrown at: ByteVector.java:246 ...
I removed a class ATest from an application, but it didn't help. A problem was in a constant string about 80 Kb (JSON).
In my case I just forgot to add method call when typed view name.
img_my_best_image
Instead of
img_my_best_image.show()

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.

How to put javaScript code in Java program/application?

Trying to put in your application code of Ace Editor: http://ace.c9.io/#nav=embedding.
I found something like this: http://metoojava.wordpress.com/2010/06/20/execute-javascript-from-java/
and I put this code:
engine.eval(new java.io.FileReader("ace-builds/src-noconflict/ace.js"));
But I have build errors.
Exception in thread "main" javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (<Unknown source>#1513) in <Unknown source> at line number 1513
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at javaapplication9.JavaApplication9.main(JavaApplication9.java:28)
Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (<Unknown source>#1513)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3770)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3748)
at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3833)
at sun.org.mozilla.javascript.internal.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1826)
at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1765)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1785)
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162)
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430)
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160)
at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173)
at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1169)
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214)
... 2 more
Do any of you know how can I do this?
Thans for help and Happy Holidays!
Keep in mind that you are executing a Javascript file out of context.
This Javascript file is usually executed with the browser JS engine so if you are not in that context you could not access to some objects like navigator, window... etc.

Velocity Template debugging and Catch exceptions

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

YUICompressor crashes - stackoverflow error

I frequently get what appears to be a stackoverflow error ;-) from YUICompressor. The following is the first part of thousands of error lines that come from attempting to compress a 24074 byte css stylesheet (not the "Caused by java.lang.StackOverflowError about 8 lines down):
iMac1:src jas$ min ../style2.min.css style2.css
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.StackOverflowError
at java.lang.Character.codePointAt(Character.java:2335)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3344)
at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
... (plus 1021 more error lines)
The errors happen usually after adding a couple of lines to the file getting compressed. The css is fine, and works perfectly in the uncompressed format. I don't see a particular pattern to the types of selectors added to the file that cause the errors. In this case, adding the following selector to a previously compressible file resulted in the errors:
#thisisatest
{
margin-left:87px;
}
I am wondering if there is perhaps a flag to java to enlarge the stack that might help. Or if that is not the problem, what is?
EDIT:
As I was posting this question, it dawned on me that I should check the java command to see if there was a parameter to enlarge the stack. Turns out that it is -Xssn, where "n" is a parameter to indicate the stack size. Its default value is 512k. So I tried 1024k but that still led to the stackoverflow. Trying 2048k works however, and I think this could be the solution.
EDIT 2:
While I no longer use this method for minification any longer, to be more specific here is the full command (which I have set up as a shell alias), showing how the -Xss2048k parameter is used:
java -Xss2048k -jar ~/Documents/RepHunter/Website\ Materials/Code/Third\ Party\ Libraries/YUI\ Compressor/yuicompressor-2.4.8.jar --type css -o
As posted in my edit, the solution was to add the parameters to the java command. The clue was the error line at the 5-th "at" line, as follows:
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.StackOverflowError
Seeing that the issue was a "StackOverlowError" ;-) gave the suggestion to try to increase the stack size. The default is 512k. My first try of 1024k did not work. However increasing it to 2048k did work, and I have had no further issues.

Categories

Resources