端口 80 上的 Tomcat 因 OutOfMemoryError 而失败,而端口 8080 上的 Tomcat 正常运行

端口 80 上的 Tomcat 因 OutOfMemoryError 而失败,而端口 8080 上的 Tomcat 正常运行

我有一台 Linux 服务器(Ubuntu 11.10 x64)。

我在端口上运行 Tomcat80用户。它只有应用程序(大约 8Mbs)。每当我启动 tomcat 时,我都会得到内存不足错误。(此 Tomcat 的目的是处理域、子域并将它们转发到相应的应用程序。更清楚一点,当我点击“子域名.com”,它被转发到应用程序“sub”

有趣的是,相同的服务器,我创建了一个新用户,然后我安装了雄猫配置为在端口上运行8080.我部署了3 个应用(总共 40 Mbs),启动完美!我无法用这台服务器处理域,因为它不在端口 80 上运行,所以对我来说不太好。

为什么会发生这种情况?我该怎么做才能让 tomcat 在端口 80 上运行?

以下是 catalina.out 的 tomcat 日志输出

    INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans metho                                                                                        ds marked with these annotations will have said annotations processed.
Nov 09, 2012 4:21:26 PM org.primefaces.webapp.PostConstructApplicationEventListe                                                                                        ner processEvent
INFO: Running on PrimeFaces 3.4.RC1
Nov 09, 2012 4:21:26 PM com.sun.faces.config.ConfigureListener$WebConfigResource                                                                                        Monitor$Monitor <init>
INFO: Monitoring jndi:/stk.meselen.com/WEB-INF/faces-config.xml for modification                                                                                        s
Nov 09, 2012 4:21:45 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [19,497] milliseconds.
Nov 09, 2012 4:21:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory stk
Nov 09, 2012 4:21:45 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/stk/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Nov 09, 2012 4:21:51 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.7 (SNAPSHOT 20120206) for context '/stk'
Nov 09, 2012 4:21:52 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
Nov 09, 2012 4:21:53 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 3.4.RC1
Nov 09, 2012 4:21:53 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFO: Monitoring jndi:/stk.meselen.com/stk/WEB-INF/faces-config.xml for modifications
Nov 09, 2012 4:21:53 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml from /etc/tomcat7/Catalina/www.meselen.com
Nov 09, 2012 4:21:53 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml from /etc/tomcat7/Catalina/www.meselen.com
Nov 09, 2012 4:21:53 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory stk
Nov 09, 2012 4:21:54 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/stk/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
        at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2006)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1969)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1858)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1826)
        at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1812)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1306)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1055)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:978)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1329)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:389)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:334)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)

以下是 ulimit -a 的输出

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15675
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 15675
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

答案1

我发现问题是由于 2 个主机使用相同的 appBase。所以我更改了主机的 server.xml 中的 appBases。现在运行正常。

相关内容