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).
Related
I am getting the following error while running my feature test.
io.cucumber.core.exception.CucumberException: Failed to instantiate class ab.cd.ef.featuresteps
at io.cucumber.core.backend.DefaultObjectFactory.cacheNewInstance(DefaultObjectFactory.java:67)
at io.cucumber.core.backend.DefaultObjectFactory.getInstance(DefaultObjectFactory.java:45)
at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:85)
at io.cucumber.core.runner.TestStep.run(TestStep.java:57)
at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
at io.cucumber.core.runner.TestCase.run(TestCase.java:84)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
at io.cucumber.core.runtime.Runtime.lambda$executePickle$6(Runtime.java:128)
at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:129)
at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:129)
at io.cucumber.core.runtime.Runtime.lambda$executePickle$7(Runtime.java:128)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:249)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.cucumber.core.runtime.Runtime.lambda$runFeatures$3(Runtime.java:110)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at io.cucumber.core.runtime.Runtime.runFeatures(Runtime.java:111)
at io.cucumber.core.runtime.Runtime.lambda$run$0(Runtime.java:82)
at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:80)
at io.cucumber.core.cli.Main.run(Main.java:87)
at io.cucumber.core.cli.Main.main(Main.java:30)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at io.cucumber.core.backend.DefaultObjectFactory.cacheNewInstance(DefaultObjectFactory.java:53)
... 37 more
Caused by: java.lang.NoClassDefFoundError: <path>/CommonQueueService
at uk.gov.di.ipvspot.integrationtests.Slice3FeatureSteps.<init>(Slice3FeatureSteps.java:30)
... 42 more
Caused by: java.lang.ClassNotFoundException: <path>.service.CommonQueueService
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 43 more
The error is also pointing to a build.gradle line javaexec { (see below)
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec {
mainClass = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', 'ab.cd.ef.featuresteps', 'src/test/features']
}
}
I am using gradle 7.4.2
Does anyone know how to resolve this please? I have couple of gradle versions installed so not sure if it is due to cache-ing. I tried to delete it but couldnt.
Have you set this on your project?
System.setProperty("webdriver.chrome.driver", "/Users/path/to/chromedriver");
Because I had the same issue and realized that this line with the path to chromedriver was missed on my project.
I'm using following simple build.gradle project template:
buildscript {
repositories {
maven {
url repoUrlPublic
}
}
dependencies {
classpath "org.gretty:gretty:3.0.2"
}
}
apply plugin: "org.gretty"
apply plugin: 'war'
description = "Servlet Template"
group = "com.grp"
version = "0.0.1"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
repoUrlPublic = "http://..."
//gradlew run
ext {
javaMainClass = "com.pckg.TemplateJAR"
}
war {
baseName 'template'
}
gretty {
debugPort = 5005 // default
debugSuspend = true // default
httpPort = 8585
servletContainer = 'jetty9.3'
}
repositories {
// project nexus server repository
maven {
url repoUrlPublic
}
}
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'ch.qos.logback:logback-classic:1.2.3'
implementation 'ch.qos.logback:logback-core:1.2.3'
compileOnly 'javax.servlet:javax.servlet-api:3.0.1'
}
and with the version specified it produce following issue:
gradlew appRunDebug Picked up JAVA_TOOL_OPTIONS: -Duser.language=en
Listening for transport dt_socket at address: 5005 10:45:40.594 [main]
DEBUG org.akhikhl.gretty.ServiceProtocol - ServiceProtocol.send(61607,
init 61611) Exception in thread "main" java.net.ConnectException:
Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.(Socket.java:434)
at java.net.Socket.(Socket.java:244)
at org.akhikhl.gretty.ServiceProtocol$Writer.write(ServiceProtocol.groovy:76)
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:498)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:179)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:70)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at org.akhikhl.gretty.Runner.run(Runner.groovy:118)
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:498)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:190)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:70)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at org.akhikhl.gretty.Runner.main(Runner.groovy:53) Picked up JAVA_TOOL_OPTIONS: -Duser.language=en Exception in thread "Thread-65"
org.gradle.process.internal.ExecException: Process 'command
'C:\Java\jdk1.8.0_191\bin\java.exe'' finished with non-zero exit value
1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:396)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:38)
at org.gradle.process.internal.DefaultExecActionFactory.javaexec(DefaultExecActionFactory.java:129)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1105)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1100)
at org.gradle.api.Project$javaexec$6.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at org.akhikhl.gretty.DefaultLauncher.javaExec(DefaultLauncher.groovy:100)
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:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:168)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure5.doCall(LauncherBase.groovy:208)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure5.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:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:411)
at groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.run(Closure.java:492)
at java.lang.Thread.run(Thread.java:748)
When the gretty plugin version 3.0.1 is set, script works without issue. Any idea why the script is not back compatible?
I was getting:
java.net.ConnectException: Connection refused: connect
at org.akhikhl.gretty.ServiceProtocol$Writer.write(ServiceProtocol.groovy:76)
...
when running from IntelliJ IDEA. Then I ran it from the 'Terminal' in IDEA, and it worked. Then I ran it from IDEA again ... and it worked :-\
Not stopping to ask why ... I can only speculate that Gretty is trying to write some file, which it isn't allowed to, when it runs under IDEA (maybe files related to SSL certs), but once these files are written, it is able to read them just fine ... although an argument against this is the 'blocking' nature of the problem ... a 'security exception' would be more apt.
i use grails version 3.3.4 and i want to migrate to new version of grails 4.0.1 and i'm having some issues with liquibase.
i made some changes in build.gradle i changed some versions
dependencies {
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.0.10"
classpath "org.grails.plugins:database-migration:3.0.4"
}
dependencies {
compile 'org.grails.plugins:database-migration:3.0.4'
compile ("org.liquibase:liquibase-core:3.6.3") {
exclude group: 'org.springframework'
}
}
have the exception:
ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoClassDefFoundError: org/springframework/boot/liquibase/CommonsLoggingLiquibaseLogger
at org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin.configureLiquibase(DatabaseMigrationGrailsPlugin.groovy:97)
at org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin.doWithSpring(DatabaseMigrationGrailsPlugin.groovy:50)
at org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:539)
at org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:166)
at grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:125)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at grails.boot.GrailsApp.run(GrailsApp.groovy:97)
at grails.boot.GrailsApp.run(GrailsApp.groovy:458)
at grails.boot.GrailsApp.run(GrailsApp.groovy:445)
at ogrh4.Application.main(Application.groovy:11)
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:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 common frames omitted
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!