Eclipselink / Spring boot with Gradle. Getting ClassNotFoundException for QueryDslPredicateExecutor - spring

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!

Related

gretty throws org.gradle.process.internal.ExecException: Process command {} finished with non-zero exit value 1

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.

Failed to apply plugin [id 'org.openapi.generator']

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

Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

After adding 2 dependencies shown below to my application everything works fine my session data is written to my local redis server, but when i try to specify different address of redis server i got an error. I assume that error is connected with some dependencies problem, but i dont know how to tackle this issue.
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"
Error during startup
java.lang.IllegalStateException: Error processing condition on
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
at
org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61)
~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
pl.bk.pizza.store.Initializer.main(Initializer.java:11) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class
[org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration]
from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2] at
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:569)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:724)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:665)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:633)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:164)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:203)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:254)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] ... 17
common frames omitted Caused by: java.lang.NoClassDefFoundError:
javax/servlet/Filter at java.lang.ClassLoader.defineClass1(Native
Method) ~[na:1.8.0-internal] at
java.lang.ClassLoader.defineClass(ClassLoader.java:763)
~[na:1.8.0-internal] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
~[na:1.8.0-internal] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
~[na:1.8.0-internal] at
java.net.URLClassLoader.access$100(URLClassLoader.java:73)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:368)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:362)
~[na:1.8.0-internal] at
java.security.AccessController.doPrivileged(Native Method)
~[na:1.8.0-internal] at
java.net.URLClassLoader.findClass(URLClassLoader.java:361)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass1(Native
Method) ~[na:1.8.0-internal] at
java.lang.ClassLoader.defineClass(ClassLoader.java:763)
~[na:1.8.0-internal] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
~[na:1.8.0-internal] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
~[na:1.8.0-internal] at
java.net.URLClassLoader.access$100(URLClassLoader.java:73)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:368)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:362)
~[na:1.8.0-internal] at
java.security.AccessController.doPrivileged(Native Method)
~[na:1.8.0-internal] at
java.net.URLClassLoader.findClass(URLClassLoader.java:361)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods0(Native
Method) ~[na:1.8.0-internal] at
java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
~[na:1.8.0-internal] at
java.lang.Class.getDeclaredMethods(Class.java:1975)
~[na:1.8.0-internal] at
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 35 common frames
omitted Caused by: java.lang.ClassNotFoundException:
javax.servlet.Filter at
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] ... 63 common frames omitted
RedisConfig
#Configuration
#EnableRedisHttpSession
public class RedisConfig
{
#Bean
LettuceConnectionFactory jedisConnectionFactory()
{
final RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setHostName("redis-19999.c14.us-east-1-2.ec2.cloud.redislabs.com");
config.setPort(19999);
config.setPassword(RedisPassword.of("***"));
return new LettuceConnectionFactory();
}
}
build.gradle file
buildscript {
ext.springVersion = '2.0.2.RELEASE'
ext.gradleDocker = '1.2'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "se.transmode.gradle:gradle-docker:$gradleDocker"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springVersion"
}
}
plugins {
id "org.sonarqube" version "2.6.2"
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
apply plugin: 'jacoco'
dependencies {
// spring
compile "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-security:${springVersion}"
testCompile "org.springframework.security:spring-security-test:${springSecurityTest}"
testCompile "org.springframework.boot:spring-boot-starter-test:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"
// utils
testCompile "org.assertj:assertj-core:${assertJ}"
compile "com.google.guava:guava:${guava}"
compile "io.projectreactor:reactor-core:${reactor}"
compile "io.reactivex.rxjava2:rxjava:${rxjava}"
compile "commons-lang:commons-lang:${commonsLang}"
compile "commons-validator:commons-validator:${commonsLangValidator}"
compileOnly "org.projectlombok:lombok:${lombok}"
// embedded mongo for tests
testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${embeddedMongo}"
// spock
compile "org.codehaus.groovy:groovy-all:${groovy}"
testCompile "org.spockframework:spock-core:${spockCore}"
testCompile "org.spockframework:spock-spring:${spockSpring}"
}
There are several thing going on here.
The log you've supplied indicates javax.servlet.Filter is missing from the classpath while your build script and dependencies suggest your building a Spring WebFlux app. I suspect this is due to you explicitly configuring Spring Session's Servlet support using #EnableRedisHttpSession (notice HttpSession in there?) rather than #EnableRedisWebSession. Even better, you should leave Spring Session configuration to Spring Boot to auto-configure it - see Spring Session dedicated section of Spring Boot's reference manual.
The same advice (avoid explicit config, rely on auto-config) applies to your Redis configuration i.e. no need for that explicit LettuceConnectionFactory bean.
Furthermore, with Spring Boot, it's highly recommended to use its dependency management, rather then providing the versions of your dependency explicitly, at least for the dependencies that are covered by Spring Boot's dependency management. Refer to dependency management and dependency versions appendix sections of Boot's reference manual. On top of that, you should also strongly consider using Boot's starters to make sure all the required dependencies are pulled in - see starters dedicated section.
This same error message presents if you create an application via spring initializr , specify Session as a dependency, create a #RestController and then use #EnableSpringHttpSession.
Without using #EnableSpringHttpSession, the application will start and exit, with no stack trace. This gives the appearance that perhaps there is something wrong with the HttpSession configuration.
The actual cause of the error condition is due to not having included Web as an application dependency (or implementation('org.springframework.boot:spring-boot-starter-web' in build.gradle)
For me ,Everything is perfect but it still throws the exception-Propertyplaceholderautoconfiguration
I just tried maven reload and project reload ,still it throws this error and shows some red lines on dependency Class which is I used to import and used it in my project files
Just closed IntelliJ and opened the project again,Then Everything works fine.
Thumbs up,If it is useful to you

NoClassDefFoundError when starting Gretty in Gradle build

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).

Running Spring boot fat JAR

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'
}

Resources