spring-loaded icon indicating copy to clipboard operation
spring-loaded copied to clipboard

Starting hosted Eclipse instance immediately fails with java.lang.NoClassDefFoundError: org/springsource/loaded/ri/ReflectiveInterceptor

Open fbricon opened this issue 9 years ago • 3 comments

I'm trying to see if the Eclipse plug-in development experience could be enhanced by running hosted Eclipse instances with the spring-loaded agent.

When launching an Eclipse plugin as an Eclipse Application (using OSX 10.10.2, Eclipse Mars M5, Oracle JDK 1.8.0_40 or Oracle JDK 1.7.0_60), after adding the -javaagent:...springloaded-1.2.3.RELEASE.jar -noverify to the JVM arguments of the launch configuration, Eclipse fails fast :

 An error has occurred.  See the log file
 /Users/fbricon/Dev/workspaces/test/.metadata/.plugins/org.eclipse.pde.core/New_configuration/1428531082949.log

The log contains :

!MESSAGE Exception launching the Eclipse Platform:                                                    
!STACK                                                                                                
java.lang.NoClassDefFoundError: org/springsource/loaded/ri/ReflectiveInterceptor                      
  at org.eclipse.osgi.util.NLS.load(NLS.java:305)                                                     
  at org.eclipse.osgi.util.NLS.initializeMessages(NLS.java:143)                                       
  at org.eclipse.osgi.internal.messages.Msg.<clinit>(Msg.java:68)                                     
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:241)                     
  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:497)                                                 
  at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
  at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)                                 
  at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)                                        
  at org.eclipse.equinox.launcher.Main.run(Main.java:1465)                                            
  at org.eclipse.equinox.launcher.Main.main(Main.java:1438)                                           
Caused by: java.lang.ClassNotFoundException: org.springsource.loaded.ri.ReflectiveInterceptor         
  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)                                       
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)                                            
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)                                            
... 13 more               

Starting with -Dspringloaded=verbose, a whole bunch of debug statements similar to this are displayed :

 [...]
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=sun/reflect/BootstrapConstructorAccessorImpl classloader=null typeRegistry=null                                                                                                                             
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/eclipse/core/runtime/adaptor/EclipseStarter classloader=Main$StartupClassLoader typeRegistry=TypeRegistry(id=117244645,loader=org.eclipse.equinox.launcher.Main$StartupClassLoader)                     
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/springsource/loaded/ri/ReflectiveInterceptor classloader=Launcher$AppClassLoader typeRegistry=TypeRegistry(id=519821334,loader=sun.misc.Launcher$AppClassLoader)                                        
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/springsource/loaded/NameRegistry classloader=Launcher$AppClassLoader typeRegistry=TypeRegistry(id=519821334,loader=sun.misc.Launcher$AppClassLoader)                                                    
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=java/util/concurrent/Semaphore classloader=null typeRegistry=null                                                                                                                                           
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/eclipse/core/runtime/adaptor/EclipseStarter$StartupEventListener classloader=Main$StartupClassLoader typeRegistry=TypeRegistry(id=117244645,loader=org.eclipse.equinox.launcher.Main$StartupClassLoader)
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/osgi/framework/SynchronousBundleListener classloader=Main$StartupClassLoader typeRegistry=TypeRegistry(id=117244645,loader=org.eclipse.equinox.launcher.Main$StartupClassLoader)                        
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=org/osgi/framework/BundleListener classloader=Main$StartupClassLoader typeRegistry=TypeRegistry(id=117244645,loader=org.eclipse.equinox.launcher.Main$StartupClassLoader)                                   
 avr. 08, 2015 6:11:22 PM org.springsource.loaded.agent.SpringLoadedPreProcessor logPreProcess                                                                                                                                                            
 INFOS: SpringLoaded preprocessing: classname=java/util/EventListener classloader=null typeRegistry=null
 [...]

It'd be nice if that could, you know, just work :-)

fbricon avatar Apr 08 '15 22:04 fbricon

@fbricon I wouldn't expect from javaagent to just work in OSGI land :)

Did you try to setup boot delegation?

Taken from jprofiler setup (I guess they would have similar issues):

-Xbootclasspath/a:${jprofiler.root.folder}\bin\agent.jar -Dorg.osgi.framework.bootdelegation=com.jprofiler.*

ilx avatar Apr 09 '15 10:04 ilx

That spits a lot of errors in the logs :

INFOS: SpringLoaded preprocessing: classname=org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerHideProcessor classloader=EquinoxClassLoader typeRegistry=TypeRegistry(id=964863654,loader=org.eclipse.osgi.internal.loader.EquinoxClassLoader)
java.lang.NullPointerException
  at org.springsource.loaded.agent.SpringLoadedPreProcessor.tryToEnsureSystemClassesInitialized(SpringLoadedPreProcessor.java:362)
  at org.springsource.loaded.agent.SpringLoadedPreProcessor.preProcess(SpringLoadedPreProcessor.java:128)
  at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:102)

NPE occurs at SpringLoadedPreProcessor.java:362 :

Class<?> clazz = SpringLoadedPreProcessor.class.getClassLoader().loadClass(classname.replace('/', '.'));

According to the getClassLoader() javadoc :

Returns the class loader for the class.  Some implementations may use
null to represent the bootstrap class loader. This method will return
null in such implementations if this class was loaded by the bootstrap class loader.

fbricon avatar Apr 09 '15 18:04 fbricon

I put in a change for #116 that might affect things here too. People have tried in the past to use this with an Eclipse setup but it really wasn't engineered to cope with it. Possibly it just needs some tweaks around class loader delegation assumptions.

aclement avatar May 02 '15 23:05 aclement