我正在将我的Spring依赖注入从XML声明迁移到注释样式。
但是现在我已经迁移了DAO,服务和控制器,服务器将不再启动:
java.lang.OutOfMemoryError: Java heap space
我可以在stacktrace中看到(见下文)有一个BeanCreationException,但我不知道是哪一个,因为在BeanCreationException的消息构造中发生了OutOfMemory异常。
我已经尝试增加-Xmx和-XX:MaxPermSize JVM的参数,但我相信它就像一个无限循环或类似的东西。在迁移到注释之前,该应用程序运行良好。
您是否知道如何知道问题的来源?
版本:Hibernate 3.1,Spring 2.5,Tomcat 7,JDK 7
典型的applicationContext.xml内容(之前):
<bean id="fooDAO" class="foo.bar.fooDAO">
<property name="sessionFactory">
<ref bean="foo_factory" /> //extends LocalSessionFactoryBean
</property>
</bean>
<bean id="fooService" class="foo.bar.fooService">
<property name="foodDAO" ref="fooDAO" />
</bean>
<bean id="fooControler" class="foo.bar.fooControler" autowire="byName">
<property name="fooService" ref="fooService" />
</bean>
迁移后:
DAO上的@Repository,服务上的@Service和控制器上的@Controller。
StackTrace:
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1239)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2367)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]