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

java.lang.NoSuchFieldError: r$sfields with spring-loaded

Open preethi29 opened this issue 10 years ago • 4 comments

Hi, the configuration I used for adding spring-loaded (tomcat 7, java 7) is '-javaagent:/Projects/springloaded-1.2.4.RELEASE.jar -noverify'. The app contains different modules which will be packed as .omod files and given to tomcat. When I start tomcat, I get the following error:

java.lang.NoSuchFieldError: r$sfields at org.myproject.module.metadata.MetadataSharing17Configuration$$EnhancerByCGLIB$$ae5743fa.() at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386) at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:92) at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:358) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:244) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)

Any idea why this error would be thrown?

preethi29 avatar Oct 04 '15 09:10 preethi29

Hi,

Have you disabled session persistence on tomcat?

I've only got spring-loaded to work with tomcat when I discovered this option.

Just add <Manager pathname="" /> to your context.xml

Hope it helps.

Marcio

On Sun, Oct 4, 2015, 06:15 Preethi [email protected] wrote:

Hi, the configuration I used for adding spring-loaded (tomcat 7, java 7) is '-javaagent:/Projects/springloaded-1.2.4.RELEASE.jar -noverify'. The app contains different modules which will be packed as .omod files and given to tomcat. When I start tomcat, I get the following error:

java.lang.NoSuchFieldError: r$sfields at org.myproject.module.metadata.MetadataSharing17Configuration$$EnhancerByCGLIB$$ae5743fa.() at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386) at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:92) at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:358) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:244) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)

Any idea why this error would be thrown?

— Reply to this email directly or view it on GitHub https://github.com/spring-projects/spring-loaded/issues/151.

marweck avatar Oct 04 '15 15:10 marweck

The underlying reason for this exception is that we are expecting something to have been treated as reloadable but it has not been. (So we expected to find r$fields on it, but it wasn't there). There can be a few reasons for it - like using split packages (where some of your app is loaded from .class files on disk but you have classes in the same package also coming from a jar dependency). In order to dig into it I would need to be able to recreate it. The tip from Marcio sounds interesting, I wonder why that makes a difference.

aclement avatar Oct 06 '15 23:10 aclement

Hi Andy,

Actually this is not a spring loaded issue, but a spring IOC + tomcat one.

Let me explain it better.

Since all the injected dependencies are cglib proxies created dynamically at classload time (I guess) , when tomcat tries to deserialize previous sessions it can't find the original cglib proxy classes. So they raise a lot of ClassNotFound exceptions and the whole hot swap process breaks down.

Even when spring-loaded is not activated, tomcat has this issue at the moment it tries to deserialize a previous session.

I'm using tomcat 7 and spring 3.4.

Hope it helps.

On Tue, Oct 6, 2015, 20:26 Andy Clement [email protected] wrote:

The underlying reason for this exception is that we are expecting something to have been treated as reloadable but it has not been. (So we expected to find r$fields on it, but it wasn't there). There can be a few reasons for it - like using split packages (where some of your app is loaded from .class files on disk but you have classes in the same package also coming from a jar dependency). In order to dig into it I would need to be able to recreate it. The tip from Marcio sounds interesting, I wonder why that makes a difference.

— Reply to this email directly or view it on GitHub https://github.com/spring-projects/spring-loaded/issues/151#issuecomment-146032577 .

marweck avatar Oct 07 '15 00:10 marweck

Hi,

Any fix or workarounds for this issue ? :(

Reeska avatar Jan 16 '17 15:01 Reeska