IntelliJ with spring-boot-jetty-jsp - java

I'm trying to run the spring-boot-jetty-jsp sample. It works from the command line using mvn jetty:run but when I try it in IntelliJ I get this error:
2016-07-16 02:54:25.150 INFO 19012 --- [ main] s.jetty.jsp.SampleJettyJspApplication : Starting SampleJettyJspApplication on dac-Latitude-E7450 with PID 19012 (/home/dac/proj/spring-boot-master/spring-boot-samples/spring-boot-sample-jetty-jsp/target/classes started by dac in /home/dac/proj/spring-boot-master/spring-boot-samples/spring-boot-sample-jetty-jsp)
2016-07-16 02:54:25.153 INFO 19012 --- [ main] s.jetty.jsp.SampleJettyJspApplication : No active profile set, falling back to default profiles: default
2016-07-16 02:54:25.252 INFO 19012 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3ad83a66: startup date [Sat Jul 16 02:54:25 CEST 2016]; root of context hierarchy
2016-07-16 02:54:25.402 WARN 19012 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jetty.jsp.SampleJettyJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
2016-07-16 02:54:25.426 ERROR 19012 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jetty.jsp.SampleJettyJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.BUILD-SNAPSHOT.jar:1.4.0.BUILD-SNAPSHOT]
at sample.jetty.jsp.SampleJettyJspApplication.main(SampleJettyJspApplication.java:33) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:301) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) ~[spring-context-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_91]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_91]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_91]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.2.BUILD-20160715.204924-12.jar:4.3.2.BUILD-SNAPSHOT]
... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_91]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_91]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_91]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_91]
... 20 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:36461', transport: 'socket'
Process finished with exit code 1
It is possible to create a maven configuration in IntelliJ and run the jetty:run argument with that configuration, then it works. But what does the above error mean?

It's because the example lists Jetty starter dependency as provided so IntelliJ does not include it in your module, making ServletContext class unavailable, thus causing the NoClassDefFound exception.
Change the definition of spring-boot-starter-jetty dependency in your pom.xml file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<!--<scope>provided</scope>-->
</dependency>
and refresh/reimport the maven project in IntelliJ.
Alternatively, if you do not wish to change the example code, you can manually edit the dependencies in your module's settings in IntelliJ - simply change all Provided dependencies to Compile and it should yield a similar result.

Related

No bean named 'entityManagerFactory' available when module descriptor is added

I want to develop a modular app that uses a MySql db, Java 11 and spring boot. The app works perfectly well until I add the module descriptors; so I can only guess I am missing something in the module-info.java, but I can't figure out what it is. I appreciate any help. Here is my code
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/modules?serverTimezone=UTC
username: modulesAdmin
password: modules
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
properties:
hibernate.format_sql: true
module-info.java
requires java.persistence;
requires spring.context;
requires spring.beans;
requires spring.data.jpa;
requires spring.data.commons;
requires spring.web;
requires spring.boot;
requires spring.boot.autoconfigure;
opens com.jamsws.demojpa to spring.core;
exports com.jamsws.demojpa to spring.beans, spring.context;
exports com.jamsws.demojpa.resource to spring.beans;
User.java
#Entity
public class User {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String teamName;
private Integer salary;
public User() {
}
public User(String name, String teamName, Integer salary) {
this.name = name;
this.teamName = teamName;
this.salary = salary;
}
// getters and setters
}
UsersRepository.java
#Repository
public interface UsersRepository extends JpaRepository<User, Integer> {
}
UserResources.java
#RestController
#RequestMapping(value = "rest/users")
public class UserResources {
#Autowired
private UsersRepository usersRepository;
#PostMapping(value = "/load")
public List<User> persist(#RequestBody final User user) {
usersRepository.save(user);
return usersRepository.findAll();
}
}
DemojpaApplication.java
#SpringBootApplication
#EntityScan(basePackages = "com.jamsws.demojpa.model")
#EnableJpaRepositories(basePackages = "com.jamsws.demojpa.repository")
public class DemojpaApplication {
public static void main(String[] args) {
SpringApplication.run(DemojpaApplication.class, args);
}
}
Error trace
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:982) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:992) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.startup.Tomcat.stop(Tomcat.java:478) ~[tomcat-embed-core-9.0.36.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:273) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:331) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:148) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar:na]
at demojpa/com.jamsws.demojpa.DemojpaApplication.main(DemojpaApplication.java:15) ~[classes/:na]
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:267) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5431) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
... 23 common frames omitted
Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[na:na]
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3307) ~[na:na]
at java.base/java.lang.Class.getMethod0(Class.java:3293) ~[na:na]
at java.base/java.lang.Class.getMethod(Class.java:2106) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc(WebappClassLoaderBase.java:1697) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:1619) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:1555) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:449) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
... 31 common frames omitted
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:72) ~[spring-boot-2.3.1.RELEASE.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) ~[tomcat-embed-core-9.0.36.jar:na]
... 41 common frames omitted
2020-07-19 19:51:17.437 ERROR 10199 --- [ main] org.apache.catalina.core.ContainerBase : A child container failed during stop
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during stop
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:982) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:992) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.startup.Tomcat.stop(Tomcat.java:478) ~[tomcat-embed-core-9.0.36.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:273) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:331) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:148) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar:na]
at spring.boot#2.3.1.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar:na]
at demojpa/com.jamsws.demojpa.DemojpaApplication.main(DemojpaApplication.java:15) ~[classes/:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during stop
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:990) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) ~[tomcat-embed-core-9.0.36.jar:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar:na]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.tomcat.embed.core#9.0.36/org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) ~[tomcat-embed-core-9.0.36.jar:na]
... 16 common frames omitted
2020-07-19 19:51:17.441 INFO 10199 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-19 19:51:17.469 ERROR 10199 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field usersRepository in com.jamsws.demojpa.resource.UserResources 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.
EDIT: Following #Naman suggestion I added a requires java.sql; to the module descriptor file which helped but the issue about "No bean named 'entityManagerFactory' available" is still there
2020-07-20 06:57:54.679 INFO 21643 --- [ main] com.jamsws.demojpa.DemojpaApplication : Starting DemojpaApplication on anderson-ubuntu with PID 21643 (/home/anderson/Documents/JavaApps/PracticeProjects/demojpa/target/classes started by anderson in /home/anderson/Documents/JavaApps/PracticeProjects/demojpa)
2020-07-20 06:57:54.681 INFO 21643 --- [ main] com.jamsws.demojpa.DemojpaApplication : No active profile set, falling back to default profiles: default
2020-07-20 06:57:54.973 INFO 21643 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-07-20 06:57:54.996 INFO 21643 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 20ms. Found 1 JPA repository interfaces.
2020-07-20 06:57:55.272 INFO 21643 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-07-20 06:57:55.276 INFO 21643 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-07-20 06:57:55.276 INFO 21643 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-07-20 06:57:55.295 INFO 21643 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-07-20 06:57:55.295 INFO 21643 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 579 ms
2020-07-20 06:57:55.327 WARN 21643 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userResources': Unsatisfied dependency expressed through field 'usersRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersRepository' defined in com.jamsws.demojpa.repository.UsersRepository defined in #EnableJpaRepositories declared on DemojpaApplication: Cannot create inner bean '(inner bean)#5c080ef3' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5c080ef3': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2020-07-20 06:57:55.328 INFO 21643 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-07-20 06:57:55.338 INFO 21643 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-20 06:57:55.370 ERROR 21643 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field usersRepository in com.jamsws.demojpa.resource.UserResources 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.
Process finished with exit code 1
The primary cause of the exception seems to be
Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException
At the same time, the mention in your question that the "app works perfectly well until I add the module descriptors", seems to indicate that prior to introducing the module-info.java, your application must have been using the classpath, where it was able to find the class mentioned above through transitive dependencies.
1Another aspect would be, that your application doesn't directly need this class, else you would have faced a compile-time error stating that the imports are unrecognized.
This boils down to the module dependencies that you've mentioned in your application's descriptor, so one or more of them requires java.sql.SQLException now to be present on the modulepath and has itself missed specifying that explicitly (quite possible in the case of automatic modules). You would need to identify which module(s) amongst those required by you could need the specific class for a long term resolution.
1One way would be then to say, report it to the library/module owner and ask them to define an explicit dependency. This might require you to wait for them to be modular themself and then make use of the upgraded version. In such a case, you can until there upgrade add an argument to your application
--add-modules=java.sql
Another could be that your application itself at runtime needs the java.sql module and that the libraries just make use of it when declared by you explicitly. In this case, the solution would be to add the following to your module-info.java file:
requires java.sql
I have gone through your stack-trace. Can you try below steps
Remove #Repository annotation from UserRepository.java
Remove #EnableJpaRepositories from DemojpaApplication only if UserRepository.java is in sub package of main DemojpaApplication.java

