Manage TomEE libs loading order - java

I have an EJB application that is currently deployed on TomEE 1.7.4 with OpenJDK 7 inside a docker container (openjdk 7, TomEE, and my war).
Note: The Jar files that I added within TomEE lib folder are reconized by the application, because I had some errors that has been solved after adding those Jar files.
The error log
INFO: PersistenceUnit(name=manager1, provider=org.hibernate.jpa.HibernatePersistenceProvider) - provider time 2214ms
Apr 25, 2018 5:35:21 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeploying app: /usr/local/tomee/webapps/myapp
Apr 25, 2018 5:35:21 PM org.apache.catalina.core.ContainerBase removeChild
SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]] in state [STARTING_PREP]
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:401)
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:291)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1038)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1537)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1518)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:762)
at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:1982)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:839)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
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:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:748)
Apr 25, 2018 5:35:21 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]
org.apache.openejb.OpenEJBException: Creating application failed: /usr/local/tomee/webapps/myapp: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:843)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
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:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:973)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:64)
at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:116)
at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:102)
at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:154)
at org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:982)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:741)
List of Jar added to TomEE lib folder:
mysql:mysql-connector-java:5.1.22
org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
org.hibernate:hibernate-entitymanager:4.3.9.Final
org.hibernate:hibernate-core:4.3.9.Final
org.hibernate.common:hibernate-commons-annotations:4.0.5.Final
org.jboss:jandex:1.1.0.Final
org.jboss.logging:jboss-logging:3.1.3.GA
org.javassist:javassist:3.18.1-GA
antlr:antlr:2.7.7
dom4j:dom4j:1.6.1
Although, I tried to deploy other apps within this docker image and every think works as expected.

TLDR; your TomEE version does not support the apis you seem to be using.
I would go with upgrading TomEE, so you would get proper support for the apis you want to use. Other solutions are just workarounds that might break in numerous ways as they are not supported.
A bit longer answer:
This looks java app dependency problem/version conflict for me: see this thread for similar error message and its cause. The dependencies you've added depend on javax.persistence spec 2.1, but based on the stack trace your app seems to be using older apis.
You seem to want to use Java Persistence API 2.1, that comes with Java EE 7. Java EE 6 contains Java Persistence API 2.0.
Version of TomEE you're using, Apache TomEE 1.7.4, supports only Java EE 6 and thus Persistence API 2.0, and it was last version not supporting Java EE 7:
From this point on the TomEE community will be focusing most of it's efforts on TomEE 7.0.0, which will be the first TomEE Java EE 7 driven version running on Apache Tomcat 8.x.
So an upgrade of TomEE would be in order.

TomEE comes with OpenJPA as persistence engine.
You can change to Hibernate but you have to follow this guide
Extending the ClassPath is a bad solution although it does the job.

I fugured it out, the solution is to create a "setenv.sh" file in TomEE bin directory with the CLASSPATH of the "jpa 2.1" jar file.
setenv.sh
#!/bin/sh
CLASSPATH=/usr/local/tomee/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar

Related

ClassNotFoundException: HttpServletRequest with Struts2 in Eclipse

I have 2 versions of a project (GIT), the oldest (work perfectly) and the new one commited (don't work - issue below).
Here the error I have in Eclipse :
août 18, 2020 4:22:24 PM org.apache.catalina.core.StandardContext filterStart
GRAVE: Exception au démarrage du filtre struts2
java.lang.NoClassDefFoundError: HttpServletRequest
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.getActionAnnotations(PackageBasedActionConfigBuilder.java:877)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:689)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:355)
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:274)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4583)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: HttpServletRequest
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
... 27 more
The GRAVE: Exception au démarrage du filtre struts2 can be translated in SEVERE: Exception in start of struts2 filter
I saw this answer java.lang.ClassNotFoundException: HttpServletRequest but I have already not servlet-api in the WEB-INF/lib folder but in the Tomcat/lib. And I have exactly the same .jar between the current modified project and the old one.
What can I do about this ?
The error comes from the convention plugin. This plugin is used to create additional configuration objects by convention. If you havily use annotations to define Java based configuration for struts actions then it invokes a reflection mechanism to process creating runtime configuration elements.
The NoClassDefFoundError says that you missing some classes on the classpath of the current classloader. Usually it fixed by adding missing jar to the classpath.
It could be ignored if your application used different classloader than a servlet container is used. Tomcat is a servlet container which is using multiple classloaders in the multithreaded pool. It could also have bugs the one had discovered in the 8.x version.
In many ways missing classes in the broken servlet environment leads to change/update the servlet container itself and download correct dependencies from the Maven central repository.
I finally found a solution but I hesitated to post because I don't know how I did that.
I was trying this :
Duplicate the existing Eclipse server into another folder.
Create a new server in the Servers view in Eclipse with the new folder.
Click-right on the new server -> Clean and Clean Tomcat Work Directory...
Go to Run -> Run configurations
Totally random action :
Double click on one of the server
The server instance start. Stop it. Restart your project. The problem has disappeared.
I think a clean publish is what I needed but we will never know..

