when close the application,i got exception below:
[ INFO ] [2016-01-25 10:01:18] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext doClose [957] - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@428a71be: startup date [Sat Jan 23 18:15:42 CST 2016]; root of context hierarchy
[ INFO ] [2016-01-25 10:01:18] org.springframework.context.support.DefaultLifecycleProcessor stop [356] - Stopping beans in phase 2147483647
[ WARN ] [2016-01-25 10:01:18] org.springframework.context.support.DefaultLifecycleProcessor doStop [257] - Failed to stop bean 'redisMessageListenerContainer'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:972) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:898) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.DefaultLifecycleProcessor$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:370) ~[na:1.8.0_65]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_65]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_65]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:166) ~[isesol-education-mobile-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:130) ~[isesol-education-mobile-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
... 7 common frames omitted
Caused by: java.util.zip.ZipException: invalid stored block lengths
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) ~[na:1.8.0_65]
at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52) ~[isesol-education-mobile-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at sun.misc.Resource.getBytes(Resource.java:124) ~[na:1.8.0_65]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:462) ~[na:1.8.0_65]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_65]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_65]
... 14 common frames omitted
[ WARN ] [2016-01-25 10:01:48] org.springframework.context.support.DefaultLifecycleProcessor stop [373] - Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000: [redisMessageListenerContainer]
[ INFO ] [2016-01-25 10:01:48] org.springframework.context.support.DefaultLifecycleProcessor stop [356] - Stopping beans in phase 0
[ WARN ] [2016-01-25 10:01:48] org.springframework.context.support.DefaultLifecycleProcessor doStop [257] - Failed to stop bean 'endpointMBeanExporter'
java.lang.NoClassDefFoundError: org/springframework/context/support/DefaultLifecycleProcessor$1
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:229) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:51) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:363) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:202) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:118) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:972) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:898) [spring-context-4.2.3.RELEASE.jar!/:4.2.3.RELEASE]
It looks like there's a corrupted jar file somewhere. That could be in your local Maven or Gradle cache or it could be that something has gone wrong when your application has been packaged. Please try building your application with a clean cache. If that doesn't resolve the issue, please provide a small sample project that reproduces the issue and we'll investigate.
it works.thanks
@wilkinsona I have exactly the same problem. Are you sure repackaging is not causing such problems?
I've never seen repackaging cause this problem. Please see my comment above for some advice on what to try.
I think I know when this problem occurs. It's happening when you launch application from fat-jar. Then you copy newer version of this jar, and after replacing file you're trying to stop your application.
@jkubrynski I can confirm that, we've also observed the same exception when accidentally replacing JAR before stopping the app.
All bets are off when you do that
See also #1106
Indeed this is happening to me too. We are using ansible for deployment. And the sequence of events is:
1) Use ansible's "maven" module to pull the desired jar from nexus.
2) If step 1 resulted in a changed jar, trigger an ansible handler that ensures the service state is "restarted"
3) This causes ansible to stop and restart the service
4) Upon stop, we see the NoClassDefFoundError
5) But the service does not really stop. So when the start happens, we get port conflicts.
In case anyone else runs into this, I solved it by changing the ansible deployment strategy a little bit.
1) Use ansible's maven module to pull the desired jar from nexus to a staging location.
2) If step 1 resulted in a changed jar, stop the service and only then copy the staged jar to the real jar location. At the same time, trigger the ansible handler that ensures the service state is "restarted"
The only downside is we have to keep the staging jar around, so I just leave it in /tmp
Most helpful comment
I think I know when this problem occurs. It's happening when you launch application from fat-jar. Then you copy newer version of this jar, and after replacing file you're trying to stop your application.