1

I have created two Spring MVC applications using spring-mvc-quickstart-archetype (includes spring mvc, spring security, hibernate) , I could run each of this application seperately on tomcat but not able to together.

when I add both the projects on to Tomcat, server will not comeup, I get

Aug 30, 2013 8:14:48 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet'

then the next line is error in red text as below and then server gets terminated

Exception in thread "main" 

I enabled Spring log level to DEBUG on the logback.xml, it writes a bunch of log messages with DEBUG and INFO but nothing with WARN or ERROR that shows any insight into what is happening internally.

Has any body come accross this and have found a solution ?

Adding the log as suggested

Sep 13, 2013 8:20:24 AM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programs\Java\jdk1.7.0_21\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Programs/Java/jdk1.6.0_32/bin/../jre/bin/server;C:/Programs/Java/jdk1.6.0_32/bin/../jre/bin;C:/Programs/Java/jdk1.6.0_32/bin/../jre/lib/amd64;c:\Python27;C:\Programs\Java\jdk1.6.0_32\bin;C:\Programs\apache-maven-3.0.4\bin;c:\Programs\mongodb243\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Programs\eclipse-jee-juno -with-SpringToolSuit;;.
Sep 13, 2013 8:20:24 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shows' did not find a matching property.
Sep 13, 2013 8:20:24 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:com.maha.science.web' did not find a matching property.
Sep 13, 2013 8:20:24 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-7080"]
Sep 13, 2013 8:20:24 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-7009"]
Sep 13, 2013 8:20:24 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 705 ms
Sep 13, 2013 8:20:25 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 13, 2013 8:20:25 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Sep 13, 2013 8:20:31 AM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath:   [com.maha.science.config.WebAppInitializer@c2854c7]
Sep 13, 2013 8:20:31 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 13, 2013 8:20:35 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet1'
Exception in thread "main" 
Venkat
  • 1,229
  • 1
  • 15
  • 23

2 Answers2

1

Venkat,

You need to specify a different root key for each app.

If you're using XML-configuration, then use Karthikenyan's approach, specifying a different value in each web.xml:

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>thisisdistinctforeachwebapp</param-value>
</context-param>

If you're using an XML-free configuration (implementing WebApplicationInitializer), it's as easy as one line:

servletContext.setInitParameter("webAppRootKey", "thisisdistinctforeachwebapp"); 

HTH

bz3x
  • 171
  • 4
  • 15
  • Thanks for detailed answer, for some reason I am still getting the Exception in thread "main" the quickstart contains spring security, hibernate integrated too, could this be causing the issue ? – Venkat Sep 12 '13 at 13:58
  • I dont see any error message, except the Exception in Thread main , I published the log i am getting in the Question now – Venkat Sep 13 '13 at 12:28
  • How about those warnings in the logs? http://stackoverflow.com/questions/104854/setpropertiesrule-warning-message-when-starting-tomcat-from-eclipse Otherwise you need to get more detailed info on the root of the exception. Check Tomcat's logs as well as the application's. – bz3x Sep 13 '13 at 15:57
0

After struggling for sometime this issue finally got resolved, i am writing that worked from me hoping it would help others in similar scenarios.

while experimenteing with logback,xml has given more info on the actual error

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1130)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:293)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

looks like the webapp being heavy with hibernate, spring and other libraries is having a permgen space issue, so i added the VM argument to server as below

-XX:MaxPermSize=128m

Double Click on Server and open Launch Configuration add the above param on VM arguments section, this did the magic.

I have reverted the earlier changes of giving a unique servlet name for appServlet and removed the unique webAppRootKey as context param and it works still.

So to summarize we can run multiple webapps that are created from the same maven quickstart on one tomcat server without any issues as long as we set-XX:MaxPermSize=128m param to server startup.

Venkat
  • 1,229
  • 1
  • 15
  • 23