Trying to run the RSA SDK under Tomcat 8

Java newbie here.
Working on a some java App that uses the RSA SDK 8.2. All applications work fine when run as a console application. We're need to put a Web front end on it but we error out as shows below.
We've tried running it on both Wildfly 10 and Tomcat 8.0. Using Java 1.8
Below is error received when running on Tomcat. The error of NoSuchMethodException below from org.glassfish.tyrus.server.TyrusServerConfiguration.()
This exists in one of the Jars provided in the SDK. If we remove the jar Tomcat will serve up the page but will fail when a call to the SDK is made. If we include the jar, we get the error below.
SEVERE: Error during ServletContainerInitializer processing<br>
javax.servlet.ServletException: java.lang.InstantiationException: org.glassfish.tyrus.server.TyrusServerConfiguration<br>
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:88)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
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)
Caused by: java.lang.InstantiationException: org.glassfish.tyrus.server.TyrusServerConfiguration
at java.lang.Class.newInstance(Class.java:427)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:74)
... 8 more
Caused by: java.lang.NoSuchMethodException: org.glassfish.tyrus.server.TyrusServerConfiguration.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 9 more
Sep 26, 2017 3:00:39 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/tomcattest3] startup failed due to previous errors
I was able to duplicate this problem using Tomcat 9. I added websocket-ri-bundle-1.1.jar to Tomcat's lib without realizing that it already contained websocket-api-jar. When I removed the ri bundle I no longer got the error.

Spring Configuration Class Processor Error with Tomcat 7

I'm trying to set up tomcat 7.0.57(JDK 1.7.0_71) to run a web application, in Eclipse Luna.The web app involves Spring annotation based bean configuration. I've added the webapp to the server, and tried to publish the server but I get this error:
0 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.IllegalStateException: Cannot load configuration class: com.zzz.BeanConfigForDev
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:371)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:246)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:626)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
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:1859)
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.IllegalArgumentException: class com.zzz.BeanConfigForDev$$EnhancerByCGLIB$$216e920d is not an enhanced class
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:621)
at net.sf.cglib.proxy.Enhancer.registerStaticCallbacks(Enhancer.java:594)
at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:151)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:108)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:361)
There is no issue in the annotations used in the code as the same setup with similar set of jar is working in other systems. With my initial analysis I doubt the issue is with the versions of cglib and asm used. Have tried with latest versions of these jars and also with cglib_nodep but getting same issue. Here is my classpath config.
http://i.stack.imgur.com/oHvOT.png
On debugging, I see cglib.Enhancer is failing because of NoSuchMethodException while operating on the configuration proxy. Any idea on the possible causes for NoSuchMethodException in this specific scenario ?
I don't know what is causing this problem, but I solved it by switching to Tomcat 7.0.29

upgrading of Birt to 4.3.2 --->org.eclipse.birt.report.exception.ViewerException: Fatal error occurred when try to startup report engine

