一尘不染

无法使用从同一Maven原型创建的两个SpringMVC Web应用程序启动Tomcat服务器

tomcat

我已经使用spring-mvc-quickstart-archetype(包括spring mvc,spring
security,hibernate)创建了两个Spring MVC应用程序,我可以在tomcat上分别运行每个应用程序,但不能一起运行。

当我将两个项目都添加到Tomcat时,服务器不会出现问题,我得到

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

然后下一行是红色文本中的错误,如下所示,然后服务器终止

Exception in thread "main"

我在logback.xml上将Spring日志级别启用为DEBUG,它使用DEBUG和INFO编写了一堆日志消息,但没有用WARN或ERROR编写任何日志消息,从而无法显示内部情况。

有没有人遇到这个问题并找到了解决方案?

根据建议添加日志

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"

阅读 304

收藏
2020-06-16

共1个答案

一尘不染

经过一段时间的努力,这个问题终于解决了,我正在写这篇对我有用的文章,希望它能对类似情况的其他人有所帮助。

在尝试logback的同时,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应用程序因hibernate,弹簧和其他库而沉重,存在permgen空间问题,因此我将VM参数添加到服务器,如下所示

-XX:MaxPermSize=128m

双击Server并打开Launch Configuration在VM arguments部分添加以上参数,这确实神奇。

我已经还原了为appServlet提供唯一的servlet名称的早期更改,并删除了唯一的webAppRootKey作为上下文参数,它仍然可以正常工作。

综上所述,只要我们将XX:MaxPermSize =
128m参数设置为服务器启动,就可以在一台tomcat服务器上运行从同一Maven快速入门创建的多个webapp,而不会出现任何问题。

2020-06-16