spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.25k stars 37.98k forks source link

java.lang.NoSuchMethodError when calling a class that extends org.springframework.web.util.CookieGenerator from Spring 2 but that it is been used in Spring 3. [SPR-6942] #11607

Closed spring-projects-issues closed 5 years ago

spring-projects-issues commented 14 years ago

jose antonio perez garcia opened SPR-6942 and commented

public class TestCookieGenerator extends CookieGenerator {

private static final int COOKIE_MAX_AGE = 365 * 24 * 60 * 60;

public TestCookieGenerator() {
    setCookieName(COOKIE_NAME);
    setCookieMaxAge(COOKIE_MAX_AGE);
}

}

TestCookieGenerator is been compiled using spring 2.5.6 which setCookieMaxAge(...) use an int in Spring 2.5.6 but this has change to be an Integer in Spring 3.

This doesn't seems to be a problem of autoboxing in Java. The problem comes up when a project that uses spring 3,it uses the library where the TestCookieGenerator has been compiled using spring 2.5.6. Because spring uses reflection to instantiate beans and reflection doesn't manage autoboxing(It is done at compilation time), that produce the next exception "java.lang.NoSuchMethodError: org.springframework.web.util.CookieGenerator.setCookieMaxAge(I)V".


Affects: 3.0 GA

1 votes, 2 watchers

spring-projects-issues commented 12 years ago

Claudio Sanchez commented

Hi, is there any progress about this one?. It break the runtime compatibility between Spring 2 and 3. If a library was compilated against Spring 2 it cant't be used in a project that use Spring 3 and vice versa. Its not needed to extend the class, every class that explicitly call the method setCookieMaxAge reproduce the problem.

spring-projects-issues commented 5 years ago

Sébastien Deleuze commented

I am resolving this issue as invalid as it is now outdated.