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

ClassNotFoundException for EnableSpringDataWebSupport & EnableWebSecurity #4121

Closed
eddumelendez opened this issue Oct 8, 2015 · 4 comments
Closed
Labels
status: invalid An issue that we don't feel is valid

Comments

@eddumelendez
Copy link
Contributor

During test execution ClassNotFoundException is thrown for EnableSpringDataWebSupport and EnableWebSecurity because these annotations are in the root of auto-configuration class.

You can use the joshlong/mybatis-spring-boot repo to reproduce and run MybatisAutoConfigurationTest class.

eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Oct 8, 2015
Add first validation for these classes on the classpath before to use them.

See spring-projectsgh-4121
eddumelendez added a commit to eddumelendez/spring-boot that referenced this issue Oct 8, 2015
Add first validation for these classes on the classpath before to use them.

See spring-projectsgh-4121
@wilkinsona
Copy link
Member

During test execution ClassNotFoundException is thrown for EnableSpringDataWebSupport and EnableWebSecurity

If an annotation isn't on the classpath, the JVM will just ignore it. Are the ClassNotFoundExceptions actually for classes that the annotations reference? I tried building the project that you referenced and all the tests passed. Can you provide some more info on the failures, or some updated instructions on how to reproduce the problem please?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Oct 8, 2015
@eddumelendez
Copy link
Contributor Author

Yes, all tests passed but the execution of MybatisAutoConfigurationTest::testDefaultConfiguration will show you exceptions in the log.

06:45:45.560 [main] DEBUG o.s.c.t.c.AnnotationAttributesReadingVisitor - Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.
java.lang.ClassNotFoundException: org.springframework.data.web.config.EnableSpringDataWebSupport
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_31]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_31]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_31]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_31]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_31]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_31]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_31]
    at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:47) ~[spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.accept(ClassReader.java:642) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.accept(ClassReader.java:508) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClasses.<init>(AutoConfigurationSorter.java:112) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.boot.autoconfigure.AutoConfigurationSorter.getInPriorityOrder(AutoConfigurationSorter.java:57) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.selectImports(EnableAutoConfigurationImportSelector.java:72) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:430) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfigurationTest.testDefaultConfiguration(MybatisAutoConfigurationTest.java:60) [test-classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) [junit-rt.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) [idea_rt.jar:na]
06:45:45.649 [main] DEBUG o.s.c.t.c.AnnotationAttributesReadingVisitor - Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.
java.lang.ClassNotFoundException: org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_31]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_31]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_31]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_31]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_31]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_31]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_31]
    at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:47) ~[spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.accept(ClassReader.java:642) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.asm.ClassReader.accept(ClassReader.java:508) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93) [spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.boot.autoconfigure.AutoConfigurationSorter$AutoConfigurationClasses.<init>(AutoConfigurationSorter.java:112) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.boot.autoconfigure.AutoConfigurationSorter.getInPriorityOrder(AutoConfigurationSorter.java:57) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.selectImports(EnableAutoConfigurationImportSelector.java:72) [spring-boot-autoconfigure-1.2.6.RELEASE.jar:1.2.6.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:430) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:306) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfigurationTest.testDefaultConfiguration(MybatisAutoConfigurationTest.java:60) [test-classes/:na]

@wilkinsona
Copy link
Member

Thanks, Eddu. Those errors are benign, which is why they're logged at debug.

Spring Framework uses ASM to look at the bytecode. In this case it's found an annotation that isn't on the classpath. That means that metadata about the annotation will be unavailable, nothing more. When the class is actually loaded, the JVM drops the annotation as it's not on the classpath.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 8, 2015
@eddumelendez
Copy link
Contributor Author

Thanks to clarify @wilkinsona

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants