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

Spring Boot Application fails to startup after adding cache2k dependencies #94

Closed
u6f6o opened this Issue Sep 26, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@u6f6o
Copy link

u6f6o commented Sep 26, 2018

I recently tested cache2k in a spring boot application, adding the required dependencies in the build.gradle file:

"org.cache2k:cache2k-api::1.2.0.Final",
"org.cache2k:cache2k-core::1.2.0.Final",
"org.cache2k:cache2k-spring:1.2.0.Final"

While evaluating cache2k inside my IDE (IntelliJ), everything worked nicely. The application started and cache2k worked as supposed. Afterwards I started the application locally, invoking gradlew bootRun on the console and everything worked like a charm as well.

Today I tried to deploy the application on our AWS EC2 instances but the application did no longer start. Opposed to the previously mentioned steps, the app is started by using the jar file that was created by spring boot:

java -server -jar myapp-build-20180926-131926.jar

As it looks like, bundling cache2k with spring boot mechanics does not work so well atm:

{"retry_after":1,"ok":false,"error":"rate_limited"}Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/cache2k-base-bom-1.2.0.Final.pom
      at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108)
      at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:86)
      at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/cache2k-base-bom-1.2.0.Final.pom'
      at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:254)
      at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:239)
      at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
      ... 4 more
Caused by: java.io.IOException: Unable to find ZIP central directory records after reading 1507 bytes
      at org.springframework.boot.loader.jar.CentralDirectoryEndRecord.<init>(CentralDirectoryEndRecord.java:65)
      at org.springframework.boot.loader.jar.CentralDirectoryParser.parse(CentralDirectoryParser.java:52)
      at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:121)
      at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:109)
      at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:287)
      at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:262)
      at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:250)
      ... 6 more

After a role back (disabling cache2k), the deployment and start of the application worked again. I also downloaded the spring boot jar file from our artifact repository and the same error occurred on my local machine.

@cruftex

This comment has been minimized.

Copy link
Member

cruftex commented Sep 28, 2018

Interesting, thanks for the bug report!

Within cache2k-spring I use the a single POM-type dependency that in turn depends on the api and the core module. Also I think my kind of usage is correct and useful, its quite uncommon and seams to confuse the spring boot startup. I'll check and get rid of this dependency.

@cruftex cruftex self-assigned this Sep 28, 2018

@cruftex cruftex added this to the v1.2.1 milestone Sep 28, 2018

@cruftex cruftex added the bug label Sep 28, 2018

@dashfwd

This comment has been minimized.

Copy link

dashfwd commented Jan 3, 2019

Interesting, thanks for the bug report!

Within cache2k-spring I use the a single POM-type dependency that in turn depends on the api and the core module. Also I think my kind of usage is correct and useful, its quite uncommon and seams to confuse the spring boot startup. I'll check and get rid of this dependency.

I'm having this same issue, which is preventing me from using Cache2K with my Spring Boot project. Is there a workaround? You mention "I use the a single POM-type dependency" but I'm not sure what that means. If there's a workaround, can you provide an example of what dependencies can be used for the workaround?

@dashfwd

This comment has been minimized.

Copy link

dashfwd commented Jan 3, 2019

So the source of the problem appears to be that the Spring boot .jar file that is generated by gradle contains a POM file (BOOT-INF/lib/cache2k-base-bom-1.2.0.Final.pom) instead of a JAR.

Based on this Stack Overflow post, I changed my build.gradle file as follows:

def cache2kVersion = '1.2.0.Final'
compile "org.cache2k:cache2k-base-bom:${cache2kVersion}"
compile("org.cache2k:cache2k-spring:${cache2kVersion}") {
   exclude group: 'org.cache2k', module: 'cache2k-base-bom'
}

That workaround appeared to work for me, although I have to admit I don't understand the specifics of why.

@cruftex

This comment has been minimized.

Copy link
Member

cruftex commented Mar 8, 2019

Just release 1.2.1 with a fix of this problem.

@cruftex cruftex closed this Mar 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.