无法与从同一Maven原型创建了两个web应用用SpringMVC启动Tomcat服务器(Unabl

2019-10-18 14:24发布

我创建了使用弹簧MVC-快速入门 - 原型(包括Spring MVC的,春天的安全性,休眠),我可以运行各该应用程序的seperately Tomcat上,但不能在一起的两个Spring MVC应用。

当我到Tomcat添加两个项目,服务器将不会川方,我得到

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

再下一行是错误的红色文字下方,然后服务器被终止

Exception in thread "main" 

我启用了春天日志级别为DEBUG的logback.xml,它写了一堆日志消息与DEBUG和INFO,但没有与WARN或错误显示任何见识到了什么是内部发生的事情。

是否有任何身体来翻过这一点,并找到了解决办法?

添加日志的建议

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" 

Answer 1:

Venkat,

你需要为每个应用程序不同的根密钥。

如果您使用XML配置,然后使用Karthikenyan的做法,在每个web.xml中指定不同的值:

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

如果您使用的是免费的XML配置(实现WebApplicationInitializer),这是作为一个行一样简单:

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

HTH



Answer 2:

挣扎了一段时间这个问题终于得到解决后,我写的是从我的工作,希望这将有助于其他处于类似的情况。

而具有的logback experimenteing,XML已经给实际错误的详细信息

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)

看起来像web应用程序是沉重与休眠,春季和其他库是有一个PermGen的空间的问题,所以我说的VM参数服务器如下

-XX:MaxPermSize=128m

双击服务器,并打开启动配置上加上VM参数部分上述PARAM,这确实神奇。

我已经恢复早先给予了appServlet唯一的servlet名称的更改并删除了独特webAppRootKey作为上下文PARAM和它的作品依然。

因此,要总结,我们可以没有任何问题,只要我们设置-XX运行从一个Tomcat服务器在同一个Maven快速创建多个web应用:MaxPermSize参数=128米参数去服务器启动。



文章来源: Unable to start Tomcat server with two SpringMVC webapps that are created from same maven archetype