Skip to content

developmentOnly configuration excludes jar files from fat jar #21288

Closed
@kdankert

Description

@kdankert

The docker image that is built with the default buildpack (paketo) in Springboot version 2.3.0-RC1 throws an error because the dependencies inside the container cannot be found. In 2.3.0-M4 this wasn't the case with the cloudfoundry buildpack.

Log of the docker container

Container memory limit unset. Configuring JVM for 1G container.
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=111994K -XX:ReservedCodeCacheSize=240M -Xss1M -Xmx424581K (Head Room: 0%, Loaded Class Count: 17359, Thread Count: 250, Total Memory: 1073741824)
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
	at com.xerocs.comicro.chatservice.ChatServiceApplication.main(ChatServiceApplication.java:10)
	... 8 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:113)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 9 more

Gradle Project File

plugins {
	id 'org.springframework.boot' version '2.3.0.RC1'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
}

group = <groupId>
version = 'latest'
sourceCompatibility = '11'

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
	mavenCentral()
	maven { url 'https://repo.spring.io/milestone' }
}

bootBuildImage {
	imageName = <imageName>
}

dependencies {
	implementation platform("org.keycloak.bom:keycloak-adapter-bom:10.0.0")
	implementation "org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.2.6.RELEASE"
	implementation "com.c4-soft.springaddons:spring-security-oauth2-test-webmvc-addons:2.0.3"
	implementation 'org.keycloak:keycloak-spring-boot-starter'

	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	implementation 'org.springframework.boot:spring-boot-starter-cache'
	implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	implementation 'org.springframework.boot:spring-boot-starter-web'

	compileOnly 'org.projectlombok:lombok'

	developmentOnly 'org.springframework.boot:spring-boot-devtools'

	annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
	annotationProcessor 'org.projectlombok:lombok'

	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
	testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo'
	testImplementation 'org.springframework.security:spring-security-test'
}

test {
	useJUnitPlatform()
}

Metadata

Metadata

Assignees

Labels

type: blockerAn issue that is blocking us from releasingtype: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions