1

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.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Andrew Harmel-Law
  • 7,739
  • 12
  • 44
  • 55
  • Bad JAR file in your local maven cache (it happens)? Did you try actually running the app with "mvn spring-boot:run"? If you have a bad JAR file it might show up that way. – Dave Syer Jan 28 '14 at 12:02
  • Also can you try 1.0.0.RC1 or a snapshot please? I think there were some jar extraction issues that we came across and fixed. – Dave Syer Jan 28 '14 at 12:02
  • OK. Update to 1.0.0.RC1 didn't fix it - same error as above (but nice to be on the latest). However "mvn spring-boot:run" came up as expected but reported a Zipfile problem (just as @DaveSyer predicted) when trying to process a Jar for TLD files (we're using the web flavour of Spring Boot) – Andrew Harmel-Law Jan 28 '14 at 13:17
  • Not sure whether that means you solved your problem or if so how. But we don't support JSP taglibs in embedded servers, so if that's the TLD problem, you'll either have to find an alternative view technology or switch to deploying a WAR file. – Dave Syer Jan 28 '14 at 15:15
  • Thanks Dave. We (fortunately) could remove the dependency which had TLD issues. It all comes up beautifully now. Thanks. Do you want to craft an answer out of this chat so you can claim the SO points? If not, I'll drop something in to complete the loop. – Andrew Harmel-Law Jan 29 '14 at 10:05
  • I don't think I know enough about what fixed it for you to write an answer. I'd like to know what the issue was. – Dave Syer Jan 29 '14 at 10:33
  • Sorry. As suspected, we had a corrupt jar file. Running mvn spring-boot:run clearly identified it. I then removed it from my POM dependencies (it was na nice to have any way) and then re-ran. After that mvn spring-boot: run and java-jar both worked on Windows and Centos as expected. – Andrew Harmel-Law Jan 29 '14 at 15:40
  • I also faced this issue in a project and nothing seemed to solve it. By hit and trial, I found that this error was coming when adding apache Jena to my pom. Created a [ticket](https://github.com/spring-projects/spring-boot/issues/324) for this. – Sanjay Feb 07 '14 at 10:03

2 Answers2

3

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.

Dave Syer
  • 56,583
  • 10
  • 155
  • 143
0

I think RC2 might have this issue fixed.

Sanjay
  • 8,755
  • 7
  • 46
  • 62