首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Tomcat部署两个相同工程遇到有关问题及解决方案汇总

2012-09-02 
Tomcat部署两个相同工程遇到问题及解决方案汇总一、我写了2个用了struts2的项目。若我把这2个项目全部部署在

Tomcat部署两个相同工程遇到问题及解决方案汇总
一、
我写了2个用了struts2的项目。
若我把这2个项目全部部署在tomcat里,会出现这样的异常

严重: Exception starting filter struts2Unable to load configuration. - [unknown location]    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:213)    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)    at org.apache.catalina.core.StandardService.start(StandardService.java:448)    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Caused by: Caught exception while loading file struts-default.xml - [unknown location]    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:879)    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:161)    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:130)    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:155)    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)    ... 30 moreCaused by: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)    at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)    at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)    at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:69)    at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:212)    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:197)    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:188)    at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:174)    at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:114)    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:870)    ... 34 more2008-7-25 8:09:32 org.apache.catalina.core.StandardContext start严重: Error filterStart2008-7-25 8:09:32 org.apache.catalina.core.StandardContext start严重: Context [/workmass] startup failed due to previous errors2008-7-25 8:09:32 org.apache.coyote.http11.Http11AprProtocol start


但是如果我只部署一个项目 一切没问题。部署任何一个都没问题。但是只要2个一起部署,启动猫就出现上面的错误;

解决方案:
1.删除xerce.jar
2.web.xml里的这个配置,我居然在两个项目里用的一样的,param-value换下就ok了,保证两个项目里不一样
 <context-param><param-name>webAppRootKey</param-name><param-value>CITYSPACESystem.root</param-value></context-param>


参考:
http://www.nabble.com/org.apache.xerces.parsers.XML11Configuration-cannot-be-cast-to-org.apache.xerces.xni.parser.XMLParserConfiguration-td14108368.html

二、
java.lang.OutOfMemoryError: PermGen space及其解决方法
PermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决方法也一定是加大内存。说说为什么会内存益出:这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入PermGen space区域,它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误。这种错误常见在web服务器对JSP进行pre compile的时候。
内存溢出。
如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误,
这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下使用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)
那么就会产生此错误信息了。

解决方法: 手动设置MaxPermSize大小
修改TOMCAT_HOME/bin/catalina.sh

在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m 


补充一下Windows下的做法:
设置环境变量JAVA_OPTS=-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m
即可,java.lang.OutOfMemoryError: PermGen space的问题以前经常遇到,现在可以对付了

热点排行