Caused by:
java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
}
}
group 'batch'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
bootRun {
addResources = true
}
war {
baseName = 'Batch'
version = '0.1.0'
manifest {
attributes 'Main-Class': 'com.Application'
}
}
jar {
manifest {
attributes 'Main-Class': 'src.main.java.com.Application'
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.6.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.24'
compile group: 'org.json', name: 'json', version: '20180130'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.6.RELEASE'
compile group: 'javax.servlet', name: 'jstl', version: '1.2'
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '7.0.82'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '1.2.4.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.7.4.RELEASE'
compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.1'
}
Technologies used:
Gradle, Springboot,jdk7
Exception Trace:
tionConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh att
empt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/aut
oconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persist
ence unit root URL
2018-05-14 21:11:04.427 INFO 3136 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2018-05-14 21:11:04.505 INFO 3136 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report enable debug logging (start with --debug)
2018-05-14 21:11:04.552 ERROR 3136 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfi
gure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence u
nit root URL
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.3.2.RELEAS
E.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.2.RELEASE.j
ar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.2.RELEASE.jar
!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.R
ELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.2.RELEASE.ja
r!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEA
SE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
at com.Application.main(Application.java:15) [classes!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_171]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [Batch-0.1.0.war:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [Batch-0.1.0.war:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [Batch-0.1.0.war:na]
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [Batch-0.1.0.war:na]
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:603) ~[spring-orm
-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443) ~[spring-orm-4.3.2.RELE
ASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:424) ~[spring-orm-4.3.2.RELEASE.jar!/
:4.3.2.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:310) ~[spring-orm-4.3
.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.2.RELEASE.ja
r!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.REL
EASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.3.2.REL
EASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.3.2.RELEAS
E.jar!/:4.3.2.RELEASE]
... 24 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:600) ~[spring-orm
-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
... 31 common frames omitted
Solution:
Removed
compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.1'
Added a class like below
#Entity
public class TestEntity {
#Id
#GeneratedValue
private int id;
}
Related
This is my first question here, so please be kind...
I have a SpringBoot REST API running with gradle.
I recently added a new dependency in my build.gradle (implementation group: 'com.smsfactor', name: 'smsfactor', version: '1.0'), made some code, and when I tried to run the app, I had this error :
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi
Quite surprising because I didn't make any new use of the lombok library. First thing I did was adding a mapstruct dependency to my build.gradle. I also tried to define a version (1.18.20, same as on my Eclipse install) for my lombok dependency, which wasn't set before.
Both actions independently solved the issue, but created another one :
2021-04-29 12:36:51.104 ERROR 4971 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.schema.configuration.ModelsConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader#21213b92]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.8.RELEASE.jar:na]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:741) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:680) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:648) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1614) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:523) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:495) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.context#5.2.8.RELEASE/org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:100) ~[spring-context-5.2.8.RELEASE.jar:na]
at spring.context#5.2.8.RELEASE/org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) ~[spring-context-5.2.8.RELEASE.jar:na]
at spring.context#5.2.8.RELEASE/org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[spring-context-5.2.8.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.2.RELEASE.jar:na]
at com.feudjey.picsession.PicSessionApplication.main(PicSessionApplication.java:11) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[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:564) ~[na:na]
at spring.boot.devtools#2.4.5/org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.5.jar:na]
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3325) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2466) ~[na:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.8.RELEASE.jar:na]
... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.TypeResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 30 common frames omitted
2021-04-29 12:36:51.120 WARN 4971 --- [ restartedMain] o.s.boot.SpringApplication : Unable to close ApplicationContext
java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.schema.configuration.ModelsConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader#21213b92]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.8.RELEASE.jar:na]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:741) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:680) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:648) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1614) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:523) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:495) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:620) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.beans#5.2.8.RELEASE/org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:612) ~[spring-beans-5.2.8.RELEASE.jar:na]
at spring.context#5.2.8.RELEASE/org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1243) ~[spring-context-5.2.8.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:880) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:868) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:855) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:806) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.2.RELEASE.jar:na]
at spring.boot#2.3.2.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.2.RELEASE.jar:na]
at com.feudjey.picsession.PicSessionApplication.main(PicSessionApplication.java:11) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[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:564) ~[na:na]
at spring.boot.devtools#2.4.5/org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.5.jar:na]
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3325) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2466) ~[na:na]
at spring.core#5.2.8.RELEASE/org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.8.RELEASE.jar:na]
... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.TypeResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 30 common frames omitted
The thing is that I have "com.fasterxml:classmate:1.5.1" in my project when I run gradle dependencies. I found many threads about this dependency, but usualy users did not have included it in their project, which isn't my case.
The other weird thing is that when I stash my changes to go back to my last good build state, I encounter the same first error about lombok.
I started coding in java 4 years ago, I always find a solution to my issue in this community forums, but today I am totally lost, that's why I am writing my first thread.
Here is my build.gradle :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:'2.4.5'"
}
}
plugins {
id 'org.springframework.boot' version '2.3.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'eclipse'
id 'java'
id 'war'
}
bootWar {
archiveName 'rest-api.war'
}
group = 'com.feudjey'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
// Security
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.4.3'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.3.3.RELEASE'
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
// Swagger
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.3'
// File management
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'org.imgscalr', name: 'imgscalr-lib', version: '4.2'
implementation group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.14.0'
// Validation
implementation group: 'org.hibernate', name: 'hibernate-validator-annotation-processor', version: '7.0.1.Final'
implementation group: 'org.hibernate.validator', name: 'hibernate-validator', version: '7.0.1.Final'
implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
implementation group: 'javax.el', name: 'javax.el-api', version: '3.0.0'
implementation group: 'org.glassfish', name: 'javax.el', version: '3.0.0'
// Misc
implementation group: 'com.google.api-client', name: 'google-api-client', version: '1.30.10'
// Mapper
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.4.2'
// Faker
implementation group: 'com.github.javafaker', name: 'javafaker', version: '1.0.2'
// eMail
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.4.2'
// SMS
implementation group: 'com.smsfactor', name: 'smsfactor', version: '1.0'
// Paypal
implementation group: 'com.paypal.sdk', name: 'rest-api-sdk', version: '1.14.0'
// Persistance
implementation group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
// Database
runtimeOnly group: 'org.postgresql', name: 'postgresql', version: '42.2.20'
// Dev Tools
developmentOnly group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '2.4.5'
// Lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
// Tests
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
javac 11.0.10
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9)
OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)
Edit :
When I remove these two dependencies (and the code using them)
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation group: 'com.fasterxml.jackson.core:jackson-databind', version: '2.9.6'
I get get the following error :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field repository in com.feudjey.picsession.services.ServiceBase required a bean named 'entityManagerFactory' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
Does this make any sense ?
Here is my configuration class :
package com.feudjey.picsession.configuration;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.modelmapper.ModelMapper;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import com.feudjey.picsession.contracts.GlobalContract;
#Configuration
#EnableJpaAuditing(dateTimeProviderRef = "auditingDateTimeProvider")
#EnableJpaRepositories(basePackages = {GlobalContract.BASE_PACKAGE + ".repositories"})
#EntityScan(basePackages = {GlobalContract.BASE_PACKAGE + ".entities"})
#ComponentScan(basePackages = {
GlobalContract.BASE_PACKAGE + ".events",
GlobalContract.BASE_PACKAGE + ".services",
GlobalContract.BASE_PACKAGE + ".mappers",
GlobalContract.BASE_PACKAGE + ".fixtures"})
public class ApplicationConfig {
#Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
// #Bean
// public Docket api() {
// return new Docket(DocumentationType.SWAGGER_2)
// .select()
// .apis(RequestHandlerSelectors.basePackage(GlobalContract.BASE_PACKAGE + ".controllers"))
// .paths(PathSelectors.any())
// .build();
// }
#Bean
public DateTimeProvider auditingDateTimeProvider() {
return () -> Optional.of(OffsetDateTime.now());
}
#Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
final String origin = "*";
final String header = "*";
final String method = "*";
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin(origin);
config.addAllowedHeader(header);
config.addAllowedMethod(method);
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
#Bean
public ApplicationEventMulticaster applicationEventMulticaster() {
final SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
return eventMulticaster;
}
}
Edit 2 :
OK, I've just noticed that the project runs perfectly whith gradle bootrun, but doesn't with eclipse, so I have no debug mode.
I do a gradle cleaneclipse eclipse before every eclipse build, so what can it be ?
Please ask me if you want more details about my project. Hope someone can help me.
Thanks.
I created a simple Spring 5 application with spring-mvc. In one of my model objects I use bean validation (hibernate-validator). I added the following configuration to make it all work:
#Configuration
#ComponentScan(basePackages = "nl.myprod.springcrud")
public class AppConfig {
#Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
return new MethodValidationPostProcessor();
}
}
When launching my full application with Gretty, everything works as expected. But when I run the following test....
#RunWith(SpringRunner.class)
#WebAppConfiguration
#ContextConfiguration(classes = {WebConfig.class})
public class tmpTest {
#Test
public void tmp () {
}
}
... it gives me the following stacktrace:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [nl/myprod/springcrud/config/AppConfig.class]: Invocation of init method failed; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
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:204)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:228)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:129)
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:61)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 24 more
Caused by: javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:116)
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:47)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolator(ConfigurationImpl.java:474)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolatorConfiguredWithClassLoader(ConfigurationImpl.java:650)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getMessageInterpolator(ConfigurationImpl.java:397)
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:183)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:364)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
at org.springframework.validation.beanvalidation.MethodValidationInterceptor.<init>(MethodValidationInterceptor.java:68)
at org.springframework.validation.beanvalidation.MethodValidationPostProcessor.createMethodValidationAdvice(MethodValidationPostProcessor.java:125)
at org.springframework.validation.beanvalidation.MethodValidationPostProcessor.afterPropertiesSet(MethodValidationPostProcessor.java:113)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
... 39 more
Caused by: java.lang.NoClassDefFoundError: javax/el/ELManager
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:108)
... 52 more
Caused by: java.lang.ClassNotFoundException: javax.el.ELManager
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)
... 53 more
Now I know that I can fix it by adding the following dependency to my build.gradle:
compile group: 'org.glassfish', name: 'javax.el', version: '3.0.0'
And I can also fix this by not loading my ApplicationContext (comment out #ContextConfiguration(classes = {WebConfig.class}) in the test).
But I don't see why my code works fine when run with Gretty, but fails configuration in the tests. Can anyone explain to me why this is?
PS: This is my build.gradle:
plugins {
id 'java'
id 'org.gretty' version '2.3.1'
}
gretty {
httpPort=8081
}
group 'nl.myprod'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.4.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.7'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework', name: 'spring-test', version: '5.1.4.RELEASE'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.13.Final'
}
Looks like when you start Gretty at least in Tomcat mode it includes some implementation of those EL classes.
The following files have EL dependencies:
https://github.com/akhikhl/gretty/blob/master/libs/gretty-runner-tomcat8/build.gradle:
compile "org.apache.tomcat.embed:tomcat-embed-el:$tomcat8_version"
https://github.com/akhikhl/gretty/blob/master/libs/gretty-runner-tomcat7/build.gradle: compile "org.apache.tomcat.embed:tomcat-embed-el:$tomcat7_version"
Hello so i have a multi project set up that we have inherited and trying to dockerize. i am able to successfully run the application with spring boot cmd:
SPRING_PROFILES_ACTIVE=local ./gradlew :products:myapp:bootRun
However,when i do the following:
java -jar -Dspring.profiles.active=local myapp.jar
i am facing the error:
`Caused by: java.lang.ClassNotFoundException: javax.validation.bootstrap.ProviderSpecificBootstrap
at java.net.URLClassLoader$1.run(URLClassLoader.java:370) ~[na:1.8.0_91]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_91]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_91]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_91]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_91]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[myapp.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_91]
... 43 common frames omitted
Caused by: java.util.zip.ZipException: invalid code lengths set
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) ~[na:1.8.0_91]
at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52) ~[myapp.jar:na]
at sun.misc.Resource.getBytes(Resource.java:124) ~[na:1.8.0_91]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:462) ~[na:1.8.0_91]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_91]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_91]
... 49 common frames omitted
`My Application.java has
#Import({
EmbeddedServletContainerAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
HealthEndpointConfigImpl.class,
EndpointAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class
})
public class Application
{}
gradle file for this product:
apply plugin: 'java'
dependencies {
compile group: 'org.springframework', name: 'spring-context', version: rev_spring
compile group: 'org.springframework', name: 'spring-webmvc', version: rev_spring
compile group: 'org.springframework.boot', name: 'spring-boot-actuator', version: rev_spring_boot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: rev_spring_boot
testCompile group: 'junit', name: 'junit', version: rev_junit
testCompile group: 'org.mockito', name: 'mockito-all', version: rev_mockito
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: rev_hamcrest
testCompile group: 'org.springframework', name: 'spring-test', version: rev_spring
}
apply plugin: 'org.springframework.boot'
gradle file outside of this:
configure(subprojects.findAll { it.buildFile.exists() }) {
buildscript {
dependencies {
classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: rev_spring_boot
}
}
plugins.withId('java') {
processResources {
inputs.properties(['version': version])
doLast {
ant.propertyfile(file: new File("${sourceSets.main.output.resourcesDir}/config/application.properties")) {
entry key: 'spring.application.version', value: version
}
}
}
}
plugins.withId('org.springframework.boot') {
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('org.springframework.boot:spring-boot-starter-tomcat') with module("org.springframework.boot:spring-boot-starter-jetty:${rev_spring_boot}")
}
}
springBoot {
backupSource = false
layout = 'JAR'
}
bootRepackage {
withJarTask = jar
}
I am stuck at this point. tried to research the errors,but not of much help.
i am guessing the import EmbeddedServletContainerAutoConfiguration.class is the culprit,but wondering why when we run it as a spring boot,it's fine.
I am using Spring Integration SQS Outbound Channel Adapter to publish payload to SQS. I am running into some dependency issue. I am getting the exception:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.aws.outbound.SqsMessageHandler#0': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.aws.outbound.SqsMessageHandler]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate.<init>(Lcom/amazonaws/services/sqs/AmazonSQS;Lorg/springframework/cloud/aws/core/env/ResourceIdResolver;)V
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at com.expedia.dataloader.boot.Application.main(Application.java:15)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.aws.outbound.SqsMessageHandler]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate.<init>(Lcom/amazonaws/services/sqs/AmazonSQS;Lorg/springframework/cloud/aws/core/env/ResourceIdResolver;)V
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
... 17 more
Caused by: java.lang.NoSuchMethodError: org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate.<init>(Lcom/amazonaws/services/sqs/AmazonSQS;Lorg/springframework/cloud/aws/core/env/ResourceIdResolver;)V
at org.springframework.integration.aws.outbound.SqsMessageHandler.<init>(SqsMessageHandler.java:56)
at org.springframework.integration.aws.outbound.SqsMessageHandler.<init>(SqsMessageHandler.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessoava:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 19 more
Here are my Gradle dependencies:
dependencies {
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
compile 'org.springframework.cloud:spring-cloud-aws-context:1.2.2.RELEASE'
compile 'org.springframework.cloud:spring-cloud-aws-core:1.2.2.RELEASE'
compile ("org.springframework.cloud:spring-cloud-aws-messaging:1.2.2.RELEASE") {
exclude group:'com.amazonaws', module:'aws-java-sdk-sqs'
}
compile 'org.apache.commons:commons-lang3:3.+'
compile "org.springframework:spring-context:4.3.8.RELEASE"
compile "org.springframework:spring-webmvc:4.3.8.RELEASE"
compile "org.springframework:spring-aop:4.3.8.RELEASE"
compile "org.aspectj:aspectjweaver:1.8.2"
compile 'org.codehaus.castor:castor:1.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
compile 'org.springframework.integration:spring-integration-core:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-http:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-xml:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-amqp:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-stream:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-file:4.3.8.RELEASE'
compile 'org.springframework.integration:spring-integration-java-dsl:1.0.0.RELEASE'
compile group: 'org.springframework.integration', name: 'spring-integration-aws', version: '1.0.0.RELEASE'
compile 'org.projectlombok:lombok:1.14.8'
compile 'joda-time:joda-time:2.+'
compile("org.springframework.boot:spring-boot-starter-web") {
exclude group: 'org.hibernate'
exclude group: 'org.springframework'
exclude group: 'com.fasterxml.jackson.core'
exclude group: 'org.mockito'
exclude group: 'junit'
}
compile "ch.qos.logback:logback-classic:1.1.2"
compile "org.slf4j:jcl-over-slf4j:1.7.7"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile 'org.apache.httpcomponents:httpclient:4.3.6'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
testCompile 'junit:junit:4.+'
testCompile 'org.springframework:spring-test:4.3.8.RELEASE'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'org.apache.commons:commons-io:1.3.2'
jaxb group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.2.6'
jaxb group: 'com.sun.xml.bind', name: 'jaxb-xjc', version: '2.2.6'
jaxb group: 'javax.xml', name: 'jaxb-api', version: '2.1.5'
}
Here is my SQS config:
<aws-messaging:sqs-async-client id="sqs"/>
<int-aws:sqs-outbound-channel-adapter channel="sqsChannel" sqs="sqs" queue="${sqs.queue}"/>
I have tried all suggestions that I found on Internet, still no luck. Can someone please help?
According to Artem Bilan, modify the following:
SI AWS to 1.1.0
SC-AWS to 1.2.2
SC-AWS fetches AWS SDK version 1.11.125. I had to override AWS SQS SDK version to be 1.11.209 as mentioned here to fix the dependencies issues.
I'm trying to wire in Hibernate Envers into my Spring Boot app, and I get this exception:
I've tried a lot of different dependencies for Envers, because this seems like dependency conflict issue, but nothing helped.
When I start the app, everything is ok, but when I try to annotate class with #Audited this exception drops.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/spi/SharedSessionContractImplementor
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.base.BaseApplication.main(BaseApplication.java:11) [main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.0.RELEASE.jar:1.3.0.RELEASE]
Caused by: java.lang.NoClassDefFoundError: org/hibernate/engine/spi/SharedSessionContractImplementor
at org.hibernate.envers.boot.internal.EnversIntegrator.integrate(EnversIntegrator.java:94) ~[hibernate-envers-5.2.8.Final.jar:5.2.8.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:280) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.spi.SharedSessionContractImplementor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
... 31 common frames omitted
My application.properties
spring.profiles.active = dev
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# ===============================
# = JPA / HIBERNATE
# ===============================
spring.jpa.show-sql = true
logging.level.org.hibernate.type.descriptor.sql=trace
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
spring.jpa.database-platform = org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect
spring.datasource.url = jdbc:mysql://localhost:3306/database
# Username and secret
spring.datasource.username = root
spring.datasource.password = root
server.port=8082
Gradle build file:
plugins {
id 'org.springframework.boot' version '1.5.2.RELEASE'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
jar {
baseName = 'Base'
version = '0.0.1-SNAPSHOT'
}
bootRun {
systemProperties = System.properties
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version:'1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '1.3.0.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.40'
compile group: 'org.modelmapper', name: 'modelmapper', version:'0.7.5'
compile group: 'com.vividsolutions', name: 'jts', version:'1.13'
compile group: 'com.bedatadriven', name: 'jackson-datatype-jts', version:'2.3'
compile group: 'org.hibernate', name: 'hibernate-spatial', version:'5.0.11.Final'
compile group: 'org.flywaydb', name: 'flyway-core', version:'3.2.1'
compile group: 'org.apache.commons', name: 'commons-email', version: '1.4'
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.5.6'
compile group: 'io.springfox', name: 'springfox-swagger2', version:'2.4.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version:'2.4.0'
compile group: 'org.hibernate', name: 'hibernate-envers'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'1.4.2.RELEASE'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.6'
}
I had the same problem, I solved adding the hibernate-core dependency, this dependency has the missing class (SharedSessionContractImplementor), so you can add it to your gradle file.
I used the hibernate-core 5.0.11.final for spring-boot 1.4.2.RELEASE
Gradle:
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.0.11.Final'
In my case the solution is to use spring-data-envers instead of the original hibernate-envers
implementation 'org.springframework.data:spring-data-envers'