can't deploy spring project on tomcat - spring

I had a working spring project and updated the framework to version 3.2.2. Now I can build my project but I can't deploy it any more. Aparently Tomcat can't find a class responsible for the logging. But the springframework is in my CLASSPATH, and I'm sure it is contained in the WAR, too. Did I misunderstand the tomcat log?
I even started a new minimalistic spring project - same result.
I'm quite stuck here - any help is appreciated.
Here's my Netbeans log:
Tomcat server started.
Incrementally deploying http://localhost:8080/SpringTest
Completed incremental distribution of http://localhost:8080/SpringTest
Incrementally redeploying http://localhost:8080/SpringTest
Deploy is in progress...
deploy?config=file%3A%2Ftmp%2Fcontext9144781847406895845.xml&path=/SpringTest
FAIL - Deployed application at context path /SpringTest but context failed to start
/home/maex/NetBeansProjects/SpringTest/nbproject/build-impl.xml:1061: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 7 seconds)
And the more interesting Tomcat Apache log:
INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
Jun 01, 2013 7:00:05 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /home/maex/public_html/conf/Catalina/localhost/Bonjour.xml
Jun 01, 2013 7:00:05 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/maex/NetBeansProjects/Bonjour/build/web/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Jun 01, 2013 7:00:07 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Bonjour]]
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.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
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.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2317)
at java.lang.Class.getDeclaredFields(Class.java:1762)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
Jun 01, 2013 7:00:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor /home/maex/public_html/conf/Catalina/localhost/Bonjour.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Bonjour]]
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.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
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)

It looks like you have several issues, but let's start with the 2 obvious ones.
INFO: validateJarFile(/home/maex/NetBeansProjects/Bonjour/build/web/WEB-INF/lib/servlet-api.jar) - jar not loaded...
This error is cause by the inclusion of the servlet*.jar in your runtime, it only needs to be available during build time. The servlet container (e.g. tomcat) should provide the servlet*.jar for you at runtime.
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
You are probably missing the commons logging jar. make it available, either in the webapp/WEB-INF/lib or container lib.

Related

Deploy multiple spring framework enabled web project and conflict

I have multiple Spring Framework enabled projects and try to deploy them into Tomcat.
If I deploy any single one, everything fine.
But if I deploy more than one projects, the deployment will fail from the second one.
Not sure if it caused by Spring or Tomcat. The error info related the Spring framework initialization.
Hope to know if it is a popular one.
Thanks in advance.
Log:
Nov 16, 2017 3:09:01 PM org.apache.catalina.core.StandardContext resourcesStart
Severe: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file
at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:136)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5247)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5436)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
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)
Nov 16, 2017 3:09:01 PM org.apache.catalina.core.ContainerBase addChildInternal
Severe: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/wshermesadminweb]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
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: org.apache.catalina.LifecycleException: Error in resourceStart()
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5437)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 10 more
Nov 16, 2017 3:09:01 PM org.apache.catalina.startup.HostConfig deployWAR
Severe: Error deploying web application archive C:\Users\chenhang.AUTH\Documents\Tools\apache-tomcat-7.0.77\webapps\wshermesadminweb.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].Standar
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
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)

Deployment Compound Projects using Utility Module With Hibernate 5 and Spring 4 in Eclipse on Tomcat failed

