You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Payette, Don J" <Do...@unisys.com> on 2005/04/04 20:31:01 UTC

Build with Java 1.4.2

I'm using eclipse for my IDE and my project has a build.xml.  Whenever I
do a
build, I right-click the build.xml and select Run Ant...  I then select
the
All target.  Works great.

Recently, my cohorts have suggested I need to switch from the 1.3.1 Java
to the 1.4.2
Java to be compatible with a new run environment.  I start eclipse with

	C:\eclipse\V2_1_3\eclipse\eclipse.exe eclipse -vm
C:\Java\j2sdk1.4.2_07\bin\javaw.exe
So it uses the newer java vm.   However I'm getting this when I do my
build:

        [echo] The classpath for compilation is
c:\Java\j2sdkee1.4.2_07\lib\j2ee.jar:jars/xerces.jar:jars/MCP.jar
        [echo] Java home is C:\Java\j2sdk1.4.2_07
       [javac] Compiling 307 source files to C:\SPEC\classes
       [javac] C:\SPEC\src\com\sun\jini\debug\Debug.java:177: cannot
access java.lang.Object
       [javac] bad class file:
C:\Java\j2sdk1.4.2_07\jre\lib\rt.jar(java/lang/Object.class)
       [javac] class file has wrong version 48.0, should be 47.0
       [javac] Please remove or make sure it appears in the correct
subdirectory of the classpath.
       [javac]     private String		propertyName;
       [javac]             ^
       [javac] 1 error
       [javac] BUILD FAILED: file:C:/SPEC/build.xml:110: Compile failed;
see the compiler error output for details.
Total time: 3 seconds

Any ideas what is going wrong and how to fix it?
Here is my build.xml:

build.xml
---------
<?xml version="1.0"?>

<!--  SPECjAppServer build definitions.

  August 2002 : Modified default to use CMP
  
  April 2002 : Modified for SPECjAppServer 2001
  
  April 2001 : Minor Modifications by Tom Daly (Sun)
  
  March 2001 : Thanks to Bill Kayser (Alliare) for creating the initial
version of this
	       ant input file and for the documentation accompanying it
which has been 
	       incorporated into the README.html

  Please refer to the readme.html for instructions on building and
deploying 
  the SPECjAppServer source.

  This file contains targets for compiling and packaging war files and
  ejb files using ant 1.3 or later.

  You can find the ant binaries at http://jakarta.apache.org/ant

  It should not be necessary to edit this file.  

  EXECUTING TARGETS

  To execute a target for a particular appserver such as the reference
  implementation, do this:

  ant -Dappserver=ri.1.3.1 target

  Substitute "ri.1.3.1" for the name of the appserver, such as "tomcat"
or 
  "jrun". 

  "ant" should be invoked from the SPECjAppServer top directory
($JAS_HOME)

  SUPPORTED TARGETS

  These are the targets you are most likely to use:

  clean:              Delete all output files
  jAppServer-ear:     Builds all ejb jar files and warfiles needed for 
                      SPECjAppServer, minus the supplier, emulator and
driver.
  emulator-ear:       Builds the emulator ear file with the war inside.
  allejbs:	          Builds just the ejb jar files for all
deployable ejbs
  clean-driver:	      Removes the driver class files and jar in
preparation for 
	                  rebuilding.
  driver:	          Builds the driver.jar file, this must be
called explicitly
	                  as it is not part of the default build also
driver.jar is not 
	                  removed by the "clean" target
  load:		          builds the load.jar file
  loaddb:             Executes the load program for all domains.
  load-corp,load-supp,load-mfg,load-ords,load-rules:
                  The targets for individual domain db loading

  -->

<project name="SPECjAppServer" default="all">

  <!-- This property determines where env and config files will
       be loaded from.  The default is "ri.1.3.1" which means that
       config/ri.1.3.1.env will be loaded and the EJB descriptors will
       be found in src/deploy/ri.1.3.1.  -->

  <property name="appserver" value="ri.1.3.1"/>

  <!-- This is the classpath used for compilation.
       If you don't have the j2ee.jar file handy, you
       can substitute it with the individual ext jar
       files if you have them instead.  -->

  
  <!-- Load the external properties.  
       These will override any settings here. -->
  <property file="config/${appserver}.env"/>

   <property name="compile.classpath"
            value="${JAVAX_JAR}:jars/xerces.jar:jars/MCP.jar" />
 
  <!-- This uses the JDK1.3 compiler if available.  You may need to set
JAVA_HOME. -->
    <property name="build.compiler" value="modern"/> 

    <property name="descriptor-dir" location="src/deploy/${appserver}"/>

    <target name="all" depends="jAppServer-ear,emulator-ear,load"/>

    <!-- Delete all the targets -->
    <target name="clean">
        <delete dir="./classes/WEB-INF" />
        <mkdir dir="./classes/WEB-INF" />
        <delete>
          <fileset dir="." 
              includes="**/*~,**/*.class,*.zip,**/*.?ar"
	      excludes="ant/lib/*.jar,jars/*chart*.jar,jars/driver.jar,
 
,jars/launcher.jar,jars/xerces.jar,jars/MCP.jar"/> 
        </delete>
   </target>

    <!-- Compile everything -->
    <target name="compile">
    <echo message="The classpath for compilation is
${compile.classpath}" />
    <echo message="Java home is ${JAVA_HOME}" />
    <javac srcdir="src"
           deprecation="on"
	   debug="on"
	   destdir="classes"
	   includes="**/*.java"
	   excludes="**/charts*/*"
	   target="1.2"
	   classpath="${compile.classpath}"/>
    </target>


    <!-- DRIVER clean and REBUILD Targets
 	 It is not expected that the driver will need to be deleted or
rebuilt
         but the next 2 targets provide for this should the user
explicitly want
	 to do it. So be aware that the "clean" target will not effect
the 
	 driver classes or jar, you must use "ant clean-driver" to
remove driver files
	 and then "ant driver" to build the new driver

	 The driver target also rebuilds the launcher.jar file which
contains the 
	 logic to initiate the driver in a portable fashion.
    -->

    <target name="clean-driver" >
        <delete>
            <fileset dir="." includes="**/driver/*.class,
**/jars/driver.jar,
				      **/jars/launcher.jar" />
        </delete>
    </target>

    <target name="driver" depends="compile">
    <rmic base="./classes"
includes="**/driver/*Impl.class,**/driver/*Agent.class" 
			   excludes="**/driver/Agent.class" /> 
    <jar jarfile="jars/driver.jar" compress="false">
        <fileset dir="classes"
               includes="**/driver/*.class"/>
    </jar>    
    <jar jarfile="jars/launcher.jar" compress="false">
        <fileset dir="classes"
               includes="**/launcher/*.class"/>
    </jar></target>


  <!-- Definitions for the names of the descriptor files -->

  <property name="dd.persistence" value="BMP"/>
  <property name="dd.supp" value="supplier.xml.${dd.persistence}"/>
  <property name="dd.servlet" value="servlet.xml"/>
  <property name="dd.web" value="web.xml"/>
  <property name="dd.application" value="application.xml"/>
  <property name="dd.emu-web" value="emulator-web.xml"/>
  <property name="dd.emu-app" value="emulator-app.xml"/>

  <property name="dd.application-specific" value="sun-j2ee-ri.xml"/>  
  <property name="tmpdir" value="./tmpdir"/>  

  <!-- EJB Jar Packaging  -->

  <target name="allejbs" depends="util,corp,orders,mfg,supplier-ejb"/>

  <target name="util" depends="compile">
    <jar jarfile="jars/util.jar" compress="false">
      <fileset dir="classes"
               includes="**/common/**,**/util/**"/>
      <zipfileset dir="${descriptor-dir}/util/${dd.persistence}"
                  includes="*.xml"
                  prefix="META-INF"/></jar></target>

  <target name="corp" depends="compile">
    <jar jarfile="jars/corp.jar" compress="false">
      <fileset dir="classes"
               includes="**/common/**,**/ruleengine/**,**/corp/**"/>
      <zipfileset dir="${descriptor-dir}/corp/${dd.persistence}"
                  includes="*.xml"
                  prefix="META-INF"/></jar></target>

  <target name="orders" depends="compile">
    <jar jarfile="jars/orders.jar" compress="false">
      <fileset dir="classes"
               includes="**/common/**,**/orders/**"/>
      <zipfileset dir="${descriptor-dir}/orders/${dd.persistence}"
                  includes="*.xml"
                  prefix="META-INF"/></jar></target>

  <target name="mfg" depends="compile">
    <jar jarfile="jars/mfg.jar" compress="false">
      <fileset dir="classes"
               includes="**/common/**,**/mfg/**"/>
      <zipfileset dir="${descriptor-dir}/mfg/${dd.persistence}"
                  includes="*.xml"
                  prefix="META-INF"/></jar></target>

  <!-- 
    The supplier needs to have the xerces xml parser classes 
    so add xerces.jar in the classpath of the server
  -->

  <target name="supplier-ejb" depends="compile">
    <property name="tmpfile" value="tmp.xml"/>
    <antcall target="process-dd">
      <param name="source-dd" value="${descriptor-dir}/${dd.supp}"/>
      <param name="target-dd" value="${tmpfile}"/></antcall>
	     
    <jar jarfile="jars/supplier.jar" compress="false">
      <fileset dir="classes"
               includes="**/common/**,**/supplier/**"
               excludes="**/supplier/helper/LogManager.class,
                         **/supplier/web/**,**/supplier/emulator/**"/>
      <zipfileset dir="."
                  includes="${tmpfile}"
                  fullpath="META-INF/ejb-jar.xml"/>
      <zipfileset dir="${descriptor-dir}/supplier/${dd.persistence}"
                  includes="*.xml"
                  prefix="META-INF"/></jar>
    <delete file="${tmpfile}"/></target>

  <!-- This is an ant subroutine.

       This routine should be called with the property source-dd set
       to the deployment descriptor which will be copied to the file
       given by target-dd with the emulator host and port tokens
       substituted.  

       NOTE: This could be done automatically if the tokens
       fit ant token syntax: @token@   Ant does automatic token 
       substitution during <copy>   -->

  <target name="process-dd">
    <property name="tmpfile" location="classes/tmp.xml"/>
    <copy tofile="${target-dd}"
          overwrite="true"
          file="${source-dd}"/>
    <replace file="${target-dd}"
             token="EMULATOR_HOST"
	     value="${EMULATOR_HOST}"/>
    <replace file="${target-dd}"
             token="EMULATOR_PORT"
	     value="${EMULATOR_PORT}"/>
    <replace file="${target-dd}"
             token="_EMULATOR_PREFIX_"
	     value="${EMULATOR_PREFIX}"/>
    <replace file="${target-dd}"
             token="JAS_HOST"
	     value="${JAS_HOST}" />
    <replace file="${target-dd}"
             token="JAS_PORT"
	     value="${JAS_PORT}" />
    <replace file="${target-dd}"
             token="_JAS_PREFIX_"
	     value="${JAS_PREFIX}" /></target>

  <!-- Web application archive packaging.
       The web applications consist of the targets:
         
	 supplier-war
	 web-war
	 emulator-war       -->
 
  <target name="supplier-war" depends="compile">
    <war warfile="jars/supplier.war" compress="false"
         webxml="${descriptor-dir}/${dd.servlet}"
         basedir="src/docroot" includes="dtd/**/*">
      <classes 
         dir="classes" 
         includes="**/common/**,**/supplier/helper/**,
                   **/supplier/web/**"/>
      <zipfileset dir="${descriptor-dir}/servlet"
                  includes="*.xml"
                  prefix="WEB-INF"/>
     </war>
  </target>

  <target name="web-war" depends="compile">
    <war warfile="jars/web.war" compress="false"
         webxml="${descriptor-dir}/${dd.web}"
	 basedir="src/docroot">
      <classes 
         dir="classes" 
         includes="**/common/**,**/webbeans/**"/>
      <zipfileset dir="${descriptor-dir}/web"
                  includes="*.xml"
                  prefix="WEB-INF"/>
    </war>
  </target>


  <!-- 
    The emulator needs to have the xerces xml parser classes 
    so add xerces.jar in the classpath of the server
  -->
  <target name="emulator-war" depends="compile">

    <property name="tmpfile" location="classes/tmp.xml"/>
    <antcall target="process-dd">
      <param name="source-dd" value="${descriptor-dir}/${dd.emu-web}"/>
      <param name="target-dd" value="${tmpfile}"/></antcall>
    <war warfile="jars/emulator.war" compress="false"
         webxml="${tmpfile}"
	 basedir="src/docroot"
	 includes="dtd/**/*">
      <classes 
         dir="classes" 
         includes="**/common/**,**/supplier/emulator/**,
                   **/jini/**,**/supplier/helper/**"/>
    </war>
    <delete file="${tmpfile}"/></target>

  <!-- Convenience target for building the entire supplier -->
  <target name="supplier" depends="supplier-ejb,supplier-war"/>

  <!-- EAR Files -->
  <target name="jAppServer-ear"
depends="util,supplier,web-war,corp,orders,mfg">  
    <mkdir dir="${tmpdir}" />
    <mkdir dir="${tmpdir}/META-INF"/>
    <copy todir="${tmpdir}/META-INF" >
	  <fileset dir="${descriptor-dir}" 
	  includes="${dd.application},${dd.application-specific}" /> 
    </copy>
    <copy todir="${tmpdir}" >
        <fileset dir="jars"
 
includes="corp.jar,mfg.jar,orders.jar,supplier.jar,util.jar
                           supplier.war,web.war" />
    </copy>
    <jar jarfile="jars/SPECjAppServer.ear"  compress="false"
         basedir="${tmpdir}" >
    </jar>
    <delete dir="${tmpdir}" />
  </target>

  <target name="emulator-ear" depends="emulator-war">
    <zip zipfile="jars/emulator.ear" compress="false"
         basedir="jars"
	 includes="emulator.war">
      <zipfileset dir="${descriptor-dir}"
                  includes="${dd.emu-app}"
		  fullpath="META-INF/application.xml"/></zip>
  </target>

  <!-- DB Load -->

  <!-- Default scale value.  Should be overridden on the command line.
-->
  <property name="SCALE" value="1"/>

  <property name="JAS_HOME" location="."/>

  <target name="loaddb" 
 
depends="load-corp"/><!--,load-supp,load-mfg,load-ords,load-rules"/-->
  <target name="load-corp">
    <antcall target="_loaddb">
      <param name="Domain" value="Corp"/></antcall></target>
     
  <target name="load-supp">
    <antcall target="_loaddb">
      <param name="Domain" value="Supp"/></antcall></target>
     
  <target name="load-mfg">
    <antcall target="_loaddb">
      <param name="Domain" value="Mfg"/></antcall></target>
     
  <target name="load-ords">
    <antcall target="_loaddb">
      <param name="Domain" value="Ords"/></antcall></target>

  <target name="load-rules">
    <property name="LoadPkg" value="org.spec.jappserver.load"/>
    <java classname="${LoadPkg}.LoadRules"
          fork="true">
      <classpath>
        <pathelement path="${JDBC_CLASSPATH}"/>
        <pathelement path="${CLASSPATH}"/>
	<pathelement location="jars/load.jar"/></classpath>
      <jvmarg value="-Dspecjappserver.home=${JAS_HOME}"/>
      <arg value="discount"/>
      <arg value="${JAS_HOME}/schema/discount.rules"/></java></target>

  <!-- Generic Ant target for loading a table.  Should
        be invoked using antcall action seting the Domain argument. -->

  <target name="_loaddb" depends="load">
    <property name="LoadPkg" value="org.spec.jappserver.load"/>
    <property name="Domain" value="Ords"/>
    <java classname="${LoadPkg}.Load${Domain}" fork="true">
      <jvmarg value="-Dspecjappserver.home=${JAS_HOME}"/>
      <arg value="${SCALE}"/>
      <classpath>
        <pathelement path="${JDBC_CLASSPATH}"/>
        <pathelement path="${CLASSPATH}"/>
	<pathelement
location="jars/load.jar"/></classpath></java></target>

  <target name="load" depends="compile">
    <jar jarfile="jars/load.jar" compress="false"
         basedir="classes"
         includes="org/spec/jappserver/load/**/*.class"/></target>
    
  <!-- Compile charts -->
  <target name="compile-charts">
    <echo message="The classpath for compilation is
${compile.classpath}:jars/jcchart450K.jar" />
    <javac srcdir="src"
           deprecation="on"
	   debug="on"
	   destdir="classes"
	   includes="**/charts*/*"
	   target="1.2"
	   classpath="${compile.classpath}:jars/jcchart450K.jar"/>
  </target>

  <target name="charts" depends="compile-charts">
    <jar jarfile="jars/charts.jar" compress="false"
         basedir="classes"
         includes="org/spec/jappserver/charts/*.class"/>
  </target>

</project>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Build with Java 1.4.2

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Note that you are using target=1.2 in your build.xml for the javac task. 
Not sure if it plays a role in your problem.
I do not know what are exactly class file major versions 47 and 48.
I found only this doc about this type of issue : 
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#80961
Cheers,
Antoine

Payette, Don J wrote:

>I'm using eclipse for my IDE and my project has a build.xml.  Whenever I
>do a
>build, I right-click the build.xml and select Run Ant...  I then select
>the
>All target.  Works great.
>
>Recently, my cohorts have suggested I need to switch from the 1.3.1 Java
>to the 1.4.2
>Java to be compatible with a new run environment.  I start eclipse with
>
>	C:\eclipse\V2_1_3\eclipse\eclipse.exe eclipse -vm
>C:\Java\j2sdk1.4.2_07\bin\javaw.exe
>So it uses the newer java vm.   However I'm getting this when I do my
>build:
>
>        [echo] The classpath for compilation is
>c:\Java\j2sdkee1.4.2_07\lib\j2ee.jar:jars/xerces.jar:jars/MCP.jar
>        [echo] Java home is C:\Java\j2sdk1.4.2_07
>       [javac] Compiling 307 source files to C:\SPEC\classes
>       [javac] C:\SPEC\src\com\sun\jini\debug\Debug.java:177: cannot
>access java.lang.Object
>       [javac] bad class file:
>C:\Java\j2sdk1.4.2_07\jre\lib\rt.jar(java/lang/Object.class)
>       [javac] class file has wrong version 48.0, should be 47.0
>       [javac] Please remove or make sure it appears in the correct
>subdirectory of the classpath.
>       [javac]     private String		propertyName;
>       [javac]             ^
>       [javac] 1 error
>       [javac] BUILD FAILED: file:C:/SPEC/build.xml:110: Compile failed;
>see the compiler error output for details.
>Total time: 3 seconds
>
>Any ideas what is going wrong and how to fix it?
>Here is my build.xml:
>
>build.xml
>    <target name="compile">
>    <echo message="The classpath for compilation is
>${compile.classpath}" />
>    <echo message="Java home is ${JAVA_HOME}" />
>    <javac srcdir="src"
>           deprecation="on"
>	   debug="on"
>	   destdir="classes"
>	   includes="**/*.java"
>	   excludes="**/charts*/*"
>	   target="1.2"
>	   classpath="${compile.classpath}"/>
>    </target>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org