Spring AOP using #around throws org.springframework.beans.factory.BeanCreationException when I start the application

I am building a Spring Boot MVC application which requires an authentification check on some Controller methods. For that, I didn't use any Identity management framework provided by Spring because I need to do it myself since it is a school project. So I planned to use Aspect Oriented Programmation with Spring AOP, and create an annotation AuthentificatedOnly like this:
#Target({ElementType.METHOD})
#Retention(RetentionPolicy.RUNTIME)
public #interface AuthentificatedOnly {
}
I also created an aspect that should match this annotation, and throw an exception if the user is not authentificated (with a UserManager that I also created, autowired with Spring IOC, and that is fully operationnal since I tested it directly on some controllers, so the problem can't be in the user manager).
The aspect looks like this:
#Aspect
#Component
public class AuthentificationCheckAspect {
#Autowired
private IUserManager userManager;
#Around("#target(dgl.dgladmin_rest.model.auth.AuthentificatedOnly)")
public Object checkAuthentification(ProceedingJoinPoint joinPoint) throws Throwable{
System.out.println("checking authentification for " + joinPoint.getSignature().toShortString());
if(!userManager.isConnected())throw new AuthentificationException();
return joinPoint.proceed();
}
}
I use my annotation on some controller methods which return a view or a ModelAndView like this:
#Controller
public class UserController{
[...]
#AuthentificatedOnly
#GetMapping("/users")
public String userPage(Model model){
return "users";
}
[...]
}
When I launch my application, it throws exceptions and stops:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.6.RELEASE)
2018-11-08 16:43:31.193 INFO 4060 --- [ restartedMain] dgl.Application : Starting Application on WARREN-LAPTOP with PID 4060 (started by Warren in C:\Users\Warren\Documents\école\HELMOB3\Archi Log\projet\DGLAdmin_REST)
2018-11-08 16:43:31.199 INFO 4060 --- [ restartedMain] dgl.Application : No active profile set, falling back to default profiles: default
2018-11-08 16:43:31.681 INFO 4060 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#713bc672: startup date [Thu Nov 08 16:43:31 CET 2018]; root of context hierarchy
2018-11-08 16:43:35.317 INFO 4060 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'authentificationCheckAspect' with a different definition: replacing [Generic bean: class [dgl.dgladmin_rest.model.auth.AuthentificationCheckAspect]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Users\Warren\Documents\école\HELMOB3\Archi Log\projet\DGLAdmin_REST\target\classes\dgl\dgladmin_rest\model\auth\AuthentificationCheckAspect.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=application; factoryMethodName=authentificationCheckAspect; initMethodName=null; destroyMethodName=(inferred); defined in dgl.Application]
2018-11-08 16:43:36.956 INFO 4060 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3cf3c81e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-11-08 16:43:37.134 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [void org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration.setConfigurers(java.util.Collection)] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.274 INFO 4060 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$bc741550] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-11-08 16:43:37.298 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.plugin.core.support.PluginRegistryFactoryBean org.springframework.hateoas.config.HateoasConfiguration.relProviderPluginRegistry()] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.298 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.hateoas.core.AnnotationRelProvider org.springframework.hateoas.config.HateoasConfiguration.annotationRelProvider()] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.298 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.hateoas.RelProvider org.springframework.hateoas.config.HateoasConfiguration.defaultRelProvider()] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.299 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.hateoas.core.DelegatingRelProvider org.springframework.hateoas.config.HateoasConfiguration._relProvider(org.springframework.plugin.core.PluginRegistry)] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.299 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.hateoas.LinkDiscoverers org.springframework.hateoas.config.HateoasConfiguration.linkDiscoverers(org.springframework.plugin.core.PluginRegistry)] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.299 INFO 4060 --- [ restartedMain] o.s.aop.framework.CglibAopProxy : Method [org.springframework.hateoas.config.ConverterRegisteringBeanPostProcessor org.springframework.hateoas.config.HateoasConfiguration.jackson2ModuleRegisteringBeanPostProcessor(org.springframework.beans.factory.ObjectFactory)] is package-visible across different ClassLoaders and cannot get proxied via CGLIB: Declare this method as public or protected if you need to support invocations through the proxy.
2018-11-08 16:43:37.313 WARN 4060 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.hateoas.config.HateoasConfiguration': Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$bc741550: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
2018-11-08 16:43:37.328 INFO 4060 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-11-08 16:43:37.346 ERROR 4060 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.hateoas.config.HateoasConfiguration': Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$bc741550: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:373) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1246) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:708) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at dgl.Application.main(Application.java:34) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.6.RELEASE.jar:2.0.6.RELEASE]
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$bc741550: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:473) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:355) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:304) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
... 29 common frames omitted
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:345) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_101]
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:480) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:337) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205) ~[spring-aop-5.0.10.RELEASE.jar:5.0.10.RELEASE]
... 36 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
... 49 common frames omitted
Caused by: java.lang.IllegalAccessError: class org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$a0484109 cannot access its superclass org.springframework.hateoas.config.HateoasConfiguration
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_101]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_101]
... 54 common frames omitted
I believe the problem is in the #Around annotation in my aspect, because the application starts normally if I replace the #Around annotation by a #Pointcut annotation, but then I can call the affected methods and nothing happens (even the System.out.println isn't reached, so I believe the aspect is never used).
I found the solution to my problem:
Use
#Around("#annotation(dgl.dgladmin_rest.model.auth.AuthentificatedOnly)")
instead of
#Around("#target(dgl.dgladmin_rest.model.auth.AuthentificatedOnly)")

Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder

I am migrating my application from jboss-eap-5.1 to jboss-eap-6.4.0. My application is using spring 3.1.1 related jar and apache-cxf-2.7.7 jars.
Ear file structure is as below
EAR/lib - contains all the jar which is common for wars.
app1.war/lib - contains jars required for it
app2.war/lib - contains jars required for it
I have also excluded modules for webservice, org.jboss.as.jaxrs & ejb3 from standalong.xml config file.
Spring jars :
spring-orm-3.1.1.RELEASE.jar
spring-aop-3.1.1.RELEASE.jar spring-oxm-3.2.4.RELEASE.jar
spring-asm-3.1.1.RELEASE.jar spring-test-3.2.4.RELEASE.jar
spring-beans-3.1.1.RELEASE.jar spring-tx-3.1.1.RELEASE.jar
spring-context-3.1.1.RELEASE.jar spring-web-3.2.4.RELEASE.jar
spring-core-3.1.1.RELEASE.jar spring-webmvc-3.2.4.RELEASE.jar
spring-data-commons-core-1.1.0.RELEASE.jar spring-ws-core-2.1.4.RELEASE.jar
spring-data-jpa-1.0.3.RELEASE.jar spring-ws-test-2.1.4.RELEASE.jar
spring-expression-3.1.1.RELEASE.jar spring-xml-2.1.4.RELEASE.jar
javaw.ws.rs jar containes below jar
javax.ws.rs-api-2.0-m10.jar
apache-cfx-jars packaged in ear/lib are
cxf-api-2.7.7.jar cxf-rt-frontend-jaxrs-2.7.7.jar
cxf-rt-bindings-soap-2.7.7.jar cxf-rt-frontend-jaxws-2.7.7.jar
cxf-rt-bindings-xml-2.7.7.jar cxf-rt-frontend-simple-2.7.7.jar
cxf-rt-core-2.7.7.jar cxf-rt-transports-http-2.7.7.jar
cxf-rt-databinding-jaxb-2.7.7.jar cxf-rt-transports-local-2.7.7.jar
cxf-rt-features-clustering-2.7.7.jar
now when i deploy , i am getting below error. I am not sure how to resolve this error as below
7:33:07,784 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (pool-6-thread-2) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
07:33:07,785 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (pool-5-thread-1) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
07:33:07,790 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (pool-6-thread-2) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#75b6f75e: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,servletContextReaderComponent,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,signatureAlgorithm,serviceAuthManager,authServiceProvider,soaErrorBundle,soaErrorMapper,soaExceptionHandler,soaClientPolicyEvaluator,com.walmart.platform.soa.client.listener.SOAClientLifeCycleListener#0,clientHeaderOutInterceptor,clientLoggingOutInterceptor,clientHeaderInInterceptor,clientLoggingInInterceptor,serviceAuthOutInterceptor,clientPolicyOutInterceptor,clientPolicyInInterceptor,cxf.config2,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
#
07:33:08,015 ERROR [stderr] (Thread-147) 2016-06-20 07:33:08.014 WARN net.spy.memcached.auth.AuthThread: Authentication failed to /172.16.113.154:11210, Status: {OperationStatus success=false: Invalid arguments}
07:33:08,026 WARN [org.jboss.modules] (pool-6-thread-2) Failed to define class org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder in Module "deployment.smcfs.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder (Module "deployment.smcfs.ear:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.6.Final-redhat-1
When i check errors closely it is failing due to below class not found exception .
]
at com.walmartlabs.services.util.base.LabsCallable.call(LabsCallable.java:31) [labs-ims-1.0.jar:]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_51]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_51]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.6.Final-redhat-1]
... 148 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder from [Module "deployment.smcfs.ear:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.
*********************************************8
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_51]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_51]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.6.Final-redhat-1]
... 148 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.AbstractPolicyInterceptorProvider from [Module "deployment.smcfs.ear:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1]
a
************************************
Any suggestion how to overcome this problem
Thanks
I had to add this following dependencies to my pom to avoid that error:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.0</version>
</dependency>

Spring Boot + Hibernate Envers. Error creating bean with name 'entityManagerFactory'

I want to use Envers in my app. So I added to my pom.xml
hibernate-envers 4.2.19.Final
My hibernate version is 4.38
I didn't do anything else, tried to run the tests and it failed
Caused by: 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/boot/registry/classloading/internal/ClassLoaderServiceImpl$Work
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.test.SpringApplicationContextLoader.loadContext(SpringApplicationContextLoader.java:101)
at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:68)
at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:86)
... 28 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl$Work
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:49)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 42 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$Work
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 47 more
Here is my application.yml:
spring:
profiles: default
spring.datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/server?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8_unicode_ci&characterSetResults=UTF-8
username: root
password:
spring.jpa:
database: MYSQL
show-sql: true
hibernate:
ddl-auto: validate
dialect: org.hibernate.dialect.MySQL5Dialect
naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
For test environment:
spring.datasource:
driverClassName: org.h2.Driver
url: jdbc:h2:mem:test;MODE=MySQL;INIT=CREATE SCHEMA IF NOT EXISTS \"public\"
spring.jpa:
database: H2
show-sql: true
hibernate:
ddl-auto: validate
dialect: org.hibernate.dialect.H2Dialect
naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
envers.default_schema: keyserver_audit
What additional configuration I need to do?
There's a Spring Data Envers project which might help here. As a side bonus, it will allow you to access revisions through your repositories. You'll just need this annotation in your config:
#EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
Also, your hibernate properties should be underneath spring.jpa.properties as per the docs

class not found exception spring

i tried to compile and run my application code but i get a class not found exception i will print the stack trace i hope there is someone can help me .
236 [main] INFO org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#37eaab: startup date [Sat May 03 21:15:12 CEST 2014]; root of context hierarchy
472 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - L oading XML bean definitions from URL [file:/C:/Users/housseminfo/workspace/ERP_PCD/target/classes/META- INF/applicationContext.xml]
1017 [main] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
1242 [main] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
1272 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#59727ed4: defining beans [datasource,persistenceUnitManager,entityManagerFactory,entityManager,transactionManager,o g.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annot ation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.Tr ansactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,op manager,metier,org.springframework.context.annotation.internalConfigurationAnnotationProces sor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springf ramework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context .annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.intern alPersistenceAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassP ostProcessor.importAwareProcessor]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(A bstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abs tractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFacto ry.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Default SingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.j ava:198)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(A bstractApplicationContext.java:741) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationC ontext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init> (ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init> (ClassPathXmlApplicationContext.java:83)
at com.ensi.dao.Maintest.main(Maintest.java:13)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader
at org.springframework.beans.CachedIntrospectionResults.<clinit> (CachedIntrospectionResults.java:65)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.jav a:321)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:328)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterProperty DescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterProperty at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(A bstractAutowireCapableBeanFactory.java:1117)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(A bstractAutowireCapableBeanFactory.java:522)
.. 10 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.support.SpringFactoriesLoader
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 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
Hi its very clear from your exception that , you dont have all spring jars in your classpath.
if you are using maven add all dependencies in pom.xml.
otherwise download the jars from spring source and add them into project classpath.
once you add and run , it will work properly.
i don't see any aplication related errors over there. its only jar problem.
either missing jars or version mismatch. check it properly.

Categories

Resources