puniverse / comsat

Fibers and actors for web development
docs.paralleluniverse.co/comsat
Other
598 stars 103 forks source link

NullPointerException Unable to instrument class co/paralleluniverse/fibers/servlet/FiberHttpServlet #59

Open jsteinich opened 8 years ago

jsteinich commented 8 years ago

Getting an error when starting up a Jetty server via gretty or Eclipse Jetty Plugin during instrumentation.

[quasar] WARNING: Can't determine super class of co/paralleluniverse/fibers/servlet/FiberServletContext [quasar] ERROR: Unable to instrument class co/paralleluniverse/fibers/servlet/FiberHttpServlet java.lang.NullPointerException at co.paralleluniverse.asm.Item.a(Unknown Source) at co.paralleluniverse.asm.ClassWriter.c(Unknown Source) at co.paralleluniverse.asm.ClassWriter.a(Unknown Source) at co.paralleluniverse.asm.Frame.a(Unknown Source) at co.paralleluniverse.asm.Frame.a(Unknown Source) at co.paralleluniverse.asm.MethodWriter.visitMaxs(Unknown Source) at co.paralleluniverse.asm.tree.MethodNode.accept(Unknown Source) at co.paralleluniverse.asm.commons.JSRInlinerAdapter.visitEnd(Unknown Source) at co.paralleluniverse.asm.MethodVisitor.visitEnd(Unknown Source) at co.paralleluniverse.fibers.instrument.InstrumentClass$1.visitEnd(InstrumentClass.java:193) at co.paralleluniverse.asm.ClassReader.b(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:120) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:88) at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:187) at sun.instrument.TransformerManager.transform(TransformerManager.java:188) at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475) at org.akhikhl.gretty.FilteringClassLoader.loadClass(FilteringClassLoader.java:62) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475) at org.akhikhl.gretty.FilteringClassLoader.loadClass(FilteringClassLoader.java:62) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86) at org.eclipse.jetty.webapp.DiscoveredAnnotation.loadClass(DiscoveredAnnotation.java:82) at org.eclipse.jetty.webapp.DiscoveredAnnotation.getTargetClass(DiscoveredAnnotation.java:67) at org.eclipse.jetty.annotations.WebServletAnnotation.apply(WebServletAnnotation.java:69) at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:419) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1339) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:517) at org.akhikhl.gretty.JettyWebAppContext.super$10$doStart(JettyWebAppContext.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150) at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.server.Server.start(Server.java:405) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.Server.doStart(Server.java:372) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:45) at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.akhikhl.gretty.Runner.run(Runner.groovy:119) at org.akhikhl.gretty.Runner.this$2$run(Runner.groovy) at org.akhikhl.gretty.Runner$this$2$run.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at org.akhikhl.gretty.Runner.main(Runner.groovy:46) [quasar] ERROR: while transforming co/paralleluniverse/fibers/servlet/FiberHttpServlet: null java.lang.NullPointerException at co.paralleluniverse.asm.Item.a(Unknown Source) at co.paralleluniverse.asm.ClassWriter.c(Unknown Source) at co.paralleluniverse.asm.ClassWriter.a(Unknown Source) at co.paralleluniverse.asm.Frame.a(Unknown Source) at co.paralleluniverse.asm.Frame.a(Unknown Source) at co.paralleluniverse.asm.MethodWriter.visitMaxs(Unknown Source) at co.paralleluniverse.asm.tree.MethodNode.accept(Unknown Source) at co.paralleluniverse.asm.commons.JSRInlinerAdapter.visitEnd(Unknown Source) at co.paralleluniverse.asm.MethodVisitor.visitEnd(Unknown Source) at co.paralleluniverse.fibers.instrument.InstrumentClass$1.visitEnd(InstrumentClass.java:193) at co.paralleluniverse.asm.ClassReader.b(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:120) at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:88) at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:187) at sun.instrument.TransformerManager.transform(TransformerManager.java:188) at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475) at org.akhikhl.gretty.FilteringClassLoader.loadClass(FilteringClassLoader.java:62) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:549) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:475) at org.akhikhl.gretty.FilteringClassLoader.loadClass(FilteringClassLoader.java:62) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86) at org.eclipse.jetty.webapp.DiscoveredAnnotation.loadClass(DiscoveredAnnotation.java:82) at org.eclipse.jetty.webapp.DiscoveredAnnotation.getTargetClass(DiscoveredAnnotation.java:67) at org.eclipse.jetty.annotations.WebServletAnnotation.apply(WebServletAnnotation.java:69) at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:419) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1339) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:517) at org.akhikhl.gretty.JettyWebAppContext.super$10$doStart(JettyWebAppContext.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150) at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.server.Server.start(Server.java:405) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.Server.doStart(Server.java:372) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:45) at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.akhikhl.gretty.Runner.run(Runner.groovy:119) at org.akhikhl.gretty.Runner.this$2$run(Runner.groovy) at org.akhikhl.gretty.Runner$this$2$run.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at org.akhikhl.gretty.Runner.main(Runner.groovy:46) 14:34:10 INFO Jetty 9.2.10.v20150310 started and listening on port 8080 14:34:10 INFO runs at: 14:34:10 INFO http://localhost:8080/ Press any key to stop the server. QUASAR WARNING: Quasar Java Agent isn't running. If you're using another instrumentation method you can ignore this message; otherwise, plea se refer to the Getting Started section in the Quasar documentation. [quasar] WARNING: Can't determine super class of com/google/common/collect/MapMakerInternalMap [quasar] WARNING: Can't determine super class of com/google/common/collect/MapMaker$NullConcurrentMap [quasar] WARNING: Can't determine super class of com/google/common/collect/MapMakerInternalMap$KeySet [quasar] WARNING: Can't determine super class of com/google/common/collect/MapMakerInternalMap$ExpirationQueue

I have a servlet which is currently just the example from http://docs.paralleluniverse.co/comsat/#servlets It seems to still work correctly, despite the errors.

My gradle file is: `apply plugin: 'java' apply plugin: 'war' apply plugin: 'org.akhikhl.gretty' apply plugin: 'eclipse-wtp'

sourceSets.main.java.srcDirs = ['src/']

configurations { quasar }

dependencies { compile 'co.paralleluniverse:quasar-core:0.7.5:jdk8' compile 'co.paralleluniverse:comsat-servlet:0.7.0' compile 'co.paralleluniverse:comsat-jdbc:0.7.0'

providedCompile 'javax.servlet:javax.servlet-api:3.1'

quasar 'co.paralleluniverse:quasar-core:0.7.5:jdk8'

}

configurations.grettyRunnerJetty9 { resolutionStrategy.eachDependency { DependencyResolveDetails dt -> if(dt.requested.group == 'org.eclipse.jetty' && dt.requested.name != 'jetty-jsp') { dt.useVersion '9.3.8.v20160314' } } }

gretty { port = 8080 contextPath = '/' servletContainer = 'jetty9' jvmArg "-javaagent:${configurations.quasar.iterator().next()}" }`

circlespainter commented 8 years ago

It looks like a classloader issue. I don't know much about Gretty but I suspect it uses the classloading structure of a standalone servlet container; have you tried using the Jetty instrumenting classloader instead?

Also, do you need multiple webapps? If not, wouldn't an embedded Jetty work for your use-case, like in this test?

jsteinich commented 8 years ago

I didn't have any luck the instrumenting classloader either, but I am new to both Jetty and Gretty so I may have just been configuring it wrong.

I have switched over to using embedded Jetty and things seem to be working better now.

Thanks for taking a look.

circlespainter commented 8 years ago

No problem, I'll have a try with the instrumenting classloader too before closing.