I have a spring boot gradle project with a server module and I am using the gradle war plugin in my build.gradle file.
https://docs.gradle.org/current/userguide/web_project_tutorial.html
Per this link: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html (80.1)
I am overriding the configure method and I can see that a war file is being built and placed in the server/build/tmp directory.
When the project builds it also creates a empty webapp directory at server/src/main/webapp (this is the default webAppDirName).
http://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-creating-a-web-application-project/
The war is needed so that our ops guys can run it on an external Tomcat container. However, for convenience, us devs are just building and running with the gradle wrapper > ./gradlew :server:bootRun using the embedded Tomcat container.
My problem is that when we do a bootRun it is looking at the empty webapp folder that gets created during the build process and throwing this error:
2016-02-23 10:51:32.632 INFO 83043 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 22443 (https)
2016-02-23 10:51:32.641 INFO 83043 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-02-23 10:51:32.642 INFO 83043 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-02-23 10:51:32.673 ERROR 83043 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/imageretriever]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_60]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_60]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.30.jar:8.0.30]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/imageretriever]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot#7f31763e]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.c.core.StandardContext.resourcesStart(StandardContext.java:4928) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5058) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 6 common frames omitted
Caused by: java.lang.IllegalArgumentException: The main resource set specified [/Users/carlc/intellij_workspace/image-retriever/src/main/webapp] is not valid
at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:723) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:684) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 9 common frames omitted
I thought the issue might be tangentially related to this: https://github.com/spring-projects/spring-boot/issues/1313
But I wasn't able to glean any helpful information out of it.
I can think of two solutions: 1) remove the offending webapp folder during the build process 2) Configure bootRun to ignore the webapp folder all together 3) Your suggestions go here _____________ :)
I can post the build.gradle or other code you think relevant upon request. Thanks for any help.
Related
I was working on spring mybatis-3.2.8 and it was ok for auto mapping with map or Model objects.
When I use individual parameter without #Param annotation, it stops working.
(At the time, I didn't know that no-param annotation mapping only works above mybatis-3.5.2)
Btw, I changed mybatis version to 3.5.2 at pom.xml, then the following error occured.
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:915)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:86)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:63)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:335)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:782)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5202)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.Resource
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
... 20 more
I looked for solution hours and hours, and most of them suggests to add dependancy spring-core-${org.springframework.version}. e.g.here
But it doesn't work for me.
My dependancy hierarchy has already got spring-core.
Also, when I change the version from 3.5.2 to 3.5.8 then rollback to original version(3.2.8), the error continues. (what a hell...)
Can anybody help me.?
I append screenshot of pom.xml dependancy hierarchy.
I have a simple Spring Boot web application.
https://gist.github.com/IvanZelenskyy/90f554276c6b3665f11368c7152ae97e
And I have a Tomcat 8.x and TomEE 7.x servers with default config both.
When I deploy my app (as war) to Tomcat (and also to Glassfish), and it works fine. But when I'm trying to deploy this war to TomEE, I got a lot exception in logs:
07-Sep-2018 14:05:45.627 INFO [localhost-startStop-2] sun.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application archive [/home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1.war]
07-Sep-2018 14:05:45.629 INFO [localhost-startStop-2] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /demotomee1
07-Sep-2018 14:05:45.633 INFO [localhost-startStop-2] org.apache.openejb.util.JarExtractor.extract Extracting jar: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1.war
07-Sep-2018 14:05:45.744 INFO [localhost-startStop-2] org.apache.openejb.util.JarExtractor.extract Extracted path: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1
07-Sep-2018 14:05:46.180 INFO [localhost-startStop-2] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1
07-Sep-2018 14:05:46.402 INFO [localhost-startStop-2] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
07-Sep-2018 14:05:46.403 INFO [localhost-startStop-2] org.apache.openejb.config.AutoConfig.createContainer Auto-creating a container for bean demotomee1.Comp1226937296: Container(type=MANAGED, id=Default Managed Container)
07-Sep-2018 14:05:46.403 INFO [localhost-startStop-2] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Container(id=Default Managed Container)
07-Sep-2018 14:05:46.429 INFO [localhost-startStop-2] org.apache.openejb.core.managed.SimplePassivater.init Using directory /home/ivan/apache-tomee-plume-7.0.5/temp for stateful session passivation
07-Sep-2018 14:05:46.478 INFO [localhost-startStop-2] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1" loaded.
07-Sep-2018 14:05:46.478 INFO [localhost-startStop-2] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1
14:05:46.915 [localhost-startStop-2] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
07-Sep-2018 14:05:46.988 INFO [localhost-startStop-2] org.apache.openejb.assembler.classic.Assembler.destroyApplication Undeploying app: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1
07-Sep-2018 14:05:46.993 SEVERE [localhost-startStop-2] sun.reflect.NativeMethodAccessorImpl.invoke ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demotomee1]] in state [STARTING_PREP]
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:856)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1651)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1631)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:764)
at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:2374)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:1092)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:757)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1303)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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)
07-Sep-2018 14:05:47.137 SEVERE [localhost-startStop-2] org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demotomee1]
org.apache.openejb.OpenEJBException: Creating application failed: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1: javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:1096)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:757)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1303)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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.NoSuchMethodError: javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:140)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38)
at org.apache.bval.jsr.ConfigurationImpl.__privileged_doBuildValidatorFactory(ConfigurationImpl.java:332)
at org.apache.bval.jsr.ConfigurationImpl.doBuildValidatorFactory(ConfigurationImpl.java)
at org.apache.bval.jsr.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:324)
at org.apache.openejb.assembler.classic.ValidatorBuilder$OpenEjbConfig.buildValidatorFactory(ValidatorBuilder.java:401)
at org.apache.openejb.assembler.classic.ValidatorBuilder.buildFactory(ValidatorBuilder.java:111)
at org.apache.openejb.assembler.classic.ValidatorBuilder.buildFactory(ValidatorBuilder.java:67)
at org.apache.openejb.assembler.classic.LazyValidatorFactory.ensureDelegate(LazyValidatorFactory.java:54)
at org.apache.openejb.assembler.classic.LazyValidatorFactory.getFactory(LazyValidatorFactory.java:65)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:975)
... 17 more
07-Sep-2018 14:05:47.138 SEVERE [localhost-startStop-2] sun.reflect.NativeMethodAccessorImpl.invoke ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demotomee1]]
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: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Creating application failed: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1: javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1315)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.apache.openejb.OpenEJBException: Creating application failed: /home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1: javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:1096)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:757)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1303)
... 15 more
Caused by: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:140)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38)
at org.apache.bval.jsr.ConfigurationImpl.__privileged_doBuildValidatorFactory(ConfigurationImpl.java:332)
at org.apache.bval.jsr.ConfigurationImpl.doBuildValidatorFactory(ConfigurationImpl.java)
at org.apache.bval.jsr.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:324)
at org.apache.openejb.assembler.classic.ValidatorBuilder$OpenEjbConfig.buildValidatorFactory(ValidatorBuilder.java:401)
at org.apache.openejb.assembler.classic.ValidatorBuilder.buildFactory(ValidatorBuilder.java:111)
at org.apache.openejb.assembler.classic.ValidatorBuilder.buildFactory(ValidatorBuilder.java:67)
at org.apache.openejb.assembler.classic.LazyValidatorFactory.ensureDelegate(LazyValidatorFactory.java:54)
at org.apache.openejb.assembler.classic.LazyValidatorFactory.getFactory(LazyValidatorFactory.java:65)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:975)
... 17 more
07-Sep-2018 14:05:47.138 SEVERE [localhost-startStop-2] sun.reflect.NativeMethodAccessorImpl.invoke Error deploying web application archive [/home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1.war]
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demotomee1]]
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)
07-Sep-2018 14:05:47.138 INFO [localhost-startStop-2] sun.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application archive [/home/ivan/apache-tomee-plume-7.0.5/webapps/demotomee1.war] has finished in [1,511] ms
What can I do to start my app on TomEE?
I had the same problems. I was able to get a working Spring Boot application on TomEE with its dependency and exclusiion of hibernate-validator in pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>apache-tomee</artifactId>
<version>7.X.X</version>
</dependency>
I have 2 environments. The first one is a mac where I have installed Tomcat 8 by extracting the .zip file downloaded from Apache's homepage. The second one is a virtual machine on this mac which runs Ubuntu 15.04.
I have my web application as a war-file and can deploy that on my mac's Tomcat without any problem. Now, I want to do exactly the same deployment on the Ubuntu. So I copy the Tomcat-folder over to my Ubuntu along with my war-file and try to do the same deployment there. Before I do this I check so that JRE_HOME and JAVA_HOME is set the Java 8 installation I installed via PPA. I then start Tomcat and it seems to work so far. I go to localhost:8080 and Tomcat is running. I look at the JVM version at the status page and it reads 1.8.0_91_b14, seems good right? But then I try the deployment and I get this error:
FAIL - Application at context path /app could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component ...
I tried with a very simple web app as well, one that only contained a index.html file. That is working. But this one, with compiled java classes and jsp and stuff does not. Here is more from the tomcat log files:
28-Jun-2016 03:02:00.557 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/app]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.apache.jasper.xmlparser.ParserUtils.<init>(Z)V
at org.apache.jasper.runtime.TldScanner.scanTld(TldScanner.java:603)
at org.apache.jasper.runtime.TldScanner.scanJar(TldScanner.java:460)
at org.apache.jasper.runtime.TldScanner.scanJars(TldScanner.java:697)
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:353)
at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:242)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5292)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more
28-Jun-2016 03:02:00.561 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive /home/ubuntu/Java/apache-tomcat-8.0.36/webapps/app.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/app]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
What is different from my mac that causes this?
UPDATE:
I can run a simple war with a jsp file, a servlet class. I think it's very strange and confusing.
UPDATE:
Ok, now I have tested with Glassfish on the virtual machine and the application is running there, but instead I get sql exception that no connection to database could be created.
I went back to my mac and noticed that I get no exceptions, but no items from my database are shown in my page. The only time they are shown is when started with Eclipse. So I let eclipse build the war file and do manual deployment, but same thing, no items loaded.
My hypothesis is that the database (driver, config, ect) are not enough/corrupted when I manually deploy to the server. ANYONE KNOWING A BIT MORE ABOUT HOW SERVERS WORK?? And still, why does deployment work on mac but not Ubuntu?
UPDATE:
Apparently the logging with log4j doesn't work either when I deploy manually. Somehow all my external resources and communication gets fucked up when I deploy manually. Why doesn't the log files tell me what is the problem??
UPDATE:
I changed eclipse tomcat server installation location to the same location as my tomcat home. Now I can se how Eclipse changed the Tomcat folder. I copied over that tomcat installation to Ubuntu and tried, but same failure..
UPDATE:
Now, I recognized the log-files for the virtual host called localhost, and it gives me a much more precise cause of the problem:
30-Jun-2016 06:36:08.586 SEVERE [http-nio-8080-exec-10] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.app.AppContextListener
javax.persistence.PersistenceException: Unable to build entity manager factory
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:66)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at com.app.AppContextListener.createEntityManagerFactory(AppContextListener.java:67)
at com.app.AppContextListener.contextInitialized(AppContextListener.java:63)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1284)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:666)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:64)
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:47)
at org.hibernate.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:143)
at org.hibernate.boot.archive.internal.ExplodedArchiveDescriptor.visitArchive(ExplodedArchiveDescriptor.java:54)
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:46)
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:75)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)
... 39 more
UPDATE:
There was another post on this new error and it turned out that I had duplicate jar files of type javassist-xyz.jar of different versions. I removed one of them and now I get this instead:
com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source
Another with the exact same problem now: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source
SOLVED:
I finally solved it! Apperently the port on which my tcp database server runs on was not closed when Tomcat started, so it could not start a new one from the old state. The situation evolved when the application context couldn't be destroyed properly on all my attempts to get it working. I added some more logging to my AppContextListener class and that did spot this problem. The only real severe problem I had in the end, was a duplicate of two jar files!
I am trying to deploy a Spring application to server running Apache Tomcat. However, I get this error:
SEVERE: ContainerBase.addChild: start: …
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/RuralIvrs]]
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:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NoSuchMethodError:
javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.tomcat.websocket.server.WsServerContainer.(WsServerContainer.java:147)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Jan 21, 2016 12:16:42 PM org.apache.catalina.startup.HostConfig
deployWAR … SEVERE: Error deploying web application archive
/home/ruralivrs/Ruralict/apache-tomcat-7.0.42/webapps/RuralIvrs.war
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/RuralIvrs]]
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:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I was unable to find a solution after searching for several hours. Since I am quite new to this, any help would be greatly appreciated. Thank you!
You can find similar problem in this blog post.
The solution is probably as simple as adding a tomcat.version property to your Maven project’s pom.xml file
<properties>
<tomcat.version>7.0.67</tomcat.version>
</properties>
The reason is explained inside Spring Boot documentation for embedded-servlet-containers.
Spring Boot defaults to Tomcat 8, so you need to tell Spring Boot that your target is Tomcat 7.
I am using Spring 4, Resteasy 3.0.6 and Tomcat 7
Tomcat startup fine but I get a 404 for all REST endpoints.
I think I am running into exactly is described here:
https://issues.jboss.org/browse/RESTEASY-1012
I created that custom class and updated the web.xml
<listener>
<listener-class>com.example.CustomContextLoaderListener</listener-class>
</listener>
However now I get this exception and Tomcat fails to start
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:
Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].Stand
ardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
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:744)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [St
andardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 more
Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletCo
ntainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
at org.apache.catalina.startup.ContextConfig.getServletContainerInitiali
zer(ContextConfig.java:1661)
at org.apache.catalina.startup.ContextConfig.processServletContainerInit
ializers(ContextConfig.java:1569)
Any help will be appreciated. Thanks
Answering my own question. The problem was that javax-servlet was a compile dependency so I had to change its scope to provided as that was causing a conflict with Tomcat (I'm using Maven)