spring-projects / spring-loaded

Java agent that enables class reloading in a running JVM
Apache License 2.0
2.72k stars 515 forks source link

Errors seen during class reload. #4

Open iamahern opened 11 years ago

iamahern commented 11 years ago

I was seeing exceptions from Springloaded and the exceptions instructed me to raise a defect.

Here is the stack trace from the exception I was seeing:

java.lang.RuntimeException: Reloading agent exited via exception, please raise a jira at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:104) 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.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.util.ResourceBundle$Control.newBundle(ResourceBundle.java:2383) at java.util.ResourceBundle.loadBundle(ResourceBundle.java:1406) at java.util.ResourceBundle.findBundle(ResourceBundle.java:1365) at java.util.ResourceBundle.findBundle(ResourceBundle.java:1292) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1234) at java.util.ResourceBundle.getBundle(ResourceBundle.java:787) at curam.util.message.MessageCatalog.getCatalog(MessageCatalog.java:207) at curam.util.message.CatEntry.getMessageText(CatEntry.java:170) at curam.util.message.CatEntry.getMessageText(CatEntry.java:157) at curam.core.sl.impl.LocalizableXMLStringHelper.toLocalisableString(LocalizableXMLStringHelper.java:347) at curam.core.sl.impl.LocalizableXMLStringHelper.toPlainText(LocalizableXMLStringHelper.java:247) at curam.core.sl.infrastructure.impl.EvidenceController.listActive(EvidenceController.java:10571) at curam.pdc.impl.PDCAlternateID.cancelAlternateIDEvidence(PDCAlternateID.java:439) at curam.pdc.impl.PDCAlternateID.cancel(PDCAlternateID.java:400) at curam.identityhub.impl.IdentityHubDAOImpl.disconnectConcernFromIdentityHub(IdentityHubDAOImpl.java:295) at curam.identityhub.facade.impl.IdentityHub.disconnectConcernFromIdentityHub(IdentityHub.java:110) at curam.identityhub.facade.fact.IdentityHubFactory.disconnectConcernFromIdentityHub(IdentityHubFactory.java) 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 org.springsource.loaded.ri.OriginalClassInvoker.invoke(OriginalClassInvoker.java:47) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1272) at curam.util.internal.CuramSessionBean.invoke(CuramSessionBean.java:272) at curam.util.internal.CuramSessionBean.invoke(CuramSessionBean.java:333) at curam.util.internal.OnlineMethod.rmiInvoke(OnlineMethod.java:96) at curam.util.invoke.RMIMethodImpl.invoke(RMIMethodImpl.java:121) at curam.util.invoke._RMIMethodImpl_Tie.invokeCORBA_WStringValue__CORBA_WStringValueorg_omg_boxedRMI_java_lang_seq1_Object(_RMIMethodImpl_Tie.java:144) at curam.util.invoke._RMIMethodImpl_Tie._invoke(_RMIMethodImpl_Tie.java:84) at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:637) at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:189) at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1682) at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1540) at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:922) at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:181) at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:694) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:451) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1213) at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:471) at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:500) Caused by: org.springsource.loaded.ReloadException: Problem defining class curam.dynamicevidence.message.DynamicEvidenceGeneralI at org.springsource.loaded.TypeRegistry.defineClass(TypeRegistry.java:1071) at org.springsource.loaded.ReloadableType.rewriteCallSitesAndDefine(ReloadableType.java:807) at org.springsource.loaded.ReloadableType.(ReloadableType.java:151) at org.springsource.loaded.TypeRegistry.addType(TypeRegistry.java:886) at org.springsource.loaded.agent.SpringLoadedPreProcessor.preProcess(SpringLoadedPreProcessor.java:245) at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:102) ... 54 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springsource.loaded.TypeRegistry.defineClass(TypeRegistry.java:1066) ... 59 more Caused by: java.lang.NoClassDefFoundError: curam/dynamicevidence/message/DynamicEvidenceGeneralI (wrong name: curam/dynamicevidence/message/DYNAMICEVIDENCEGENERAL__I) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.lang.ClassLoader.defineClass(ClassLoader.java:466) ... 63 more

iamahern commented 11 years ago

Digging through the stack trace the exception is benign.

ResourceBundle attempts reflectively load a class called: "DynamicEvidenceGeneral"; the class does not exist and the ResourceBundle handles the ClassNotFoundException and carries on.

At the ClassLoader/SpringLoaded level - because this is on windows - something is tripping up and trying to serve "DYNAMICEVIDENCEGENERAL" as the class for "DynamicEvidenceGeneral". The java classloader then interprets the bytes and sees that this is not actually the class expected.


From an end user perspective, the exception is benign, but - being completely ignorant of how SpringLoaded actually functions - it might point to missing logic whereby .class files are interpretted to determine their contents rather than just matched by path?

aclement commented 11 years ago

it might point to missing logic whereby .class files are interpretted to determine their contents rather than just matched by path?

Possibly, but I'd need a reproducible testcase to really dig into this. Springloaded tries to play nicely when interacting with classloaders and working with resources on the disk.

iamahern commented 11 years ago

I have a test case that can reproduce the issue consistently. It is not automated and and (if the theory holds) you may need to run it on a windows box. I don't see a way to upload it here so I will email you directly.

Stepping away and stepping back to my desk, I think this should be reproducible on a *Nix just as well if you are a Mac user.

aclement commented 10 years ago

Sorry I'm very slow posting here. Did you email me that test project? Trying to search through my old email for it but not sure what to search for.