[jboss-user] [Javassist] New message: "javassist.bytecode.BadBytecode: unset variable. Please Help Me!"
Arvind K
do-not-reply at jboss.com
Fri Feb 19 02:32:00 EST 2010
User development,
A new message was posted in the thread "javassist.bytecode.BadBytecode: unset variable. Please Help Me!":
http://community.jboss.org/message/527169#527169
Author : Arvind K
Profile : http://community.jboss.org/people/megalodon
Message:
--------------------------------------------------------------
Hello All,
I am trying to use Javassist with my tomcat based web application.
I am getting exceptions when I try to instrument servlets generated from JSPs. Stack Trace attached below.
Instrumentation that I am trying to do:
Create an object and display it using its toString() method. class and method names are
com.temp1.tenga.SimpleInstrumenter.prefixMethod (for reference in the below stack trace).
I use the 'instrument' api in java and a java.lang.ClassFileTransformer to modify classes during load time.
From the byte array of the class that I receive in my ClassFileTransformer, I create a
ByteArrayInputStream use the ClassPool.makeClassIfNew() method to create my CtClass object.
As per my understanding JSP classes can be loaded multiple times apparently with the same class loader
(a concept which I am not too familiar with leave alone tomcat implementation details).
After instrumenting a JSP class for the first time, it gets frozen. So if a CtClass is frozen, I detach() it
and recreate the CtClass using the new byteArrayInputStream using the ClassPool.makeclass() method.
- Is this logic correct?
Once I recreate the CtClass in the above manner, I make the same instrumentation changes in it as in the
first time.
However, I am getting an exception whenever I try to access an instrumented JSP page. I cannot understand
why. I know that the exception looks like I am using a local variable without initializing it but I do not
think that that is the issue. jdk version is 1.6.0_13. Platform is windows
Please help or point me in a proper direction. Thank you very much. Let me know if you need further
details.
// First line is a statement that I just printed. Stack Trace starts from the next line:prefixMethod for org.apache.jsp.tempLogin_jsp method name _jspService . signature (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V Modifiers public
javassist.CannotCompileException: by javassist.bytecode.BadBytecode: unset variable
at javassist.CtBehavior.insertBefore(CtBehavior.java:724)
at javassist.CtBehavior.insertBefore(CtBehavior.java:681)
at com.temp1.tenga.SimpleInstrumenter.prefixMethod(SimpleInstrumenter.java:404)
at com.temp1.tenga.SimpleInstrumenter.instrument(SimpleInstrumenter.java:255)
at com.temp1.tenga.Instrument$Logger.transform(Instrument.java:78)
at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:215)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
at org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:497)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:150)
at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:440)
at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:390)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:471)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at com.temp.tempAccessFilter.doFilter(tempAccessFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:457)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:576)
at java.lang.Thread.run(Thread.java:619)
Caused by: javassist.bytecode.BadBytecode: unset variable
at javassist.bytecode.stackmap.TypeData.setType(TypeData.java:44)
at javassist.bytecode.stackmap.Tracer.checkParamTypes(Tracer.java:908)
at javassist.bytecode.stackmap.Tracer.doInvokeMethod(Tracer.java:813)
at javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:615)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:101)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
at javassist.CtBehavior.insertBefore(CtBehavior.java:715)
... 49 more
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
javax.servlet.ServletException: (class: org/apache/jsp/tempLogin_jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V) Accessing value from uninitialized register 35
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at com.temp.tempAccessFilter.doFilter(tempAccessFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:457)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:576)
at java.lang.Thread.run(Thread.java:619)
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527169#527169
More information about the jboss-user
mailing list