1
votes

I modified the init script of tomcat(catalina.sh)——set the JAVA_OPTS as below : JAVA_OPTS="-server -Xms8g -Xmx8g -Xmn3g -Xss128K -Dj ava.awt.headless=true". Then I started the tomcat and its log got this Spring ERROR:

"2012-08-10 16:40:20.697 ERROR Context initialization failed java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCreationException"

But before I set JAVA_OPTS, it worked fine. Why did this happen? What should I do? Thanks a lot.

The whole stack trace is: 2012-08-10 16:40:20.697 ERROR Context initialization failed java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCreationException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:593) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

The JAVA_OPTS configuration is the old configuration and it is not written by me.

1
You'll need to post the whole stack trace to get any decent responses. - Christopher Schultz
Do you really need to set the size of the "young" generation? That seems like a very large young generation to me. Same with the thread stack size: do you really need to set those? - Christopher Schultz
Thanks for your comment. - Benjamin
Remove all of those options from JAVA_OPTS and add them back one-at-a-time to see which one triggers the error. Also, better to use CATALINA_OPTS instead of JAVA_OPTS because the latter will be used even when launching the JVM that simply sends the "shutdown" message to Tomcat. - Christopher Schultz
Sorry for my late. I used your method:"Remove all of those options from JAVA_OPTS and add them back one-at-a-time." I see the reason is the option "-Xss128K". Only remove this option and reserve other options,then it will work fine. So what is the default value of the option "-Xss"? Did I set it too small? My environment: OS: Ubuntu 10.04 64bit JAVA: java version "1.6.0_06" Java(TM) SE Runtime Environment (build 1.6.0_06-b02) Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode) Tomcat: 6.0.24 Thanks a lot! - Benjamin

1 Answers

1
votes

You have evidently set your thread stack size too small. Unless you have a good reason for doing so, don't modify the thread stack size at all.