Spring Boot Tomcat Container Deployment Errors - spring-mvc
I would like to deploy my Spring Boot application as a WAR to a Tomcat Container, but Tomcat is unable to start the container. I have followed the documentation, Traditional Deployment Section from the Spring Boot Reference. The container's thread size is set to -Xss 4068, but I'm still getting a stack overflow error.
Here is the stack trace:
Dec 08, 2014 12:01:13 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Tomcat\customer\webapps\customer-site-0.0.1-SNAPSHOT\WEB-
INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2.
Offending class: javax/servlet/Servlet.class
Dec 08, 2014 12:01:15 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[customers-prototype.mydomain.com].StandardContext[/customer-site-0.0.1-SNAPSHOT]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/customer-site-0.0.1-SNAPSHOT] due to a StackOverflowError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [com.ibm.db2.jcc.am.mf->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object]
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2126)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2072)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1947)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1913)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1898)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5380)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Dec 08, 2014 12:01:15 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive C:\Tomcat\customer\webapps\customer-site-0.0.1-SNAPSHOT.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[customers-prototype.mydomain.com].StandardContext[/customer-site-0.0.1-SNAPSHOT]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Dec 08, 2014 12:01:15 AM org.apache.catalina.startup.HostConfig deployWAR
My pom.xml has the following Spring Boot dependency with the spring-boot-starter-tomcat scope set to provided as described in the documentation.
POM.XML
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
UPDATED: Additional pom dependencies:
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc4</artifactId>
<version>9.7.0.9</version>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc_license</artifactId>
<version>9.7.0.9</version>
</dependency>
My main class extends the SpringBootServletInitializer as described in the documents:
CustomerSiteMain.java:
#Configuration
#ComponentScan("com.mydomain")
#EnableAutoConfiguration
public class CustomerMain extends SpringBootServletInitializer{
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
return application
.showBanner(true)
.parent(Global.class)
.sources(CustomerMain.class)
.profiles("container");
}
public static void main(String[] args) {
SpringApplication.run(CustomerMain.class, args);
}
#Bean
#Profile(CustomerSiteProfiles.STANDALONE)
public ServletRegistrationBean h2Console() {
ServletRegistrationBean reg = new ServletRegistrationBean(new WebServlet(), "/console/*");
reg.setLoadOnStartup(1);
return reg;
}
#Bean
public ServletRegistrationBean servletRegistrationBean(){
return new ServletRegistrationBean(new PhotoSheetPDFServlet(), "/items/factsheet/*");
}
}
The above helped me out as well. I had a similar issue and kept getting WebappClassLoader logs like this:
2015-03-06 20:32:53,741 org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0/WEB-INF/lib/tomcat-embed-core-8.0.15.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
2015-03-06 20:32:53,742 org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0/WEB-INF/lib/tomcat-embed-el-8.0.15.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
which were a clue to this SEVERE error I got with the web application loading.
2015-03-06 20:32:54,704 org.apache.catalina.startup.HostConfig deployWAR SEVERE: Error deploying web application archive /usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0.war
I was developing a web service in my case and these depencies (web service not web) in my pom.xml
<dependencies>
<!-- tag::springws[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<!-- end::springws[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
But I was forgetting to do a clean as well before a maven install. This cost my a few hours because my tomcat libraries were still there.
USER BEWARE that you should also do a maven clean when you follow Springs https://spring.io/guides/gs/convert-jar-to-war/ and http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
This is great now for more rapid development. Thanks
It seems like your Tomcat is trying to load some classes that have already been loaded.
Try to exclude an embeded tomcat from spring-boot-starter-web dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
Related
Embedded Kafka test cases are error after adding jsonschema2pojo-core
I have an application that created with Spring boot and Spring kafka libraries. Now I added jsonschema2pojo-core library to my pom file. After adding this jar file my test cases are failing with below error Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedKafka': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp Caused by: java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.1.RELEASE</version> <relativePath /> </parent> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> <!-- Test Dependencies --> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.jsonschema2pojo</groupId> <artifactId>jsonschema2pojo-core</artifactId> <version>1.0.2</version> </dependency>
It's probably similar to this https://docs.spring.io/spring-kafka/docs/2.5.11.RELEASE/reference/html/#jacksonscala-incompatibility with the library pulling in an incompatible scala library. Yes, adding <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.12.11</version> </dependency> fixed it for me; but I can't guarantee that jsonschema2pojo will work with that version. The scala folks are notorious for breaking API changes in patch releases.
Adding Spring Kafka Maven dependency version 2.2.1.RELEASE encountered ClassNotFoundException
I wanna use Kafka client in Spring boot. After reading the offical documentaion, I added the maven dependency. Then I tried to start Spring Boot. It throws ClassNotFoundException. This class is 'org.springframework.kafka.listener.RecordInterceptor ' Could anyone can solve this problem? Version: <spring.boot.version>2.2.1.RELEASE</spring.boot.version> <spring.version>5.2.1.RELEASE</spring.version> pom.xml: <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> <version>${spring.boot.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>${spring.boot.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> <version>${spring.boot.version}</version> </dependency>
When using Spring Boot, you should let boot manage the version, for Boot 2.2.1, the proper version is 2.3.3. Docs. But, when using Boot, you can omit the version and Boot will automatically use the right version. <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency>
Caused by: java.lang.NoSuchFieldError: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
When using web3j java library in a spring boot application, I am getting the below exception in the Web3j.build line. Any idea to fix this issue? private static final Web3j web3j = Web3j.build(new HttpService("https://rinkeby.infura.io/v3/sdas")); Caused by: java.lang.NoSuchFieldError: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 at org.web3j.protocol.http.HttpService.<clinit>(HttpService.java:37) at sg.com.paloit.hashit.service.ContractService.<clinit>(ContractService.java:36) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147) ... 48 common frames omitted <dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <version>4.1.0</version> </dependency>
org.web3j (4.1.0) core comes with lower version of okhttp which doesn't have the cipher: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256. Its a relatively new cipher, changing okhttp to okhttp3 helped to resolve the issue. <dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <version>4.1.0</version> <exclusions> <exclusion> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.9.0</version> </dependency>
Spring boot error:java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
I want to use spring boot to start my application ,but after i add some relative jar at pom.xml,it return this error:and i thank may be it caused by some conflict jars? Application.java package com.mm.application; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.web.servlet.view.InternalResourceViewResolver; #ComponentScan("com.mm.controller") #Configuration #EnableAutoConfiguration public class Application { public static void main(String[] args) { //spring properties xml ApplicationContext context = new ClassPathXmlApplicationContext( "Spring-Module.xml"); SpringApplication.run(Application.class, args); } #Bean public InternalResourceViewResolver setupViewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); resolver.setPrefix("/WEB-INF/jsp/"); resolver.setSuffix(".jsp"); return resolver; } } Error: Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug) Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) atorg.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648) at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) at org.springframework.boot.SpringApplication.run(SpringApplication.java:909) at org.springframework.boot.SpringApplication.run(SpringApplication.java:898) at com.mm.application.Application.main(Application.java:20) Main Problem: Caused by: java.lang.ArrayStoreException:sun.reflect.annotation.TypeNotPresentExceptionProxy atsun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673) at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480) atsun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306) atsun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) atsun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) atsun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3185) at java.lang.Class.getDeclaredAnnotations(Class.java:3166) atorg.springframework.core.annotation.AnnotationUtils.isAnnotationDeclaredLocally(AnnotationUtils.java:395) atorg.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:281) atorg.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:265) atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:173) atorg.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:123) atorg.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:103) atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126) atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ... 15 more pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.0.1.RELEASE</version> </parent> <properties> <start-class>com.kdubb.springboot.Application</start-class> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>http://repo.spring.io/libs-snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>http://repo.spring.io/libs-snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.0.4</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.0.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-dao</artifactId> <version>2.0.8</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> </dependencies> LoginController package com.mm.controller; import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; #Controller #Component public class LoginController { #RequestMapping(value = "/CreditRating", method = RequestMethod.GET) public String index(Model model) { model.addAttribute("wisdom", "Goodbye XML"); // renders /WEB-INF/jsp/Login.jsp return "Login"; } #RequestMapping(value = "/CreditRating/GoLogin") public String login(Model model) { model.addAttribute("wisdom", "Goodbye XML"); // renders /WEB-INF/jsp/index.jsp return "index"; } }
The solution can vary based on actual incompatibility root cause. The best way how to investigate such the issue is to follow this line: Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy and put breakpoint into constructor of class 'TypeNotPresentExceptionProxy' (there is only one). After execution in debug mode you should see what exactly is wrong and based on your findings you can decide what to do (add dependency, exclude autoconfig, ...) In my specific case the breakpoint revealed this: java.lang.ClassNotFoundException: org.springframework.integration.config.IntegrationManagementConfigurer As the solution I decided to exclude 'IntegrationAutoConfiguration' like this: #SpringBootApplication(exclude = IntegrationAutoConfiguration.class)
As explained by Andy Wilkinson in this GitHub issue or in this thread, these obscure exceptions occur when some annotation is referencing a class that isn't on the classpath. Most issues of this kind have been fixed in recent Spring Boot versions, but you can also trigger one from your code, for example when using #AutoConfigureAfter(X.class) where class X is missing on the classpath.
I had the same issue with spring-boot-starter-parent 2.0.0.M6. The solution was to remove <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> <version>3.1.11</version> </dependency> and include <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency> instead.
I had the same issue with : <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> As per the previous posts the solution was only to add : <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency>
I had the very same exception but my spring-boot-starter-parent was version 1.3.3, as below <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.RELEASE</version> </parent> The exception showd up as I was upgrading to 1.4.1 The solution for me was I had to lose the bad dependency: <dependency> <groupId>org.springframework.ws</groupId> <artifactId>spring-ws-core</artifactId> <version>2.1.4.RELEASE</version> </dependency> And replace it with the dependency below as per the Release notes of Spring Boot 1.4.0 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency>
The problem for me was simply that I hadn't cleaned my project before running verify, after having made some significant changes.
I had a same problem with this error : Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy I used below dependency in my POM.xml and the problem was solved : <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-spring-boot-autoconfigure --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-autoconfigure</artifactId> <version>3.2.1</version> </dependency>
The solution approach of adding spring-boot-starter-web-services dependency, proposed in the above answers, is good, working, but excessive in cases where you don't need web context to be raised up. I mean, if your application doesn't wish to be a web application. In such a case, at least for me, the adding of the following thinner dependency also resolved the issue: org.springframework:spring-webmvc implementation 'org.springframework:spring-webmvc:5.2.1.RELEASE'
If you are using spring JPA then make sure you have added the following dependency to pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
We ran into this issue when we were using an older version of Spring (1.x) and Websphere Liberty 22.0.0.3 with Java 8. The issue is no longer there with the latest WLP - 22.0.0.13.
Spring MVC Initialization Causes Log4J Exception
In my webapp, I am using Spring MVC as my controller layer. However, using the tags provided by the MVC context: <mvn:annotation-driven /> <mvc:resources /> causes a log4j exception: <Mar 26, 2012 1:49:50 PM EDT> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation. java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.log(Category.java:856) at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597) at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225) Truncated. see log file for complete stacktrace (LoggingEvent.java:165) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.log(Category.java:856) at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597) at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225) Truncated. see log file for complete stacktrace Basic stuff: log4j-1.2.16.jar is defined in the maven POM and is in the application library. Since it's a weblogic server, I have the following in the weblogic.xml file to try to prevent conflicts: <wls:prefer-application-packages> <wls:package-name>org.apache.log4j.*</wls:package-name> </wls:prefer-application-packages> (Update) I manually excluded commons-logging in the maven POM for the application. (Update) I already had the slf4j jars in my Maven POM (removing the jcl-over-slf4j has no effect): <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.5.8</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.8</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.8</version> <scope>runtime</scope> </dependency> Basically, I need to exclude the basic css and js directories as web as a single directory under WEB-INF/ that contains some jspf files that I do NOT wish to write a controller for (dropdown menus definitions used by jquery superfish). Any help?
Add slf4j-log4 connector to the POM: <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j-version}</version> <scope>runtime</scope> </dependency>