spring-guides / gs-accessing-data-jpa

Accessing Data with JPA :: Learn how to work with JPA data persistence using Spring Data JPA.
https://spring.io/guides/gs/accessing-data-jpa/
Apache License 2.0
242 stars 347 forks source link

ClassNotFound issue on clean checked out project #16

Closed jjromannet closed 8 years ago

jjromannet commented 8 years ago

I downloaded latest version from master. Both "mvnw spring-boot:run" and "mvnw clean package" are failing with same error "mvnw clean package -Dmaven.test.skip=true" succeed so JAR is being build but same exception occurs when running with java -jar target/gs-accessing-data-jpa-0.1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.0.RELEASE)

2016-09-07 22:35:57.704  INFO 9948 --- [           main] hello.Application                        : Starting Application v0.1.0 on DESKTOP-C6DUQ9V with PID 9948 (C:\workspace\projects\spring-tutorial\gs-accessing-data-jpa-master\complete\target\gs-accessing-data-jpa-0.1.0.jar started by mail in C:\workspace\projects\spring-tutorial\gs-accessing-data-jpa-master\complete)
2016-09-07 22:35:57.709  INFO 9948 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2016-09-07 22:35:57.798  INFO 9948 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@22d8cfe0: startup date [Wed Sep 07 22:35:57 CEST 2016]; root of context hierarchy
2016-09-07 22:35:58.752 ERROR 9948 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.NoClassDefFoundError: org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor
        at org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.<clinit>(JpaRepositoryConfigExtension.java:65) ~[spring-data-jpa-1.10.2.RELEASE.jar!/:na]
        at org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfigureRegistrar.getRepositoryConfigurationExtension(JpaRepositoriesAutoConfigureRegistrar.java:49) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60) ~[spring-boot-autoconfigure-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:333) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at hello.Application.main(Application.java:17) [classes!/:0.1.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_102]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor
        at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_102]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_102]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_102]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_102]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_102]
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:89) ~[gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_102]
        ... 26 common frames omitted
Caused by: java.util.zip.ZipException: invalid code lengths set
        at java.util.zip.InflaterInputStream.read(Unknown Source) ~[na:1.8.0_102]
        at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52) ~[gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at sun.misc.Resource.getBytes(Unknown Source) ~[na:1.8.0_102]
        at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.8.0_102]
        at java.net.URLClassLoader.access$100(Unknown Source) ~[na:1.8.0_102]
        ... 33 common frames omitted

2016-09-07 22:35:58.756  INFO 9948 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@22d8cfe0: startup date [Wed Sep 07 22:35:57 CEST 2016]; root of context hierarchy
2016-09-07 22:35:58.759  WARN 9948 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.context.annotation.AnnotationConfigApplicationContext@22d8cfe0: startup date [Wed Sep 07 22:35:57 CEST 2016]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:416) [spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:997) [spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956) [spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:815) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
        at hello.Application.main(Application.java:17) [classes!/:0.1.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_102]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_102]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [gs-accessing-data-jpa-0.1.0.jar:0.1.0]

Spec: Java version: Java 8 build 102 OS: Windows 10

Dependency tree:

[INFO] org.springframework:gs-accessing-data-jpa:jar:0.1.0
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:1.4.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:1.4.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.0.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.1.7:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.1.7:compile
[INFO] |  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] |  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.21:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.4.0.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:4.3.2.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.0.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.4:compile
[INFO] |  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.4:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.3.2.RELEASE:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.0.9.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:5.0.9.Final:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:4.3.2.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-context:jar:4.3.2.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-expression:jar:4.3.2.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:4.3.2.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:4.3.2.RELEASE:compile
[INFO] |  |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
[INFO] |  \- org.springframework:spring-aspects:jar:4.3.2.RELEASE:compile
[INFO] +- com.h2database:h2:jar:1.4.192:compile
[INFO] \- org.springframework.boot:spring-boot-starter-test:jar:1.4.0.RELEASE:test
[INFO]    +- org.springframework.boot:spring-boot-test:jar:1.4.0.RELEASE:test
[INFO]    +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.0.RELEASE:test
[INFO]    +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO]    |  \- net.minidev:json-smart:jar:2.2.1:test
[INFO]    |     \- net.minidev:accessors-smart:jar:1.1:test
[INFO]    |        \- org.ow2.asm:asm:jar:5.0.3:test
[INFO]    +- junit:junit:jar:4.12:test
[INFO]    +- org.assertj:assertj-core:jar:2.5.0:test
[INFO]    +- org.mockito:mockito-core:jar:1.10.19:test
[INFO]    |  \- org.objenesis:objenesis:jar:2.1:test
[INFO]    +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO]    +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO]    +- org.skyscreamer:jsonassert:jar:1.3.0:test
[INFO]    |  \- org.json:json:jar:20140107:test
[INFO]    +- org.springframework:spring-core:jar:4.3.2.RELEASE:compile
[INFO]    \- org.springframework:spring-test:jar:4.3.2.RELEASE:test
[INFO] ------------------------------------------------------------------------`
mp911de commented 8 years ago

It looks like corrupted jar. From the stack trace and the reported class org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor I assume it's spring-orm-4.3.2.RELEASE.jar. Please delete the path org/springframework/spring-orm/4.3.2.RELEASE in your local maven repository and retry running the guide.

jjromannet commented 8 years ago

Thank you very much. This indeed did the job.