I decided to split the work to more modules in Eclipse Mars (Neon). One module is deployable as war REST Service. Using integrated Tomcat (version 8.0.41) to use: Right click on Server in Servers View -> Add and Remove causes:
15:42:21.104 [localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started
15:42:21.123 [localhost-startStop-1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Thu Jun 29 15:42:21 CEST 2017]; root of context hierarchy
15:42:21.201 [localhost-startStop-1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com.deepam.spring.config.AppRestConfig]
15:42:21.218 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotations(Class.java:3446)
at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:68)
at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:56)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:167)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:142)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:131)
at org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4851)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
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)
Jun 29, 2017 3:42:21 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotations(Class.java:3446)
at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:68)
at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:56)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:167)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:142)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:131)
at org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4851)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
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)
Jun 29, 2017 3:42:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Jun 29, 2017 3:42:21 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [201] milliseconds.
Jun 29, 2017 3:42:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/SpringOracleJDBCJPAREST] startup failed due to previous errors
Jun 29, 2017 3:42:21 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Jun 29, 2017 3:42:21 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:583)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4898)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5537)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:149)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
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)
If I the same .war file generated from Eclipse this way: Right click on Parent project -> Run as - Maven Install put into {Apache Tomcat Innstallation}/webaaps directory manually, it woks fine without errors. How can I setup Eclipse to enable automatic deployment without Context initialization failed errors?
P.S. One big project merged all together has no problem with deployment. It works fine as expected.
The solution is to undeploy .war file from Tomcat integrated environment and copy it straightforwardly into $tomcat_home/webapps deployment directory. Every setting can be as they previously were set. It means, Tomcat can be administrated from Eclipse as well. We can restart Tomcat from Eclipse, look on log using Console View etc.
I suppose, that Context needs some further configuration or it is a bug, but this workaround works fine.
There is only one limitation, that automatic deployment is not possible and Tomcat doesn't display deployed modules in View Servers.

Tomcat unable to start application

I have installed petclinic application in tomcat server. During tomcat start up and loading of petclinic application I am having the error with the followed stack trace. How to resolve this issue ?
apache-tomcat-7.0.47/webapps/petclinic
Oct 27, 2016 12:14:36 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error during ServletContainerInitializer processing
javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class at
org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:160)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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.deployDirectory(HostConfig.java:1120)
at
org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1678)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:483)
at java.util.concurrent.FutureTask.run(FutureTask.java:274) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:798) Caused by:
java.lang.NoClassDefFoundError:
org.glassfish.jersey.server.ResourceConfig at
java.lang.J9VMInternals.verifyImpl(Native Method) at
java.lang.J9VMInternals.verify(J9VMInternals.java:94) at
java.lang.J9VMInternals.initialize(J9VMInternals.java:169) at
java.lang.J9VMInternals.newInstanceImpl(Native Method) at
java.lang.Class.newInstance(Class.java:1781) at
org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:157)
... 12 more Caused by: java.lang.ClassNotFoundException:
org.glassfish.jersey.server.ResourceConfig at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 18 more
I think you didn't let spring know about some bean class.
Look at your context.xml or dispatcher-context.xml.
In the exception stack above,
it says java.lang.ClassNotFoundException occured.
Spring can't find class files even if you have them in your java src package.
If my answer doesn't solve your problem,
you need to show your xml or source code to make sure what the problem is.

Tomcat 7 fails to deploy on EC2 instance due to Exceptions

I have built my pedestal app according to following
https://github.com/pedestal/pedestal/blob/master/guides/documentation/service-war-deployment.md
and then I upload the .war file and deploy it.
however, when I ssh in to the ec2 instance I found that it did not deploy successfully even though it says so
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs durin$ May 31, 2016 2:09:52 AM org.apache.catalina.core.ContainerBase addChildInternal SEVERE: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:745) Caused by: java.lang.NoClassDefFoundError: org/apache/tomcat/util/descriptor/tld/TldParser
at org.apache.jasper.servlet.TldScanner.<init>(TldScanner.java:86)
at org.apache.jasper.servlet.JasperInitializer.newTldScanner(JasperInitializer.java:120)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5573)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.descriptor.tld.TldParser
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
... 15 more
May 31, 2016 2:09:52 AM org.apache.catalina.startup.HostConfig deployWAR SEVERE: Error deploying web application archive /var/lib/tomcat7/webapps/ROOT.war java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:745)
May 31, 2016 2:09:52 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deployment of web application archive /var/lib/tomcat7/webapps/ROOT.war has finished in 6,440 ms
May 31, 2016 2:09:52 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"]
May 31, 2016 2:09:52 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 31, 2016 2:09:52 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 6530 ms
I'm thinking this is pedestal specific because I successfully deployed a clojure ring web app packaged into war without problems.
From looking at the stack trace it seems that this class is missing: org/apache/tomcat/util/descriptor/tld/TldParser.
It is possible that the uber-war you are supplying still has Tomcat classes in it. The instructions you link to say to remove Tomcat dependencies:
[io.pedestal/pedestal.tomcat "0.1.0"]
I am guessing that EC2 supplies its own Tomcat, and if you were not supplying any conflicting classes, you would not be getting that error.
You can use any zip/archiving tool to look inside the war and verify that you have removed Tomcat completely: it is just a zip file after all.