I am working with BIRT from 2 months,
while upgrading from Birt3.2.20 to Birt4.3.2 I have faced bellow exception from Tomcat 7
in my J2EE application, to upgrade from Birt3.2.20 to Birt4.3.2 I came to know just replacing the old jar files in "Plugins" folder of application with new jar files from
birt-runtime-4_3_2\ReportEngine\lib folder jar files.
After doing the same I have restarted my Tomcat 7 which throws bellow error
INFO: Deploying web application archive D:\Suneel\apache-tomcat-7\webapps\CADBReports.war
May 07, 2014 4:30:14 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.eclipse.org/birt/taglibs/birt.tld is already defined
org.eclipse.birt.report.exception.ViewerException: Fatal error occurred when try to startup report engine.
at org.eclipse.birt.report.service.ReportEngineService.setEngineContext(ReportEngineService.java:328)
at org.eclipse.birt.report.service.BirtViewerReportService.setContext(BirtViewerReportService.java:1022)
at org.eclipse.birt.report.listener.ViewerServletContextListener.contextInitialized(ViewerServletContextListener.java:62)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
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.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
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:744)
I have just replaced old jar's with new jar's in Birt 4.3.2 runtime/lib --- is this enough to upgrade or anything else needed.
I am using
Eclipse,
Tomcat 7,
Jsp.
Pls help me on this.
Are the reports embedded in your application or do you have Birt installed in Tomcat and just call the urls from your application?
In order to update your BIRT Installation, follow this steps:
1.Close Eclipse.
2.In your Eclipse plugins directory, delete all directories that start with "org.eclipse.birt".
3.Install the new BIRT version.
4.Restart Eclipse with the -clean option: eclipse -clean
If you have BIRT installed in Tomcat, you need to undeploy it, then install the new version. Here is the link with the install steps.

Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies

My app is quit big and using many jars and tools.
Platform - windows 2008 server, Spring , hibernate, Quarts, mysql, tomcat-7.35
When I deploy and start the server first time working perfectly,
but If I restart I am getting the below err
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
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.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
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:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/TestProject]. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2109)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1981)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1947)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1932)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1326)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
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:5179)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.StackOverflowError
at java.util.HashSet.<init>(HashSet.java:103)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2252)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
Feb 16, 2013 12:16:10 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory C:\apache-tomcat-7.0.35\webapps\TestProject
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[TestProject]]
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.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
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:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
The stack trace says that tomcat is running out of stack space on the thread that is scanning your application looking for java based servlet configurations. There are three ways you can solve this problem.
Increase the stack size -Xss4m
Tell Tomcat not to scan your application if you are not using any java based Servlet configuration add metadata-complete="true" to your web-app in web.xml
Restrict what jar files tomcat scans. see http://tomcat.apache.org/tomcat-7.0-doc/config/jar-scanner.html
Update 1
you need to pass -Xss4m to your jvm to set the stack size, -Xss10m would set it to 10mb.
I am using Hibernate and Spring in my application too with annotations, the scanning that tomcat does is to look for Servlet 3.0 annotations so you can still restrict things while using hibernate and spring annotations, since hibernate and spring annoations are scanned for by spring and hibernate.
If you are running tomcat as a windows service you will need, to pass the arguments via procrun since that is the executable that is launching the jvm. The docs for procrun are at http://commons.apache.org/daemon/procrun.html. tomcat7.exe is really procrun.exe renamed, which means that all your jvm options are written to the registery under
The basic Service definitions are maintained under the registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
Additional parameters are stored in the registry at:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\ProcRun
2.0\\Parameters
On 64-bit Windows procrun always uses 32-bit registry view for storing
the configuration. This means that parameters will be stored inside:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software
Foundation\ProcRun 2.0\
Update 2
Tomcat has been tweaking how the scanner works between point releases. try rolling forward through the versions 7.25,7.26 ... etc to find the version at which it breaks, the go through the release notes for that version to see if they changed how the scanner works.
Another thing you can try doing, is to create another war file which has all the third party jars in your WEB-INF\lib but not your code. See if you get that error if you start up, and if you do then should file a bug report with tomcat and make available to them your sample project that replicates the problem, on github or some other free code hosting system. I am sure if there is a bug they will fix it.
To fix this for TC Server 2.9, running Tomcat 7.0.39 I restricted the jars to skip during startup for the context config using:
org.apache.catalina.startup.ContextConfig.jarsToSkip=*.jar
in catalina.properties.
In My case iTextpdf JAR(5.06 version) causing problem as it had dependancy on org.bouncyCastle.*.jar and it was creating cyclic dependancy.
After updating it to 5.5.6 version, worked perfectly.
If you are adding maven dependancy , clean and update maven project.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.6</version>
</dependency>
I'm not running Tomcat as a Windows service, so to pass -Xss10m through, I edited catalina.bat, towards the bottom:
:doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -Xss10m -classpath "%CLASSPATH%" -
Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end

Categories

Resources