Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servlet 3.0 annotations cause BeanDefinitionStoreException in integration tests [SPR-10553] #15184

Closed
spring-projects-issues opened this issue May 12, 2013 · 4 comments
Assignees

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 12, 2013

Black dong opened SPR-10553 and commented

Overview

In my application, there are some classes marked with Servlet 3.0 annotations like @WebServlet. When I run tests involving these classes, there are test case failures.

  1. If I remove these classes, all test cases pass.
  2. If I change the jdk to 1.7, failed too.
  3. There is no error when running my app in jetty/tomcat.

I think this is a bug for spring test.

Attachments

  • AsyncServle.java: class annotated with @WebServlet
  • applicationContext.xml: Spring configuration
  • cornerstone.springframework.context.AnnotationConfigApplicationContextTest.txt: JUnit log for the failing test

Root Error

Caused by: java.lang.UnsupportedClassVersionError: javax/servlet/annotation/WebServlet : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	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:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:165)
	at org.springframework.asm.ClassReader.a(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:257)
	... 54 more

Affects: 3.2.2

Attachments:

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 13, 2013

Sam Brannen commented

I think this is a bug for spring test.

This is almost certainly not a bug in the spring-test module, simply because the visiting of candidate classes for component scanning is part of spring-core.

In any case, this really just sounds like an issue with the wrong JDK version for your tests.

So, please ensure that the JDK version you use when compiling your classes matches the JDK version you use when executing your tests.

For further information, consult these discussions on StackOverflow:

I am resolving this issue as Cannot Reproduce, but if you are able to reproduce this issue in a stand-alone project (i.e., in the spring-framework-issues repository), feel free to reopen this issue and link to the issue project you've created.

Regards,

Sam

Loading

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 22, 2013

Black dong commented

I think this is a bug for spring test, is there any one can make an environment to reproduce this issue? Just add a Servlet class marked with @WebServlet into your auto scan package,it reproduced. This bug blocks my junit testing!

Loading

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 22, 2013

Juergen Hoeller commented

This very much looks like a JDK version problem: We are trying to load the WebServlet annotation type from the Servlet 3.0 API jar there, and your JVM refuses to accept the bytecode version (1.6) in that Servlet 3.0 API jar. I don't see what we can do about this from the framework side, since all we do is some innocent access to ClassLoader.loadClass...

Juergen

Loading

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 22, 2013

Black dong commented

OK, please close this bug.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants