I have a spring boot application that works fine when I run it using the embedded server from Intellj. However, when I package it into .war file and deploy it on tomcat I get the following error:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2200)
at
org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2159)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1124)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:769)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5176)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
21-Jan-2019 01:51:04.709 SEVERE [localhost-startStop-1]
org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [C:\Users\dennismo\Dev\Projects\Production Prep\file-upload-module\webapps\file-upload-0.0.1-SNAPSHOT.war]
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]]
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:758)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
My project does not contain multiple web-fragment so I don't know what could be causing this problem.
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from salaryPaymentRequestRepo -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<akka.version>2.5.17</akka.version>
</properties>
<repositories>
<repository>
<id>default</id>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</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-data-jpa</artifactId>
</dependency>
<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>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.univocity</groupId>
<artifactId>univocity-parsers</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.4.2</version><!-- or latest version -->
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.12</artifactId>
<version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-stream_2.12</artifactId>
<version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-persistence_2.12</artifactId>
<version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.12</artifactId>
<version>${akka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/ojdbc7-12.1.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
add <absolute-ordering /> tag to your web.xml just under the <display-name> tag.
should work.
Cleaning the server worked for me. Just do the following :
Right click on the server -> Clean.
Then redeploy the app on the server.
Sounds like you have two different versions of Spring, check your dependencies to see if you have a dependency to another Spring-version.
mvn dependency:tree -Dverbose -Dincludes=groupId:artifactId
I had the same problem when building a war file with maven because I did not clean before packaging and maven was including multiple versions of spring jar files from previous builds.
This error seems to happen after project's spring framework update, clearing the project history file in tomcat webapps may solve the problem.
This problem was solved by adding absolute ordering of deployment descriptors.
The tag <absolute-ordering/> was added to the web.xml
Reference:
https://www.oracle.com/technetwork/articles/javaee/javaee6overview-part2-136353.html
I had this occur after I updated the Spring Framework version in a Maven project. I was finally able to resolve the issue by running mvn clean, apparently the old Spring JARs were being picked up somewhere under target.
This error generally comes from that if we have two copy of spring in our container, which get loaded by different class loaders(in my case shared class loader and webapp class loader).
Check effective pom, if you have any bundle embed spring jars/classes, if so remove it, you should use the one installed as bundle from container.
If you manually adds all the Jars then you have to delete WEB-INF/lib/spring-web-5.2.9.RELEASE-sources.jar or similar jar file (may be your jar version will be different). Once you delete that jar tomcat will start working.
My project is Springboot based version (1.5.21.RELEASE) and generating war and deploying in physical tomcat.
I had gotten the same issue and got resolved with below approach.
Solution: Exclude tomcat-embed-websocket dependency from spring-boot-starter-web in the pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
**<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
</exclusion>**
</exclusions>
</dependency>
Just an answer from newbbie to newbbies:
Make sure you place web.xml inside /WebContent/WEB-INF.
I placed it inadvertently in /WebContent (not /WEB-INF), and almost got crazy trying to unsuccessfully apply some of the proposed solutions, the error message was exactly the same.
For me this meant that I was including some "shaded jars" that bundled copies of spring within them. So all the same "spring version" but multiple copies of spring causes this.
You can check if this is the case by going to tomcat/webapps/your_webapp/WEB-INF/lib, unjarring all the jars, and searching for "spring_web"
ex:
# first unjar everything then
WEB-INF/lib $ grep spring_web . -r
spring-web-4.3.12.RELEASE/META-INF/web-fragment.xml
7: <name>spring_web</name>
some_other_shaded_jar/META-INF/web-fragment.xml
7: <name>spring_web</name>
If this is the case you'd need to use the absolute fix of the other answers or not include multiple copies of spring somehow.
Seems this is a change introduced in tomcat 7.0.93 FWIW (so it didn't throw this failure in earlier versions of tomcat 7)
Your web.xml should look like this (added <absolute-ordering/> inside the tag web-app tag)
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<absolute-ordering/>
</web-app>
I had the same problem and solved it. Got similar errors but not used spring boot. I have used spring 3.x with java 8. If above solutions are not working change the jars and search whether those jars are compatible with the java version you are using or not. spring 3.x is not compatible with java 8.
I solved similar problem by removing all my apps (I had there two different apps) from webapps folder and then redeployed my war file.
I had to add this in web.xml to make it work :
<absolute-ordering>
<name>fragment_name_if_required</name>
<others></others>
</absolute-ordering>
All these answers are great but also check if "Apache CXF" lib is in your classpath, it apparently conflicts with Spring Web 5.2.3, for me I temporary removed because I'm actually not using it and now my project is running okay.
For me, this issue happened when Tomcat was not properly installed .I have reinstalled and updated the installation path at:
eclipse window->preferences->runtime ENV -> path of the newly installed tomcat
After setting the correct path, it worked fine.
For me , it was because of 2 spring-web jars i.e. spring-web-5.02-release.jar and spring-web-sources-5.02-release.jar in build path. By removing spring-web-sources-5.02-release.jar, issue is solved.
Had the same issue and wanted to get to the root cause. I knew spring-web jar's fragment is called 'spring_web'. However my source code did not have 'spring_web' fragment anywhere else. So I used a tool (jfind) to search for 'spring_web' through an expanded form of my EAR that was generated at build time. Surprisingly, 'spring_web' was found in another project's web-fragment jar that was generated at build time. On resolving this second occurrence, the issue was gone. So it seems to be due to duplicate 'spring_web' fragment and we need to have just one.
If you have previously built the project with another version and then changed the version and tried to build again, this exception is thrown. You can delete the target folder in your application. If you still get an exception, you can go to the project directory from the terminal and type mvn clean install
Remove all the unused dependencies from the lib folder.
Now try to rerun the application on the server.
Hope it will work now.
I was fighting with this few hours. Solution for me was to invalidate IntelliJ cache.
This problem showed up when I was in the process of upgrading spring framework.
Intellij was packaging two versions of the same library and that's why I was getting an error.
This happened to me when I changed the version of one of the dependencies in pom.xml, undeploying and deploying the webapp fixed it for me
See the below Line in error log:
Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
which says to use absolute ordering.
So, you have to add <absolute-ordering/> tag in your web.xml file inside <web-app> tag.
I'm working on an application that consumes a web service using SOAP requests.
Sometimes I get this error:
filters.LoggerFilter:92 - org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
The weird part is that I get this error randomly, but I can't seem to figure out the cause.
I even added a new dependency, but it doesn't seem to correct the issue:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
</dependency>
I just had the same problem while using Java 11 to create an application that consumes SOAP-requests.
I added the new dependency and it worked fine for me.
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
For me, I was using Java 13 and the following worked for me(add these in the pom.xml)
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-api</artifactId>
<version>2.4.4</version>
</dependency>
For those who face this issue in intellij IDEA using Spring Boot under Java SDK 9+, you have to include explicitly --add-modules java.se.ee in VM parameters (edit configurations -> VM options). This answer may help to resolve other importing issues related to new Java Modules
I had the same problem.
For me, adding saaj-impl was not enough to get rid of the exception
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.2</version>
</dependency>
I had to also add saaj-api which fixed it finally:
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3.5</version>
</dependency>
Since I realised that my application was using saaj-api 1.3.4 after checking with command, upgrading to 1.3.5 helped
mvn dependency:tree -Dverbose
Change your project sdk as Java 1.8
If you are using import javax.xml.ws library it could be confusing com.sun.xml.messaging.saaj dependency in Java 11. Clearing saaj dependency then using Java8 may be a solution in this issue
With open JDK 17 and spring boot 3.0.1, I was getting the same issue. It got resolved by adding these dependencies in pom.xml
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-api</artifactId>
<version>2.4.4</version>
</dependency>
I made a new Maven project with Netbeans. There is a pom.xml in which i added:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.24</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
Is it normal if I don't have a web.xml in my project tree after building the project or should i treat the glassfish.xml just the same ?
I wonder if I didn't messed up things.
Java EE 6 made web.xml optional (traded in for a bunch of annotation-based configurations).
If maven knows that Java EE 6 is the version, then it won't complain about a missing web.xml.
You should be able to configure for the most part using annotations. For portability's sake, use web.xml IF NEEDED rather than relying on vendor-specific configuration files.
Yup I Got solution (how to create web.xml in maven NetBeans 12.0 or later)
After making web application in maven NetBeans
1) Right click on WEB-INF Folder -> New -> Other
after clicking on other.. a window will popup
in that choose : WEB folder in category
after choosing WEB on right corresponding file type will open
in that select: Standard Deployment Descriptor(web.xml)
and now u have it enjoy .....
[My first Answer on Stack Overflow :)]
I have project which used JIRA REST Java Client. It worked fine until I tried to integrate it with Spring Boot. Since that I am not able to invoke createWithBasicHttpAuthentication from AsynchronousJiraRestClientFactory without error. I get:
ClassNotFoundException: org.apache.http.util.Args
So I added HttpComponents Core blocking I/O(httpcore) dependency to my pom.xml, but I after that I got
ClassNotFoundException: org.apache.http.nio.NHttpMessageParserFactory
Which I resolved with adding HttpComponents Core non-blocking I/O(httpcore-nio) to pom.xml. Now I have
NoSuchMethodError: org.apache.http.nio.client.HttpAsyncClient.start()V
I've compared dependency:tree when project has spring boot parent and when it's commented out. It shown me that adding spring boot parent changes versions of my dependencies. You can check diff here( on left without spring boot, on right with spring boot)
It seems that JIRA REST Java Client need older versions of some dependencies.
How can I solve this problem?
pom.xml
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RELEASE</version>
</parent>
...
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
<version>4.3</version>
</dependency>
</dependencies>
...
I was able to fix runtime in my Spring Boot application by overriding these properties in my pom.xml
<properties>
<httpasyncclient.version>4.0-beta3-atlassian-1</httpasyncclient.version>
<httpclient.version>4.2.1-atlassian-2</httpclient.version>
</properties>
Note that there can be other problems if you decide to use http-client and/or httpassync client in your project (eg. using RestTemplate).
Atlassian should definitely upgrade the dependencies.
I have the follwing dependencies in my POM. I am trying to add the CDI facet in IntelliJ IDEA 11 because I thought I would get an option for creating the beans.xml file without manually having to write it, just as you do with persistence.xml etc. However even though I have the dependencies it says Weld is missing, but why do I need to download these when I have everything I need in the POM?
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
On a JBoss stack, I usually use that dependency:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
(Requires JBoss Repo)
Have a look at that configuration here, which I used for a plain Java EE 6 stack (on a JBoss AS 6)
I've never had weld on the classpath. Simply the cdi-api and the beans.xml and it finds the facet just fine. If you're worried about having to manually create the beans.xml, create a template for it and be done.