Skip to content

Gradle POM-only dependencies cause jar application loader to fail #16001

@DanielThomas

Description

@DanielThomas

Dependencies with pom packaging are included on the classpath and the boot jar process nor the loader considers the type of the file cause application startup to fail.

To reproduce take the following build:

plugins {
	id 'org.springframework.boot' version '2.1.3.RELEASE'
	id 'java'
}

repositories {
	mavenCentral()
}

dependencies {
	compile 'com.googlecode.matrix-toolkits-java:mtj:1.0.3'
}

bootJar {
	mainClassName = 'com.example.ExampleApplication'
}

Run bootJar and run java -jar build/libs/spring.jar and note the failure:

Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/all-1.1.2.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/all-1.1.2.pom'
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:256)
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:241)
	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 4270 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:123)
	at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:111)
	at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:289)
	at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:264)
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:252)
	... 6 more

POM files can be expected on configurations for either pom packaged dependencies like this, or for pom dependency management files for new native BOM support.

Gradle version:

------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------

Build time:   2019-01-10 23:05:02 UTC
Revision:     3c9abb645fb83932c44e8610642393ad62116807

Kotlin DSL:   1.1.1
Kotlin:       1.3.11
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_202 (Azul Systems, Inc. 25.202-b05)
OS:           Mac OS X 10.14.3 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions