在我的build.xml中,我有:
<target name="run-tenantManagement" depends="jar">
<java classname="com.oracle.Constants" fork="true">
<sysproperty key="SIMV3.1" value="${SIMV3.1}"/>
</java>
</target>
当我调用此目标时,我得到一个例外:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: com/oracle/common/Constants
[java] Caused by: java.lang.ClassNotFoundException: com.oracle.common.Constants
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[java] Could not find the main class: com.oracle.common.Constants. Program will exit
请建议如何在我的类路径中添加此Constants类?
在我的build.xml中,我有:
<path id="jars.classpath">
<path refid="alljars.classpath"/>
<fileset dir="${code.build}" includes="**/*.class" />
<pathelement location="${code.build}"/>
</path>
<echo>Classpath=${toString:alljars.classpath}</echo>
项目结构是:
ProjectName==>src==>com==>oracle==>Constants.java
ProjectName==>build.xml
这是我的build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="common" basedir=".">
<echo>Started executing build.xml file...</echo>
<defaultexcludes add="**/.ade_path/**" />
<property name="code.src" value="src" />
<property name="lib.home" value="lib" />
<property name="resources.home" value="resources" />
<property environment="env"/>
<property name="T_WORK" value="${env.T_WORK}${file.separator}PaaS"/>
<property name="IDM_ENV" value="${env.IDM_ENV}"/>
<property name="SHARED_IDM_HOME" value="${env.SHARED_IDM_HOME}"/>
<property name="IDMUTILS_HOME" value="${env.IDMUTILS_HOME}"/>
<property name="MW_HOME" value="${env.MW_HOME}"/>
<!--<property name="ADE_VIEW_ROOT" value="${env.ADE_VIEW_ROOT}"/>-->
<property name="code.build" value="${T_WORK}${file.separator}build" />
<property name="jar.home" value="${T_WORK}${file.separator}lib" />
<!-- <property name="code.workdir" value="${T_WORK}${file.separator}workdir" /> -->
<property name="target.test.classes.dir" value="${T_WORK}${file.separator}build"/>
<property name="code.build.prefixfiles" value="${T_WORK}${file.separator}build${file.separator}prefixfiles" />
<property name="code.build.tempfiles" value="${T_WORK}${file.separator}build${file.separator}tempfiles" />
<property name="resources.testdata" value="${resources.home}${file.separator}data" />
<property name="test.output" value="${T_WORK}${file.separator}testng-report"/>
<path id="compil.classpath">
<fileset dir="${lib.home}" includes="testng.jar" />
<!--
<fileset dir="${ADE_VIEW_ROOT}{file.separator}testtool{file.separator}3rdparty{file.separator}selenium{file.separator}selenium-2.15.0{file.separator}selenium-java-2.15.0" includes="selenium-java-2.15.0.jar" />
<fileset dir="${ADE_VIEW_ROOT}{file.separator}testtool{file.separator}3rdparty{file.separator}selenium{file.separator}selenium-2.15.0{file.separator}selenium-server-2.15.0" includes="selenium-server-standalone-2.15.0.jar" />
-->
<!--<fileset dir="${ADE_VIEW_ROOT}/testtool/3rdparty/selenium/selenium-2.25.0/selenium-java-2.25.0" includes="selenium-java-2.25.0.jar" />
<fileset dir="${ADE_VIEW_ROOT}/testtool/3rdparty/selenium/selenium-2.25.0/selenium-server-2.25.0" includes="selenium-server-standalone-2.25.0.jar" />-->
<fileset dir="${lib.home}" includes="idmmtpreprocessor.jar" />
<fileset dir="${lib.home}" includes="idmmultitenancy.jar" />
<fileset dir="${lib.home}" includes="mdsrt.jar" />
<fileset dir="${lib.home}" includes="jps-mbeans.jar" />
<fileset dir="${lib.home}" includes="jps-internal.jar" />
<fileset dir="${lib.home}" includes="jps-api.jar" />
<fileset dir="${lib.home}" includes="commons-io-1.3.2.jar" />
<fileset dir="${lib.home}" includes="ldapjclnt11.jar" />
<fileset dir="${lib.home}" includes="ojdl.jar" />
<fileset dir="${lib.home}" includes="oimclient.jar" />
</path>
<path id="jars.classpath">
<fileset dir="${lib.home}" includes="testng.jar" />
<!--
<fileset dir="${ADE_VIEW_ROOT}{file.separator}testtool{file.separator}3rdparty{file.separator}selenium{file.separator}selenium-2.15.0{file.separator}selenium-java-2.15.0" includes="selenium-java-2.15.0.jar" />
<fileset dir="${ADE_VIEW_ROOT}{file.separator}testtool{file.separator}3rdparty{file.separator}selenium{file.separator}selenium-2.15.0{file.separator}selenium-server-2.15.0" includes="selenium-server-standalone-2.15.0.jar" />
<fileset dir="${lib.home}" includes="jps-mbeans.jar" />
<fileset dir="${lib.home}" includes="javax.management.j2ee_1.0.jar" />
<fileset dir="${lib.home}" includes="javax.servlet_1.0.0.0_2-5.jar" />
<fileset dir="${lib.home}" includes="jmxspi.jar" />
-->
<!--<fileset dir="${ADE_VIEW_ROOT}/testtool/3rdparty/selenium/selenium-2.25.0/selenium-java-2.25.0" includes="selenium-java-2.25.0.jar" />
<fileset dir="${ADE_VIEW_ROOT}/testtool/3rdparty/selenium/selenium-2.25.0/selenium-server-2.25.0" includes="selenium-server-standalone-2.25.0.jar" />-->
<fileset dir="${lib.home}" includes="mdsrt.jar" />
<fileset dir="${lib.home}" includes="adf-share-base.jar" />
<fileset dir="${lib.home}" includes="adflogginghandler.jar" />
<fileset dir="${lib.home}" includes="ucp.jar" />
<fileset dir="${lib.home}" includes="cache.jar" />
<fileset dir="${lib.home}" includes="xmlef.jar" />
<fileset dir="${lib.home}" includes="share.jar" />
<fileset dir="${lib.home}" includes="commons-io-1.3.2.jar" />
<fileset dir="${lib.home}" includes="ldapjclnt11.jar" />
<fileset dir="${SHARED_IDM_HOME}" includes="mtutils/jlib/idmmultitenancy.jar" />
<fileset dir="${SHARED_IDM_HOME}" includes="mtutils/jlib/idmfatools.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.ldap_11.1.1/ldifloadtool.jar" />
<fileset dir="${MW_HOME}" includes="wlserver_10.3/server/lib/wlthint3client.jar" />
<fileset dir="${MW_HOME}" includes="wlserver_10.3/server/lib/wlclient.jar" />
<fileset dir="${MW_HOME}" includes="wlserver_10.3/server/lib/wljmxclient.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.osdt_11.1.1/osdt_cert.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.osdt_11.1.1/osdt_core.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.pki_11.1.1/oraclepki.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.pwdgen_11.1.1/pwdgen.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/args4j-2.0.9.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jps_11.1.1/jps-mbeans.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jps_11.1.1/jps-api.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jps_11.1.1/jps-manifest.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jmx_11.1.1/jmxframework.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.idm_11.1.1/identitystore.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.oamprovider_11.1.1/oamcfgtool.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/javax.servlet.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jmx_11.1.1/jmxspi.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/javax.management.j2ee.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.odl_11.1.1/ojdl.jar" />
<fileset dir="${MW_HOME}" includes="oracle_common/modules/oracle.jrf_11.1.1/jrf-api.jar" />
<fileset dir="${MW_HOME}" includes="oim/server/client/oimclient.jar" />
<fileset dir="${MW_HOME}" includes="oim/server/ext/spring.jar" />
<fileset dir="${MW_HOME}" includes="oim/server/lib/xlUtils.jar" />
<fileset dir="${MW_HOME}" includes="iam/server/client/oimclient.jar" />
<fileset dir="${MW_HOME}" includes="iam/server/ext/spring.jar" />
<fileset dir="${MW_HOME}" includes="iam/server/lib/xlUtils.jar" />
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask"
classpathref="compil.classpath"/>
<target name="init" description="Initializes everything, creates directories, etc.">
<echo>Initializing the environment...</echo>
<mkdir dir="${code.build}" />
<mkdir dir="${code.build.prefixfiles}" />
<mkdir dir="${code.build.tempfiles}" />
<!-- <mkdir dir="${code.workdir}" />
<mkdir dir="${code.workdir}/data" /> -->
<mkdir dir="${jar.home}" />
<mkdir dir="${test.output}" />
<copy todir="${code.build}">
<fileset dir="${resources.home}">
<include name="**/*.properties" />
</fileset>
</copy>
<copy todir="${code.build.prefixfiles}">
<fileset dir="${resources.testdata}">
<include name="**/*.xlf" />
<include name="**/*.ldif" />
<include name="**/*.xml" />
</fileset>
</copy>
<copy todir="${code.build.tempfiles}">
<fileset dir="${resources.testdata}">
<include name="**/*.csr" />
</fileset>
</copy>
<copy file="${IDM_ENV}" todir="${code.build}" />
<!--<path id="selenium.classpath">
<path refid="jars.classpath"/>
<fileset dir="${code.build}" includes="**/*.class" />
<pathelement location="${code.build}"/>
</path>-->
</target>
<target name="compile" depends="clean,init" description="Compile source code">
<echo>Compiling the code...</echo>
<echo>Classpath=${toString:jars.classpath}</echo>
<pathconvert pathsep="${line.separator}| |-- "
property="echo.path.jarfiles"
refid="compil.classpath">
</pathconvert>
<echo>Jar files: ${echo.path.jarfiles}</echo>
<javac srcdir="${code.src}" destdir="${code.build}" debug="on" optimize="on"
excludes="**/.ade_path/**"
classpathref="compil.classpath"
includeantruntime="false"/>
</target>
<target name="jar" depends="compile" description="Builds the jar file">
<echo>Building the jar file...</echo>
<echo>code.src.set=${code.src}</echo>
<jar destfile = "${jar.home}/testC9-ui-api.jar" basedir="${code.build}"/>
</target>
<target name="clean" description="Cleans up all the directories and files">
<echo>Cleaning up...</echo>
<delete dir="${code.build}" />
<!--
<delete dir="${code.workdir}" />
<delete dir="${test.output}"/>
-->
<delete file="${jar.home}/testC9-ui-api.jar" />
<!--
<delete>
<fileset dir="." includes="**/*.suc"/>
<fileset dir="." includes="**/*.dif"/>
</delete>
-->
</target>
答案 0 :(得分:0)
正如Christian所建议的那样,通过添加以下内容解决了这个问题:
<java classpathref="jars.classpath" classname="com.oracle.common.Constants" fork="true">
<sysproperty key="SIMV3.1" value="${SIMV3.1}"/>
</java>