1

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.

Benjamin
  • 53
  • 1
  • 8
  • You'll need to post the whole stack trace to get any decent responses. – Christopher Schultz Aug 10 '12 at 14:18
  • 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 Aug 10 '12 at 14:23
  • 1
    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 Aug 13 '12 at 22:25
  • 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 Aug 16 '12 at 12:29
  • Google is your friend: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html – Christopher Schultz Aug 17 '12 at 18:35
  • I'm surprised that you don't get a better error message: a stack that is too small should result in a StackOverflowErorr or something similar. Maybe a component is swallowing an exception somewhere. – Christopher Schultz Aug 17 '12 at 18:37
  • Yeah. I agree with you. That's why I have used a lot of time to find the reason for the error. The error message is misleading! – Benjamin Aug 20 '12 at 01:53
  • Just a heads up: If your using Scala you'll want an even bigger -Xss. – Adam Gent Aug 21 '12 at 02:06

1 Answers1

1

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.

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77