java.io.IOException when running Spring Boot jar on Centos 6.4 / Open JDK 1.7.0

巧了我就是萌 提交于 2020-01-05 12:12:31

问题


We have a spring boot (0.5.0.M7) generated jar file. When we "mvn clean package" and then run ("java -jar target/my-app-camel-0.1.0.jar") on Windows 7 (64 bit with Oracle 64-bit Java SE JVM, 1.7.0_51-b13) it all works as expected:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::             (v0.5.0.M7)

10:47:25.324 [main] INFO  com.myco.myapp.Application - Starting Application on MYLAPTOP with PID 12260 (D:\Users\me\My Projects\Work\myco\myapp\src\myapp\my-app-camel\target\my-app-camel-0.1.0-SNAPSHOT.jar started by ME)
10:47:25.953 [main] INFO  o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/camel-server.xml]
10:47:27.698 [main] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1e6d136c: startup date [Tue Jan 28 10:47:27 GMT 2014]; root of context hierarchy
...

However, when we "mvn clean package" and then run ("java -jar target/my-app-camel-0.1.0.jar") on CentOS release 6.4 (Final) (64 bit OS, with OpenJDK 64-bit Java SE JVM, 1.7.0_51-b02) it fails:

java.io.IOException: Unable to find ZIP central directory records after reading 206 bytes
    at org.springframework.boot.loader.jar.CentralDirectoryEndRecord.<init>(CentralDirectoryEndRecord.java:64)
    at org.springframework.boot.loader.jar.JarFile.loadJarEntries(JarFile.java:124)
    at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:120)
    at org.springframework.boot.loader.jar.JarFile.getNestedJarFileFromFileEntry(JarFile.java:333)
    at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:305)
    at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:87)
    at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:74)
    at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:78)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:52)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:44)

NOTE: When I "unzip my-app-camel.jar" on the Centos command line it extracts fine.


回答1:


Looks like it was a bad JAR file in the local maven cache (it happens). One thing that's worth trying is actually running the app with "mvn spring-boot:run". If you have a bad JAR file it might show up that way. Another is to delete the local cached file (e.g. from "~/.m2/repository") and rebuild the application.




回答2:


I think RC2 might have this issue fixed.



来源:https://stackoverflow.com/questions/21403987/java-io-ioexception-when-running-spring-boot-jar-on-centos-6-4-open-jdk-1-7-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!