`
qtlkw
  • 浏览: 299827 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Hudson: java.lang.OutOfMemoryError: Java heap space error

阅读更多
运行hudson时,运用cobertura产生coverage reports,每当运行到最后都会报:
FATAL: Java heap space
java.lang.OutOfMemoryError: Java heap space

对在Hudson平台上运行的job下的Java Options对应处加上-Xms128m -Xmx512m条件,问题依然得不到解决。("-Xms128m -Xmx512m"?)

ant script:
<?xml version="1.0"?>
<project name="GEHGUIUT" default="all" basedir=".">

    <!-- Dir of the ant properties file -->
    <property name="ant.properties.dir"	value="."/>
	
	<!-- put in the properties. -->
	<property file="${ant.properties.dir}/ant_ut.properties"/>
	<property name="testclassname" value="*"/>
	
	<path id="src.classpath">
		<pathelement location="${tpcl}/OlderVersions/struts.jar"/>
    	<pathelement location="${tpcl}/OlderVersions/weblogic.jar"/>
    	<pathelement location="${tpcl}/icjava621.jar"/>
    	<pathelement location="${tpcl}/tibrvj.jar"/>
    	<pathelement location="${tpcl}/tibrjms.jar"/>
    	<pathelement location="${tpcl}/log4j-1.2.8.jar"/>
    	<pathelement location="${tpcl}/xml-apis.jar"/>
    	<pathelement location="${tpcl}/xercesImpl.jar" />
    	<pathelement location="${tpcl}/castor-0.9.7-xml.jar"/>
    	<pathelement location="${tpcl}/jgroups-all.jar"/>								
    	<pathelement location="${tpcl}/saaj.jar"/>				
    	<pathelement location="${tpcl}/axis-ant.jar"/>				
    	<pathelement location="${tpcl}/commons-discovery-0.2.jar"/>				
    	<pathelement location="${tpcl}/jaxrpc.jar"/>				
    	<pathelement location="${tpcl}/axis.jar"/>				
    	<pathelement location="${tpcl}/wsdl4j-1.5.1.jar"/>
    	<pathelement location="${tpcl}/xalan.jar"/>
    	<pathelement location="${tpcl}/joda-time-1.5.2.jar"/>
	</path>
	
	<path id="test.classpath">
		<fileset dir="${tpcl}/utest">
			<include name="junit-4.6.jar"/>
			<include name="mock.jar"/>
			<include name="ojdbc14.jar"/>	
		</fileset>
		<fileset dir="${tpcl}">
			<include name="commons-collections.jar"/>
			<include name="commons-dbcp-1.1.jar"/>
			<include name="commons-pool-1.1.jar"/>
			<include name="jms.jar"/>
		</fileset>
	</path>
	
	<path id="cobertura.classpath">
		<fileset dir="${tpcl}/utest/cobertura">
			<include name="*.jar" />
		</fileset>
		<path refid="src.classpath"/>
		<path refid="test.classpath"/>
	</path>
	
	<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
	<!-- Delete all directories -->
	<target name="cleanup">
		<tstamp/>
		<delete dir="${builddir}"/>
		<!--delete dir="${javadoc}"/ -->
	</target>
	

	<!-- Create directories -->
	<target name="init" depends="cleanup">
		<tstamp/>
		<mkdir dir="${builddir}"/>
		<!--mkdir dir="${javadoc}"/ -->
	</target>
	
	<target name="inittest">
		<delete dir="${testdir}" />
		<mkdir dir="${testdir}" />
		<mkdir dir="${testdir}/reports/junitxml" />
		<mkdir dir="${testdir}/reports/junithtml" />
		<mkdir dir="${testdir}/reports/coveragexml" />
		<mkdir dir="${testdir}/reports/coveragehtml" />
	</target>
	
	<!-- Generate javadoc -->
	<target name="javadoc" depends="init">
		<delete dir="${javadoc}"/>
		<javadoc packagenames="com.zw.geh.*" author="true" use="true" version="true" sourcepath="${source.web};${source.ejb}" destdir="${javadoc}">
			<classpath>
				<pathelement location="${tpcl}/struts.jar" />
				<pathelement location="${tpcl}/castor-0.9.7-xml.jar" />
				<pathelement location="${tpcl}/jms.jar" />
				<pathelement location="${tpcl}/xercesImpl.jar" />
				<pathelement location="${tpcl}/icjava621.jar"/>				
			</classpath>
		</javadoc>
	</target>
    
	<!-- Compile common, EJB and Web module code -->
	<target name="compile" depends="init">
		<tstamp/>
		<javac srcdir="${source.ejb};${source.web};${source.common};${source.workflow};" encoding="ISO-8859-1" destdir="${builddir}" debug="yes">
			<classpath refid="src.classpath"/>
	   </javac>
	</target>
	
	<target name="compiletestcode" depends="inittest,compile">
		<javac srcdir="${utestdir}/java;" destdir="${testdir}" debug="yes" >
			<classpath refid="src.classpath" />
			<classpath refid="test.classpath" />
			<classpath>
				<pathelement location="${builddir}"/>
			</classpath>
		</javac>
	</target>
	
	<target name="copyGlobalLocalResource" depends="compiletestcode">
		<copy todir="${builddir}">
			<fileset dir="${utestdir}/GlobalEnvironment/China">
				  <include name="GlobalEnvProperties.properties"/>
			</fileset>
		</copy>
	</target>
	
	<target name="copyGlobalUSResource" depends="compiletestcode">
		<copy todir="${builddir}">
			<fileset dir="${utestdir}/GlobalEnvironment/US">
				  <include name="GlobalEnvProperties.properties"/>
			</fileset>
		</copy>
	</target>
	
	<target name="copyResource" depends="compiletestcode">
		<copy todir="${builddir}">
			<fileset dir="${utestdir}/resources">
				<include name="**/*.properties"  />
				<include name="**/*.sql"  />
			</fileset>
			<fileset dir="${source.web}">
				<include name="**/*.properties"/>
				<include name="**/*.xslt"/>
			</fileset>
			<fileset dir="${web.inf.dir}">
				<include name="**/server-config.wsdd"/>
			</fileset>
			<fileset dir="${web.inf.dir}/../">
				<include name="**/GEHlog4j.properties"/>
			</fileset>
			<fileset dir="${config.dir}">
				<include name="**/DatabaseType.properties"/>
				<include name="**/SQLHelper.properties"/>
			</fileset>
			<fileset dir="${config.dir}/Oracle">
				<include name="**/DatabaseEscapeCharacters.properties"/>
			</fileset>
		</copy>
		<copy file="../ant/gehAppVersion.properties" tofile="${builddir}/com/zw/geh/gehAppVersion.properties"/>
	</target>
	<!-- this part is for unit test and coverage -->

	<target name="instrument">
		<cobertura-instrument todir="${instrumenteddir}">
			<!--
				The following line causes instrument to ignore any
				source line containing a reference to log4j, for the
				purposes of coverage reporting.
			-->
			<ignore regex="org.apache.log4j.*" />

			<fileset dir="${builddir}">
				<exclude name="**/rv/**/*.class"/>
				<exclude name="**/*Test.class"/>
			</fileset>
		</cobertura-instrument>
	</target>
	
	<target name="test">
		<junit dir="./" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
			<!--
				Note the classpath order: instrumented classes are before the
				original (uninstrumented) classes.  This is important.
			-->
			<classpath location="${instrumenteddir}" />
				 <syspropertyset>
					  <propertyref prefix="test-sys-prop."/>
					  <mapper from="test-sys-prop.*" to="*" type="glob"/>
				 </syspropertyset>
			<classpath location="${builddir}" />
			<classpath location="${testdir}" />

			<!--
				The instrumented classes reference classes used by the
				Cobertura runtime, so Cobertura and its dependencies
				must be on your classpath.
			-->
			<classpath refid="cobertura.classpath" />
						
			<formatter type="brief" usefile="false"/>
			<formatter type="xml" />
			<test name="${testcase}" todir="${reportsdir}/junitxml" if="testcase" />
			<batchtest todir="${reportsdir}/junitxml" unless="testcase">
				<fileset dir="${utestdir}/java">
					<include name="**/${testclassname}Test.java" />
					<exclude name="**/rv/**/*.java"/>
				</fileset>
			</batchtest>
		</junit>

		<junitreport todir="${reportsdir}/junitxml">
			<fileset dir="${reportsdir}/junitxml">
				<include name="TEST-*.xml" />
			</fileset>
			<report format="frames" todir="${reportsdir}/junithtml" />
		</junitreport>
	</target>

	<target name="coverage-check">
		<cobertura-check branchrate="34" totallinerate="100" />
	</target>

	<target name="coverage-report">
		<!--
			Generate an XML file containing the coverage data using
			the "srcdir" attribute.
		-->
		<cobertura-report srcdir="${source.ejb};${source.web};" destdir="${reportsdir}/coveragexml" format="xml" />
	</target>

	<target name="alternate-coverage-report">
		<!--
			Generate a series of HTML files containing the coverage
			data in a user-readable form using nested source filesets.
		-->
		<cobertura-report destdir="${reportsdir}/coveragehtml">
			<fileset dir="${source.ejb}">
				<include name="**/*.java" />
			</fileset>
			<fileset dir="${source.web}">
				<include name="**/*.java" />
			</fileset>
			<!--
			<fileset dir="${source.common}">
				<include name="**/*.java" />
			</fileset>
			<fileset dir="${source.workflow}">
				<include name="**/*.java" />
			</fileset>
			-->
		</cobertura-report>
	</target>
	
	<target name="cleanupJMSForUSMachine">
		<echo message="cleanJMS"/>
		<exec executable="/apps/tibco/ems/5.0/bin/cleanupJMSForUTLocal.sh"/>
		<echo message="clean up jms successful"/>
	</target>
	
	<target name="cleanupJMSForLocalMachine">
		<echo message="cleanJMS"/>
		<exec executable="cleanupJMSForWindows.bat"/>
		<echo message="clean up jms successful"/>
	</target>
	
	<target name="cleanGEHDB">
		<echo message="cleanGEHDB"/>
		<ant antfile="build-cleandatabase.xml" target="cleanupGEH"/>
	</target>
	<target name="cleanGALDB">
		<echo message="cleanGALDB"/>
		<ant antfile="build-cleandatabase.xml" target="cleanupGAL"/>
	</target>
	<target name="cleanGEHDBUS">
		<echo message="cleanGEHDB"/>
		<ant antfile="build-cleandatabase.xml" target="cleanupGEHUS"/>
	</target>
	<target name="cleanGALDBUS">
		<echo message="cleanGALDB"/>
		<ant antfile="build-cleandatabase.xml" target="cleanupGALUS"/>
	</target>
	<!-- Build script section -->
	<target name="all" depends="cleanGEHDB,copyGlobalLocalResource,copyResource,instrument,test,coverage-report,alternate-coverage-report,cleanupJMSForLocalMachine"/>
	<target name="US" depends="cleanGEHDBUS,copyGlobalUSResource,copyResource,instrument,test,coverage-report,alternate-coverage-report,cleanupJMSForUSMachine"/>
</project>


<?xml version="1.0"?>
<project default="all" basedir=".">

	 <!-- Dir of the ant properties file -->
    <property name="ant.properties.dir"	value="."/>
	
	<!-- put in the properties. -->
	<property file="${ant.properties.dir}/ant_ut.properties"/>

	<path id="src.classpath">
		<fileset dir="${tpcl}/utest">
			<include name="ojdbc14.jar" />
		</fileset>
	</path>

	<target name="loadGlobalProperties_China" description="load global properties(China)">
		<!-- Pull in China related environmental properties UT may need -->
		<property file="${utestdir}/GlobalEnvironment/China/GlobalEnvProperties.properties" />
	</target>
	<target name="loadGlobalProperties_US" description="load global properties(US)">
		<!-- Pull in US related environmental properties UT may need -->
		<property file="${utestdir}/GlobalEnvironment/US/GlobalEnvProperties.properties" />
	</target>
	
	<target name="cleanupGAL" depends="loadGlobalProperties_China" description="clean db">
		<sql driver="${GALGUI.UT.DB.DRIVERNAME}" url="${GALGUI.UT.DB.URL}" password="${GALGUI.UT.DB.PASSWORD}" userid="${GALGUI.UT.DB.USERNAME}" encoding="utf8" print="no">
			<transaction src="${clean.GAL.sqlfile.name}"/>
			<classpath refid="src.classpath" />
		</sql>
	</target>
	
	<target name="cleanupGALUS" depends="loadGlobalProperties_US" description="clean db">
		<sql driver="${GALGUI.UT.DB.DRIVERNAME}" url="${GALGUI.UT.DB.URL}" password="${GALGUI.UT.DB.PASSWORD}" userid="${GALGUI.UT.DB.USERNAME}" encoding="utf8" print="no">
			<transaction src="${clean.GAL.sqlfile.name}"/>
			<classpath refid="src.classpath" />
		</sql>
	</target>
	
	<target name="cleanupGEH" depends="loadGlobalProperties_China" description="clean db">
		<sql driver="${GEHGUI.UT.DB.DRIVERNAME}" url="${GEHGUI.UT.DB.URL}" password="${GEHGUI.UT.DB.PASSWORD}" userid="${GEHGUI.UT.DB.USERNAME}" encoding="utf8" print="no">
			<transaction src="${clean.GEH.sqlfile.name}"/>
			<classpath refid="src.classpath" />
		</sql>
	</target>
	
	<target name="cleanupGEHUS" depends="loadGlobalProperties_US" description="clean db">
		<sql driver="${GEHGUI.UT.DB.DRIVERNAME}" url="${GEHGUI.UT.DB.URL}" password="${GEHGUI.UT.DB.PASSWORD}" userid="${GEHGUI.UT.DB.USERNAME}" encoding="utf8" print="no">
			<transaction src="${clean.GEH.sqlfile.name}"/>
			<classpath refid="src.classpath" />
		</sql>
	</target>
</project >


对jsvc自启动的tomcat脚本,增加CATALINA_OPTS="-Xms128m -Xmx512m",问题得到解决。
#!/bin/sh
#
# Startup Script for Tomcat6
#
# chkconfig: 345 88 18
# description: Tomcat Daemon
# processname: jsvc
# pidfile: /usr/var/run/jsvc.pid
# config:
#
# Source function library.
. /etc/rc.d/init.d/functions
#
prog=tomcat
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/jdk1.5.0_18
CATALINA_HOME=/apps/apache-tomcat-6.0.16
DAEMON_HOME=$CATALINA_HOME/bin/jsvc-src
TOMCAT_USER=your username(Linux下启动tomcat的用户)
HUDSON_HOME=/apps/hudson_gal_geh

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/apps/apache-tomcat-6.0.16

CATALINA_OPTS="-Xms128m -Xmx512m"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
     -DHUDSON_HOME=$HUDSON_HOME \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile '&1' \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;

  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac


<tstamp />
<zipfileset dir="${web}" prefix="WEB-INF">
	<include name="**/*.xml"/>
	<include name="**/*.java"/>
	<exclude name="web.xml"/>
</zipfileset>  
      
分享到:
评论
2 楼 qtlkw 2012-09-24  
slave没玩过
1 楼 wuliupo 2012-07-30  
如果我的是 slave 机器,怎么设置呢?

相关推荐

Global site tag (gtag.js) - Google Analytics