发生InvocationTargetException:Play框架中为null

时间:2011-09-20 07:40:06

标签: java error-handling playframework

我正在为我的应用程序使用play框架 在我的application.conf中,我已经给出了

jvm.memory=-Xmx512M -Xms512M -XX:-UseGCOverheadLimit

我有一个功能,将为每个客户和每个microapp的客户执行 此函数将返回该客户的记录以及来自DB的该微应用程序。

如果我为所有客户运行,我将为第16位客户获取InvocationTargetException。(对于15位客户,它已成功运行)。

错误是

12:38:30,153 ERROR ~ 


Execution exception
InvocationTargetException occured : null

play.exceptions.JavaExecutionException
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:230)
        at Invocation.HTTP Request(Play!)
Caused by: java.lang.reflect.InvocationTargetException
        at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:475)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)
        ... 1 more
Caused by: java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.lang.StringValue.from(Unknown Source)
        at java.lang.String.<init>(Unknown Source)
        at com.mysql.jdbc.SingleByteCharsetConverter.toString(SingleByteCharsetConverter.java:327)
        at com.mysql.jdbc.ResultSetRow.getString(ResultSetRow.java:787)
        at com.mysql.jdbc.BufferRow.getString(BufferRow.java:539)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5571)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5448)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5488)
        at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
        at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:229)
        at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:330)
        at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2283)
        at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)
        at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)
        at org.hibernate.loader.Loader.getRow(Loader.java:1355)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
        at org.hibernate.loader.Loader.doQuery(Loader.java:829)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)

我发现该客户存在错误。所以我独自为那个客户而战。我正在

Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
        at java.util.jar.Manifest.read(Unknown Source)
        at java.util.jar.Manifest.<init>(Unknown Source)
        at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
        at java.util.jar.JarFile.getManifest(Unknown Source)
        at sun.misc.URLClassPath$JarLoader$2.getManifest(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run(ThreadPoolAsynchronousRunner.java:633)
        at java.util.TimerThread.mainLoop(Unknown Source)
        at java.util.TimerThread.run(Unknown Source)
Exception in thread "pool-2-thread-1" java.lang.OutOfMemoryError: Java heap space


For this microapp( Error occuring ) alone i have 421,251 records

可能是错误的根源。请帮帮我。

1 个答案:

答案 0 :(得分:0)

您的问题是OutOfMemory错误。当你因为这个原因增加ram时会发生这种情况。

您没有提供任何代码示例,但我假设您尝试仅使用一个查询从客户端加载太多数据。有关421k记录的评论确认了这一点(除非我误解)。

不是做一个find()(或select,或者你正在做的cal)来检索所有记录,而是尝试批量检索记录(100,200)并以这种方式处理它们。