C:\Users\sinpik\Desktop\jar\extract>java -jar PackageProject-client.jar
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at PachName.Application.main(Application.java:14)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:168)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:134)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
I have created a sample application in Spring Boot and it is running properly in IDE. I want to package it as a fat JAR and run it through command prompt. How do I do it? I am running it using java -jar JarName.jar.
This is my build script:
buildscript {
ext {
springBootVersion = '1.1.9.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'eu.appsatori.fatjar'
jar {
baseName = 'demo'
version = '0.0.1-SNAPSHOT'
}
fatJar{
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
// 'Implementation-Version': version,
'Main-Class': 'PachName.Application'
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
}
}
fatJarPrepareFiles {
include 'application.properties'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
Related
The spring boot app is running and working fine in local dev area. When I deploy to test environment and try to start the app, I am getting below error. I generated jar file by using gradlew.bat
Any insight on this error? Thanks in advance.
Error:
2021-03-29 23:15:14,283 INFO Version[21] HV000001: Hibernate Validator 6.1.7.Final
2021-03-29 23:15:35,502 WARN AnnotationConfigServletWebServerApplicationContext[590] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.org.SpringBootApplication]; nested exception is java.net.ConnectException: Connection timed out: connect
2021-03-29 23:15:35,564 ERROR SpringApplication[856] Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.org.SpringBootApplication]; nested exception is java.net.ConnectException: Connection timed out: connect
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:330)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:246)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:745)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:563)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
at com.org.SpringBootApplication.main(SpringBootApplication.java:13)
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:107)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.base/java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.base/java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.base/java.net.PlainSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at java.base/sun.net.ftp.impl.FtpClient.doConnect(Unknown Source)
at java.base/sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source)
at java.base/sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at java.base/sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at java.base/sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at java.base/sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:186)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:110)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:81)
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:67)
at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:67)
at org.springframework.core.io.support.DefaultPropertySourceFactory.createPropertySource(DefaultPropertySourceFactory.java:37)
at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:463)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:280)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:304)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175)
... 22 common frames omitted
Here is build.gradle file:
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
group = 'abc'
version = '1.0.0'
sourceCompatibility = 10
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://repo1.maven.org/maven2/' }
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: spring_boot_starter_validation_version
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: apache_commons_lang_version
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
compile 'commons-validator:commons-validator:1.4.1'
}
test {
outputs.dir snippetsDir
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
========================================================================================
Error shows that you are having some FTP server related configurations, and those configurations are not working on your test server (or FTP server is not reachable from your test server). Check those configurations, and it will be fine.
i have the following simple test-project-structure
|TestProject
|
|---project-a
| |---src
| |---main
| |---java
| |---package-name.ProjectA
| |---service
| | |---TestService.java
| |
| |---ProjectAServiceApplication.java
|
|---project-b
| |---src
| |---main
| |---java
| |---package-name.ProjectB
| |---enums
| |---Commodity.java
|
|---build.gradle
|---settings.gradle
The build.gradle looks like
import com.commercehub.gradle.plugin.avro.GenerateAvroJavaTask
import groovy.json.*
buildscript {
ext {
springCloudVersion = 'Greenwich.RELEASE'
springBootVersion = '2.1.2.RELEASE'
}
repositories {
mavenCentral()
jcenter()
maven {
url "http://packages.confluent.io/maven"
}
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://projectlombok.org/edge-releases' }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "com.commercehub.gradle.plugin:gradle-avro-plugin:0.14.2"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
}
}
plugins {
id "net.ltgt.apt" version "0.21" apply false
id "io.spring.dependency-management" version "1.0.8.RELEASE"
}
subprojects {
// Packer variables
ext {
packerVariablesFolder = "$buildDir/packer"
packerVariablesPath = "$packerVariablesFolder/$packerVariables"
packerTemplateFolder = "../config"
packerTemplatePath = "$packerTemplateFolder/$packerTemplate"
}
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
group = 'de.SWS.PLM'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
jcenter()
maven {
url "http://packages.confluent.io/maven"
}
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://projectlombok.org/edge-releases' }
}
springBoot {
buildInfo()
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
ext.convertProjectName = { ->
return project.name.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])").join("-").toLowerCase()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile 'org.apache.commons:commons-lang3:3.10'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
task defineBuildVersion {
if (project.hasProperty("revision")) {
ext.imageVersion = version + "-${revision}"
} else {
ext.imageVersion = version + "-SNAPSHOT"
}
}
compileJava {
//raise heap
options.fork = 'true'
options.forkOptions.with {
memoryMaximumSize = '2048m'
}
}
task generatePackerFiles {
doLast {
mkdir "$packerVariablesFolder"
new File("$packerVariablesPath").text = JsonOutput.toJson([
jar_file: jar.archiveName,
logback_file: "logback-pfm.xml",
image_name: "$convertProjectName",
image_tag: "${defineBuildVersion.imageVersion}"
])
}
}
task buildDockerImage(type: Exec) {
dependsOn generatePackerFiles
commandLine 'packer', 'build', "-var-file=${packerVariablesPath}", "${packerTemplatePath}"
}
compileJava {
//raise heap
options.fork = 'true'
options.forkOptions.with {
memoryMaximumSize = '2048m'
}
}
task cleanIntellijDirs(type: Delete) {
delete 'out'
}
}
configure(subprojects.findAll { !['project-b'].contains(it.name)} ) {
dependencies {
implementation project(':project-b')
}
}
and the settings.gradle looks like
rootProject.name = 'TestProject'
include 'project-a'
include 'project-b'
If i run the gradlew task build for project-a gradle :project-a:build it builds the project correctly and generate a *.jar file.
If i execute the *.jar file i get the following output
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testService' defined in URL [jar:file:/C:/Users/sws-216/Documents/Projekte/pfm-project/TestProject/project-a/build/libs/project-a-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/de/SWS/PLM/ProjectA/service/TestService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.SWS.PLM.ProjectA.service.TestService]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: de/SWS/PLM/Commodity
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1270) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1164) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
at de.SWS.PLM.ProjectA.ProjectAServiceApplication.main(ProjectAServiceApplication.java:10) ~[classes!/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[project-a-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[project-a-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[project-a-0.0.1-SNAPSHOT.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[project-a-0.0.1-SNAPSHOT.jar:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.SWS.PLM.ProjectA.service.TestService]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: de/SWS/PLM/Commodity
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1262) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
... 24 common frames omitted
Caused by: java.lang.NoClassDefFoundError: de/SWS/PLM/Commodity
at de.SWS.PLM.ProjectA.service.TestService.<init>(TestService.java:12) ~[classes!/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: de.SWS.PLM.Commodity
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[na:na]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[project-a-0.0.1-SNAPSHOT.jar:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 32 common frames omitted
What i do wrong setting up the gradle multi modules project?
The issue is in the way you are packaging project-b. You are relying on it as both a library (because you are depending on it from project-a) and as a stand-alone executable jar. But you can't use the same jar file for both these use-cases.
When you apply the Spring Boot plugin, it will by default disable the normal jar task and instead produce a "fat" jar with all dependencies bundled up, but also arranged in a way that a normal Java program can no longer find classes in it. To re-enable the original jar task, and rename the fat jar as it has the same name, do this:
jar {
enabled = true
}
bootJar {
classifier = 'boot'
}
When you do this, you will get two jar files on build. One is for when you use it as a normal dependency, and the other is for executing it.
I assume the reason it works in IntelliJ without this is because you are either not delegating your tasks to Gradle, or you are running it through bootRun. Both approaches will not build and run the final executable jar, but rather just use the compiled classes in an exploded form.
Sometimes, a better design is to extract the classes which are common to both project-a and project-b into a shared utility project instead of bundling an entire application inside another application (and sometimes this is what you want of cause). But you will need to do the same configuration for this as the above if you apply the Spring Boot plugin on it, which you might do for the reaction to the dependency-management plugin.
You can find more information on this in the documentation for the documentation for the Spring Boot Gradle plugin under Packaging Executable and Normal Archives.
Ok, i do the following
add
jar {
enabled = true
}
bootJar {
classifier = 'boot'
}
to my project-a. Then build it and received two *.jars. I Included the boot.jar one into my dockerfile and deployed it. Unfortunately i get the same error
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
22-07-2020 08:05:01.610 ERROR org.springframework.boot.SpringApplication.reportFailure - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'priceService': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [de.SWS.PLM.PriceParseService.services.PriceService] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#7225790e]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1236)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1151)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at de.SWS.PLM.PriceParseService.PriceParseServiceApplication.main(PriceParseServiceApplication.java:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [de.SWS.PLM.PriceParseService.services.PriceService] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#7225790e]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:686)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:583)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:568)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248)
... 26 common frames omitted
Caused by: java.lang.NoClassDefFoundError: de/SWS/PLM/utils/ExcelCellTypeError
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:668)
... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: de.SWS.PLM.utils.ExcelCellTypeError
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 33 common frames omitted
If i check the structure of the boot.jar it looks like
BOOT-INF
|
|---classes
| |---package.name
| |---project-a
| |---all the classes without the classes of project-b
|---lib
META-INF
org
So in both jars there are not the classes of project-b so project-a can not find the classes i think
build.gradle
buildscript {
repositories {
mavenLocal()
maven { url "https://artifactory.company.net:443/artifactory/libs-snapshot" }
maven { url "https://artifactory.company.net/artifactory/libs-release" }
jcenter()
maven { url "http://repo.spring.io/plugins-release" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE")
classpath "io.spring.gradle:propdeps-plugin:0.0.10.RELEASE"
classpath "org.openapitools:openapi-generator-gradle-plugin:3.2.0"
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.5.2"
}
}
I get exception when I try to apply this plugin. I tried with the latest Gradle 4.10.2 and old version 4.2.1, with multiple versions of this plugin.
apply plugin: 'org.openapi.generator'
Exception
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.openapi.generator']
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:120)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:38)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:86)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:143)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at build_cf4aqu9jl2xl73vdxs56nz55v.run(/Users/trpge09/Develop/jHipster/makara-microservice-template/build.gradle:115)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
... 97 more
Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class org.openapitools.generator.gradle.plugin.extensions.OpenApiGeneratorMetaExtension.
at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:223)
at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:79)
at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
at org.gradle.api.internal.plugins.DefaultConvention.instantiate(DefaultConvention.java:236)
at org.gradle.api.internal.plugins.DefaultConvention.create(DefaultConvention.java:138)
at org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin.apply(OpenApiGeneratorPlugin.kt:39)
at org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin.apply(OpenApiGeneratorPlugin.kt:36)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:42)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:50)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
... 110 more
Caused by: java.lang.NoClassDefFoundError: org/gradle/api/provider/Property
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:72)
at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:56)
at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:36)
at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:283)
at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:238)
at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:110)
... 126 more
Caused by: java.lang.ClassNotFoundException: org.gradle.api.provider.Property
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 135 more
A simple executable jar generated using the following gradle script is giving ClassNotFoundException
group 'com.acme'
version '1.0-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'acme-project1'
version = '0.1.0'
}
jar {
manifest {
attributes 'Main-Class': 'com.acme.ApplicationLoader'
attributes 'Spring-Boot-Classes': 'BOOT-INF/classes/'
attributes 'Spring-Boot-Lib': 'BOOT-INF/lib/'
}
}
repositories {
mavenCentral()
mavenLocal()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
queryDslVersion = '4.1.4'
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-jpa"){
exclude group: "org.hibernate", module: "hibernate-entitymanager"
}
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile "com.querydsl:querydsl-root:$queryDslVersion"
compile "com.querydsl:querydsl-jpa:$queryDslVersion"
compile "com.querydsl:querydsl-apt:$queryDslVersion:jpa"
compile("com.a:acme-persistence:1.0-SNAPSHOT")
testCompile("junit:junit")
}
Note: All the DAO layer code is packaged in a separate jar acme-persistence, which is added as compile() dependency
Note2: I have another project, which also relies on acme-persistence, which is build using maven and is working fine. After unjaring and comparing the packages, everything was similar except the META-INF/MANIFEST.MF file. In the working jar there were these lines:
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
which were missing from the gradle-built jar. So I added those to the gradle project and verified after unjaring that those lines are present. However, am still getting the same error!
The error:
java.lang.NoClassDefFoundError: org/springframework/data/querydsl/QueryDslPredicateExecutor
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[acme-project1-0.1.0.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[acme-project1-0.1.0.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:274) ~[spring-core-5.0.5.RELEASE.jar!/:5.0.5.RELEASE]
at org.springframework.data.repository.config.RepositoryBeanNameGenerator.getRepositoryInterfaceFrom(RepositoryBeanNameGenerator.java:90) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryBeanNameGenerator.generateBeanName(RepositoryBeanNameGenerator.java:54) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.generateBeanName(RepositoryConfigurationSourceSupport.java:98) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:134) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
The problem was spring-data-jpa-1.12.2 had class QueryDslPredicateExecutor, while it was renamed to QuerydslPredicateExecutor in spring-data-jpa-2.6.0.
Notice the small s vs capital S!
When I am trying to start Gretty using gradle appRun and Gradle 2.9 I get the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/json/JsonSlurper
at org.akhikhl.gretty.Runner.run(Runner.groovy:114)
at org.akhikhl.gretty.Runner.this$2$run(Runner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.akhikhl.gretty.Runner.main(Runner.groovy:46)
Caused by: java.lang.ClassNotFoundException: groovy.json.JsonSlurper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
Exception in thread "Thread-3" org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
at org.gradle.api.internal.file.DefaultFileOperations.javaexec(DefaultFileOperations.java:159)
at org.gradle.api.internal.project.AbstractProject.javaexec(AbstractProject.java:792)
at org.gradle.api.internal.project.AbstractProject.javaexec(AbstractProject.java:788)
at org.gradle.api.Project$javaexec$10.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.akhikhl.gretty.DefaultLauncher.javaExec(DefaultLauncher.groovy:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy:240)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:420)
at groovy.lang.Closure.run(Closure.java:507)
at java.lang.Thread.run(Thread.java:745)
My application does not require groovy-json at all and I suspect it's required by the Gretty Gradle plugin but I cannot find the problem. Here is what I tried yet:
Applied gretty.plugin from a local location and add groovy-json as a classpath dependency of the buildscript.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.2.4'
classpath "org.codehaus.groovy:groovy-json:${groovyVersion}"
}
}
repositories {
jcenter()
}
dependencies {
// does not affect the situation either
runtime "org.codehaus.groovy:groovy-json:${groovyVersion}"
}
if (!project.plugins.findPlugin(org.akhikhl.gretty.GrettyPlugin))
project.apply(plugin: org.akhikhl.gretty.GrettyPlugin)
It doesn't change whether I use Jetty 9 or Tomcat 8. It always results in the same error.
I have found the reason for this behaviour.
In my buildscript I make sure that groovy-all never gets used and is replaced by groovy module (see below).
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
//changing 'groovy-all' into 'groovy':
if (details.requested.name == 'groovy-all') {
details.useTarget group: details.requested.group, name: 'groovy', version: groovyVersion
}
}
}
So that's the reason why the error occurs. But can anyone tell me why I does not get fixed when I add groovy-json as runtime dependency?
I ran into the same problem. Didn't solve it completely yet, but this seems to help:
https://github.com/akhikhl/gretty/issues/5
https://github.com/akhikhl/gretty/issues/72
What the say essentially is that deps for grettyplugin itself must be added with the keyword gretty (not compile nor runtime)
compile group: 'org.apache.poi', name: 'ooxml-schemas', version: '1.3'
runtime group: 'org.postgresql', name: 'postgresql', version: '9.4.1209.jre7'
gretty 'com.atomikos:transactions-jta:4.0.4'
Hope this helps someone else (took me quite a while to figure it out).