无法使用从相同maven原型创建的两个SpringMVC webapp启动Tomcat服务器 [英] Unable to start Tomcat server with two SpringMVC webapps that are created from same maven archetype

查看:97
本文介绍了无法使用从相同maven原型创建的两个SpringMVC webapp启动Tomcat服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

b
$ b

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

  2013年8月30日8:14:48 org.apache.catalina.core.ApplicationContext log 
INFO:初始化Spring FrameworkServlet'appServlet'

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

 线程main中的异常

我在logback.xml中启用了Spring日志级别DEBUG,它使用DEBUG和INFO编写了一堆日志消息,但是没有任何WARN或ERROR消息显示对内部发生的事情的任何了解。



找到一个解决方案?



添加日志作为建议ed

  2013年9月13日上午8:20:24 org.apache.catalina.core.AprLifecycleListener init 
INFO :在java.library.path中找不到基于APR的Apache Tomcat Native库,它允许在生产环境中获得最佳性能:C:\ Program \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中/服务器; C:/程序/的Java / jdk1.6.0_32 / bin中/../ JRE /箱; C:/Programs/Java/jdk1.6.0_32/bin /../的jre / lib中/ AMD64; C:\Python27; C:\\ \\Programs\Java\jdk1.6.0_32\bin; C:\Programs\apache-行家-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:\\\\\\\\\\\\\\\\\\\\\\\\\\产品\10.2.0\server\bin; C:\Windows\system32; C:\Wi ndows; C:\Windows\System32\Wbem; C:\ Windows \ System32\WindowsPowerShell\v1.0\; C:\ Program Files(x86)\Windows Live\Shared; C:\ Programs \\\\\\\\\\\\\\\\\\\\\\\\\
2013年9月13日上午8时20分24秒org.apache.tomcat.util.digester.SetPropertiesRule开始
警告:[SetPropertiesRule] {服务器/服务/引擎/主机/上下文}设置属性'源'to'org.eclipse.jst.jee.server:显示'没有找到匹配的属性。
2013年9月13日上午8时20分24秒org.apache.tomcat.util.digester.SetPropertiesRule开始
警告:[SetPropertiesRule] {服务器/服务/引擎/主机/上下文}设置属性'源'to'org.eclipse.jst.jee.server:com.maha.science.web'找不到匹配的属性。
2013年9月13日上午8时20分24秒org.apache.coyote.AbstractProtocol init
INFO:初始化ProtocolHandler [http-bio-7080]
2013年9月13日8:20 :24 AM org.apache.coyote.AbstractProtocol init
INFO:Initializing ProtocolHandler [ajp-bio-7009]
2013年9月13日上午8:20:24 org.apache.catalina.startup。 Catalina加载
INFO:在705毫秒中处理初始化
2013年9月13日上午8:20:25 org.apache.catalina.core.StandardService startInternal
INFO:启动服务Catalina
2013年9月13日上午8时20分25秒org.apache.catalina.core.StandardEngine startInternal
INFO:启动Servlet引擎:Apache Tomcat / 7.0.25
2013年9月13日上午8时20分31秒org.apache.catalina.core.ApplicationContext log
INFO:在类路径中检测到Spring WebApplicationInitializers:[com.maha.science.config.WebAppInitializer@c2854c7]
2013年9月13日上午8时20分31秒org .apache.catalina.core.ApplicationContext log
INFO:初始化Spring根WebApplicationContext
Sep 13,2013 8:20:35 AM org.ap ache.catalina.core.ApplicationContext log
INFO:初始化Spring FrameworkServlet'appServlet1'
线程main中的异常


解决方案

经过一段时间的努力后,这个问题终于得到解决,我写这从我的工作,希望它可以帮助其他人在类似的情况。 b
$ b

在使用logback进行实验时,xml
给出了有关实际错误的更多信息

  SEVERE:子容器在启动过程中失败
java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:PermGen空间$ b $在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)
在org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:293)
在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.ja va:150)

看起来像hibernate一样重要的webapp,spring和其他库有一个permgen空间问题,所以我添加VM参数到服务器如下

  -XX:MaxPermSize = 128m 

双击服务器并打开Launch Configuration在虚拟机参数部分添加上面的参数,这样做很神奇。



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



所以总结一下,只要我们设置-XX:MaxPermSize = 128m参数给服务器启动,我们就可以在一个tomcat服务器上运行多个webapps,而这些webapps是在同一个tomcat服务器上创建的,没有任何问题。


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" 

解决方案

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.

这篇关于无法使用从相同maven原型创建的两个SpringMVC webapp启动Tomcat服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