Omnifaces exception on deployment on Tomcat 7

I'm trying to add Omnifaces 2.1 to a web application to use FullAjaxExceptionHandler and possibly other functionality in Omnifaces 2.1.
I've read and followed following post by BallusC and am still stuck:
How to install and use CDI on Tomcat?
Tried to install Weld 2.2.9.Final and configure as described above. I am using the following:
JSF 2.2, EL 2.2, Servlet 3, Java 7
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="{name}" version="3.0">
Upon startup I am still getting the following exception:
Catalina.log:
INFO: Starting service Catalina
Aug 09, 2015 8:57:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.56
Aug 09, 2015 8:57:18 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\xampp\tomcat\conf\Catalina\localhost\MITrace.xml
Aug 09, 2015 8:57:24 AM org.richfaces.webapp.ResourceServletContainerInitializer registerServlet
INFO: Auto-registered servlet ResourceServlet with mapping '/org.richfaces.resources/*'
Aug 09, 2015 8:57:24 AM org.omnifaces.ApplicationInitializer logOmniFacesVersion
INFO: Using OmniFaces version 2.1
Aug 09, 2015 8:57:26 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.6 ( 20140304-1537 https://svn.java.net/svn/mojarra~svn/tags/2.2.6#12949) for context '/MITrace'
Aug 09, 2015 8:57:27 AM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
Aug 09, 2015 8:57:27 AM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment:
java.lang.NoClassDefFoundError: Could not initialize class org.omnifaces.config.BeanManager
at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:69)
at org.omnifaces.application.OmniApplicationFactory.createOmniApplication(OmniApplicationFactory.java:89)
at org.omnifaces.application.OmniApplicationFactory.getApplication(OmniApplicationFactory.java:54)
at com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:93)
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:144)
at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:379)
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:721)
at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:553)
at javax.faces.FactoryFinder.access$500(FactoryFinder.java:140)
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1120)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1861)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:745)
Localhost.log:
Aug 09, 2015 10:28:23 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Aug 09, 2015 10:28:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Aug 09, 2015 10:28:27 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.omnifaces.ApplicationListener
java.lang.ExceptionInInitializerError
at org.omnifaces.ApplicationListener.checkCDIAvailable(ApplicationListener.java:63)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:55)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1861)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:745)
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.
at org.omnifaces.config.BeanManager.<init>(BeanManager.java:99)
at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:49)
... 15 more
Caused by: java.lang.IllegalStateException: javax.naming.NamingException: Cannot create resource instance
at org.omnifaces.util.JNDI.lookup(JNDI.java:92)
at org.omnifaces.config.BeanManager.<init>(BeanManager.java:95)
... 16 more
Caused by: javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:115)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.omnifaces.util.JNDI.lookup(JNDI.java:88)
... 17 more
The jar does indeed exist and has been added to the application.
What else could be causing this error?
Ok issue is now resolved. I can confirm the following for Apache Tomcat/7.0.56:
/META-INF/context.xml is not required however the resource entry is still required. To resolve the issue I added the resource entry in the following existing location: tomcat\conf\Catalina\localhost{resource-file-name}.xml
After that no errors appeared.
No related listeners need to be registered in web.xml
No related <resource-env-ref> are required in web.xml
/WEB-INF/beans.xml (empty) is required
Most of the above is covered here: http://balusc.blogspot.com.au/2013/10/how-to-install-cdi-in-tomcat.html
I wanted to provide an update to this though as some may find the resource loading part on tomcat helpful.
Thanks again BallusC. I've up-voted a similar post because the suggestion related to it helped me resolve this issue.

Resources