我正在通过 build.xml 在 Jenkins 中运行 Junit 测试用例。当我运行特定的测试用例时,出现以下错误。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 Java heap space</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /url. Reason:
<pre> Java heap space</pre></p><h3>Caused by:</h3><pre>java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
at java.lang.StringBuilder.append(StringBuilder.java:119)
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:410)
at java.lang.Long.valueOf(Long.java:525)
at org.codehaus.jettison.mapped.DefaultConverter.convertToJSONPrimitive(DefaultConverter.java:39)
at org.codehaus.jettison.mapped.MappedNamespaceConvention.convertToJSONPrimitive(MappedNamespaceConvention.java:282)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter$JSONPropertyObject.withProperty(MappedXMLStreamWriter.java:153)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter$JSONProperty.withProperty(MappedXMLStreamWriter.java:66)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeEndElement(MappedXMLStreamWriter.java:247)
at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.endTag(XMLStreamWriterOutput.java:144)
at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:120)
at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:326)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1041)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1020)
at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:252)
at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:121)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:155)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:324)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
下面是我用来运行 junit 测试用例 build.xml 的 build.xml 代码
<target name="runTests">
<junit fork="yes" forkmode="once" printsummary="yes" dir="${basedir}" includeantruntime="yes" failureproperty="failureTest" maxmemory="1024m" jvm="">
<jvmarg value="-XX:MaxPermSize=512M"/>
<jvmarg value="-Dlog4j.configuration=log4j.properties"/>
但是此错误仅在特定系统中发生,而不是在所有环境中发生。我怎样才能摆脱这个?