SAXParser, Classpath woes and ANT

Greetings,
I am having a problem running a java task in ANT due to classpath related issues (I believe) but I don't understand why or how to fix them.
First to give some information I am using ant 1.7.1. I do NOT have an enviroment variable classpath.
I have not had any issues until a new task I created today which is failing. The program in question needs to use a SAXParser and is failing like below...
     [java] Warning: Caught exception attempting to use SAX to load a SAX XMLRea
der
     [java] Warning: Exception was: java.lang.ClassNotFoundException: org.apache
.xerces.parsers.SAXParserSo Google would lend me to believe this is a classpath error. Okay. But I don't really get how, why or most how to fix it. Here is what I know so far.
- I haven't had problems with other java tasks before now. And other tasks that have run before still run fine today
- I do not have a classpath environment variable.
- I can run the program from Eclipse with the same included libraries
- I munged all the classpath elements into one classpath atrribute for the task. It still does not work but if I copy and paste this exact path into java -cp CLASSPATHPASTEDHERE ClassName then it does work.
I don't know what to look at next. All the elements of the classpath exist and are correctly named, it runs stand-alone but not in ANT. Any suggestions appreciated.

ant -d produced 30 odd K of output it didn't tell me anything particularly exciting although ant was trying to use the parent class loader rather than the ant class loader to load it. If that means something to you I don't know.That just means to me something along the lines of "there's something going on with the parser class being visible by which class loader, reminding that JAXP may use the contextClassLoader at some point"... Not a very accurate thought I know, but the class loading traces are probably necessary to go further into the explanation.
I was hoping the -d traces would give the whole stack trace for the ClassNotFoundException. The problem is probably explainable by JAXP's dynamic loading of the parser class(ses), but I'm not brave enough to try to understand the JDK source code by second-guessing which method might be used in both your scenarios.
Something happens in ANT that causes the parser factory to do something different. When I run the java command myself with verbose I see this.
Loaded com.sun.org.apache.xerces.internal.parsers.SAXParser from C:\Program Files\Java\jre6\lib\rt.jar
So. Um. It's using a different parser (different classname). I don't really understand why.By a quick look at javax.xml.parsers.SAXParserFactory Javadoc:
- unless the class name is specified, JAXP will look for class whose names are:
1) specified in a system property javax.xml.parsers.SAXParserFactory
2) failing that, specified in the JRE config file
3) failing that, specified a s a service
4) failing that, default to "platform default"
A quick look at the code additionally shows that:
- 4) is com.sun.org.apache.xerces.internal.parsers.SAXParser in Sun's JRE6
- the config file mentioned at step 2) is read only once (see note below)
- under some circumstances, which I didn't get well, 4) is not attempted
- the context class loader plays a role that I didn't dig, I think it's specifically for 3)
Please note, if you really want to understand what was going on, that the SAXParserFactory Javadoc also mentions:
Tip for Trouble-shooting
Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.
If you have problems loading DocumentBuilders, try:
+java -Djaxp.debug=1 YourProgram ....+
(+note+) just noted by the way that there's a horrible Double-Checked Locking idiom (DCL) in the caching of the properties file!
Edited by: jduprez on Oct 7, 2009 1:02 PM

Similar Messages

  • Cannot make .war file using tomcat with eclipse and ant

    i have made all necesary configuration for deploying application using eclipse and ant for the tomcat server.
    when i start the server by clicking the tomcat icon on eclipse toolbar, the message is prompted that "missing application web.xml and using defaults". i have placed the web.xml file in the web/WEB-INF directory of the source project directory.
    also when i use ant by right-clicking on the build.xml file and choose Run as ant.. the process creates a desired .war file in webapps folder of the tomcat server but that war file does not works.
    where is the error i cannot figure out.
    am attaching the code of build.xml for reference.
    please help.
    build.xml:-
    <project name="BecilCTI" default="compile" basedir=".">
    <property file="build.properties"/>
    <property file="${user.home}/build.properties"/>
    <property name="app.name" value="BecilCTI"/>
    <property name="app.path" value="/${app.name}"/>
    <property name="app.version" value="0.1-dev"/>
    <property name="build.home" value="${basedir}/build"/>
    <property name="catalina.home" value="c:/Tomcat_5.5"/> <!-- UPDATE THIS! -->
    <property name="dist.home" value="${basedir}/dist"/>
    <property name="docs.home" value="${basedir}/docs"/>
    <property name="manager.url" value="http://localhost:8080/manager"/>
    <property name="src.home" value="${basedir}/src"/>
    <property name="web.home" value="${basedir}/web"/>
    <property name="compile.debug" value="true"/>
    <property name="compile.deprecation" value="false"/>
    <property name="compile.optimize" value="true"/>
    <!--<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>-->
    <path id="compile.classpath">
    <!-- Include all elements that Tomcat exposes to applications -->
    <pathelement location="${catalina.home}/common/classes"/>
    <fileset dir="${catalina.home}/common/endorsed">
    <include name="*.jar"/>
    </fileset>
    <fileset dir="${catalina.home}/common/lib">
    <include name="*.jar"/>
    </fileset>
    <pathelement location="${catalina.home}/shared/classes"/>
    <fileset dir="${catalina.home}/shared/lib">
    <include name="*.jar"/>
    </fileset>
    </path>
    <target name="all" depends="clean,compile"
    description="Clean build and dist directories, then compile"/>
    <target name="clean"
    description="Delete old build and dist directories">
         <echo message="Cleaning all dirs."/>
    <delete dir="${build.home}"/>
    <delete dir="${dist.home}"/>
    </target>
    <target name="compile" depends="prepare"
    description="Compile Java sources">
    <!-- Compile Java classes as necessary -->
    <mkdir dir="${build.home}/WEB-INF/classes"/>
    <javac srcdir="${src.home}"
    destdir="${build.home}/WEB-INF/classes"
    debug="${compile.debug}"
    deprecation="${compile.deprecation}"
    optimize="${compile.optimize}">
    <classpath refid="compile.classpath"/>
    </javac>
    <!-- Copy application resources -->
    <copy todir="${build.home}/WEB-INF/classes">
    <fileset dir="${src.home}" excludes="**/*.java"/>
    </copy>
    </target>
    <target name="dist" depends="compile"
    description="Create binary distribution">
    <!-- Copy documentation subdirectories
    <mkdir dir="${dist.home}/docs"/>
    <copy todir="${dist.home}/docs">
    <fileset dir="${docs.home}"/>
    </copy> -->
    <!-- Create application JAR file -->
    <jar jarfile="${catalina.home}/webapps/${app.name}.war"
    basedir="${build.home}"/>
    <!-- Copy additional files to ${dist.home} as necessary -->
    </target>
    <target name="install" depends="compile"
    description="Install application to servlet container">
    <deploy url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"
    localWar="file://${build.home}"/>
    </target>
    <target name="list"
    description="List installed applications on servlet container">
    <list url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"/>
    </target>
    <target name="prepare">
    <!-- Create build directories as needed -->
    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.home}/WEB-INF"/>
    <mkdir dir="${build.home}/WEB-INF/classes"/>
    <!-- Copy static content of this web application -->
    <copy todir="${build.home}">
    <fileset dir="${web.home}"/>
    </copy>
    <mkdir dir="${build.home}/WEB-INF/lib"/>
    </target>
    <target name="reload" depends="compile"
    description="Reload application on servlet container">
    <reload url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"/>
    </target>
    <target name="remove"
    description="Remove application on servlet container">
    <undeploy url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"/>
    </target>
    </project>

    So is context.xml actually overwriting the settings found in server.xml?I think so. The way I understand it is the the context.xml file saves you from having to edit server.xml. It is preferred for each web app to do its own config, rather than lumping them all together in server.xml.
    And what would be the best way to create the war file? IAt its heart, a WAR is just a zip file with its contents laid out in according to the specification of a web application directory structure.
    So the simplest way to make a war file is to zip up your directory structure with a tool like winzip, and rename it to be myApp.war.
    Regarding ant, I would recommend you take a look through [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/index.html
    ]this tutorial. It explains the basics of website layout, configuration and deployment.
    On [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/source.html] this page  in particular, it includes a link to a basic ant file that you can use as a starting point.
    Cheers,
    evnafets

  • [svn] 758: Updating all modules to Java 1.5.0 and Ant 1.7.0

    Revision: 758
    Author: [email protected]
    Date: 2008-03-07 10:47:56 -0800 (Fri, 07 Mar 2008)
    Log Message:
    Updating all modules to Java 1.5.0 and Ant 1.7.0
    * Updated setup.sh to reflect this.
    * Added an Eclipse project called flex-asc; it's required to run the other compiler projects now (now you can build and debug the entire compiler, including asc, all in Eclipse; I've removed the reference to asc.jar).
    * The other Eclipse projects now specify Java 1.5.
    * Revving asc.jar for compatibility with Java 1.5; it's taken from the 3.0.x branch temporarily while mainline asc is fixed up.
    * Fixed some assertions in mainline ASC (commenting them out with comments means fixing them, in this case)
    * Fixed some in-your-face warnings in the modules when compiling.
    * This will probably break the build, so hold tight. Preemptively, I'm on it...
    Modified Paths:
    flex/sdk/trunk/README.txt
    flex/sdk/trunk/development/eclipse/java/flex-compiler/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-compiler/.settings/org.eclipse.jdt.core.pref s
    flex/sdk/trunk/development/eclipse/java/flex-compiler/.settings/org.eclipse.jdt.ui.prefs
    flex/sdk/trunk/development/eclipse/java/flex-debugger/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-debugger/.settings/org.eclipse.jdt.core.pref s
    flex/sdk/trunk/development/eclipse/java/flex-debugger/.settings/org.eclipse.jdt.ui.prefs
    flex/sdk/trunk/development/eclipse/java/flex-jars/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-swfutils/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-swfutils/.settings/org.eclipse.jdt.core.pref s
    flex/sdk/trunk/development/eclipse/java/flex-swfutils/.settings/org.eclipse.jdt.ui.prefs
    flex/sdk/trunk/lib/asc.jar
    flex/sdk/trunk/modules/antTasks/build.xml
    flex/sdk/trunk/modules/asc/README.txt
    flex/sdk/trunk/modules/asc/build/java/build.xml
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/LintEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/MetaDataEvaluator.java
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/util/Context.java
    flex/sdk/trunk/modules/compiler/build.xml
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/API.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/config/ConfigurationBuffer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/zip/ZipEntry.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/ToolsConfiguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Library.java
    flex/sdk/trunk/modules/debugger/build.xml
    flex/sdk/trunk/modules/swfutils/build.xml
    flex/sdk/trunk/modules/swfutils/src/java/flash/util/ExceptionUtil.java
    flex/sdk/trunk/setup.sh
    Added Paths:
    flex/sdk/trunk/development/eclipse/java/flex-asc/
    flex/sdk/trunk/development/eclipse/java/flex-asc/.classpath
    flex/sdk/trunk/development/eclipse/java/flex-asc/.project
    flex/sdk/trunk/development/eclipse/java/flex-asc/.settings/
    flex/sdk/trunk/development/eclipse/java/flex-asc/.settings/org.eclipse.jdt.core.prefs
    flex/sdk/trunk/development/eclipse/java/flex-asc/.settings/org.eclipse.jdt.ui.prefs
    flex/sdk/trunk/development/eclipse/java/flex-jars/.settings/
    flex/sdk/trunk/development/eclipse/java/flex-jars/.settings/org.eclipse.jdt.core.prefs
    Property Changed:
    flex/sdk/trunk/development/eclipse/java/flex-compiler/
    flex/sdk/trunk/development/eclipse/java/flex-debugger/
    flex/sdk/trunk/development/eclipse/java/flex-jars/
    flex/sdk/trunk/development/eclipse/java/flex-swfutils/

    I'm expieriencing the very same problem, i.e. code compilation with a 1.5.0_06 compiler and execution on a 1.5.0_06 jre works fine, but the code parser will display an red line under a code line like the following:
    Vector<String> sv = new Vector<String>();
    I did what was hinted to in the reply. I connected to archive rt.jar in the jre-director of the jdk-1.5 and connected the javadoc for 1.5, but I still have the red lines.
    I have also added the argument -source 1.5 to the compiler, but nothing seems to help.
    Any hints very much appreciated. Many thanks.
    Pasqualino

  • Jdeveloper and ant

    hello,
    i need execute ant script before create EAR and WAR file
    i found the option in the project war properties ant xml execute but the build.xml don't run ,
    any ideas for jdeveloper and Ant integration ?
    the use case this i want create a properties file with svn version.
    thanks!!

    <?xml version="1.0" encoding="windows-1252" ?>
    <project xmlns="antlib:org.apache.tools.ant" default="generar">
    <path id="path.svnant">
    <pathelement location="libs/svnant/svnant.jar"/>
    <pathelement location="libs/svnant/svnClientAdapter.jar"/>
    <pathelement location="libs/svnant/svnjavahl.jar"/>
    <pathelement location="libs/svnant/svnkit.jar"/>
    <pathelement location="libs/svnant/ganymed.jar"/>
    <pathelement location="libs/svnant/jna.jar"/>
    </path>
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant"/>
    <target name="find_revision" >
    <property name="directorio" value="${buildir}"/>
    <!-- find out revision number of HEAD, need svn.exe installed on local machine -->
    <exec executable="svn" outputproperty="svnlog.out">
    <arg line="log ../"/>
    </exec>
    <echo>${homedir}</echo>
    <echo>${svnlog.out}</echo>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="libs/svnant/ant-contrib-1.0b3.jar"/>
    </classpath>
    </taskdef>
    <propertyregex property="revision.number" input="${svnlog.out}" select="\1">
    <regexp pattern="r([0-9]*)"/>
    </propertyregex>
    <echo file="src\org\sidoc\common\BuildInfo.java">
    package org.common;
    public class BuildInfo {
    public static final String revisionNumber="${revision.number}";
    </echo>
    </target>
    </project>
    works!

  • JDev9033, SQLJ and Ant

    Hi, can anybody help me with this?
    In this project we use JDev9033, JDK1.4.2_02, SQLJ, Ant1.54 and Oracle 9.2.0.1 client. Now I have a problem integrating OJC and Ant, since we want to use Ant from within JDev to build the project.
    I have set up the paths and class paths according to Oracle 9i SQLJ Developers Guide (Release 2). If I compile from JDev without Ant, JDev compiles the projects *.java and *.sqlj classes corretly.
    I have set the build.properties and build.xml file according to the paths specified in the build.xml file, which JDev can generate for me. And I have included jdev.jar and ojc.jar in the class path.
    Any way I get the exception with the -debug flag set i Ant:
    BUILD FAILED
    file:D:/JDev/GCSSMLIS/Tests/build.xml:166: Compiler Adapter 'oracle.jdeveloper.compiler.ant.teskdefs.OjcAdapter' can't be found.
         at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.resolveClassName(CompilerAdapterFactory.java:195)
    In build.properties I have:
    # COMPILATION SETTINGS
    compiler=oracle.jdeveloper.compiler.ant.teskdefs.OjcAdapter
    source="1.4"
    target="1.4"
    deprecation="on"
    optimize="off"
    debug="on"
    optimize=off
    and in build.xml:
    <javac
    compiler="${compiler}"
    srcdir="${comp.dir}"
    destdir="${build.dir}"
    includes="**/*.java, **/*TEST*.java, **/Test*.java"
    >
    <classpath refid="classpath" />
    </javac>
    with classpath:
    <path id="classpath">
    <fileset dir="${javac.path}" >
    <include name="*.jar" />
    </fileset>
    <fileset dir="${jdev.home}/sqlj/lib" >
    <include name="*.jar" />
    </fileset>
    <pathelement location="${jdev.home}/jdev/lib/jdev.jar" />
    <pathelement location="${jdev.home}/jdev/lib/ojc.jar" />
    <pathelement location="${ora.home}/jdbc/lib/ojdbc14.jar" />
    <pathelement location="${ant.path}/optional.jar"/>
    <pathelement location="${junit.path}/junit.jar" />
    </path>
    Regards
    Flemming

    Matthew,
    Thank for your replies. I manages to get rid of the Ant error by using the first method. I would expect the second to work to.
    I do not expect the OjcAdapter to translate the sqlj files into java files. I have read those chapters in the SQLJ Developers Guide.
    I would like to do obtain is the following:
    1) Use Ant as build system. I do not care, if Ant is external or internal to JDeveloper since both version are 1.5.3. But we have a lot of other steps like ftp to development server, running JUnit, updating CVS and VSS, documentation and so on, so I need Ant to make one build file that every body in the project can use.
    2) Use jre/sdk 1.4.2, sqlj and Oracle client 9.2.0. So I have to translate the projects sqlj files to x.generate.java files before I pass all projects files to a Java compiler.
    3) I tried to build an Ant precompile task in this way:
    a) copy all java and sqlj files from src directory to compile directory.
    b) From the Ant task run the sqlj translator on the compile directory
    c) pass the translated files to javac or ojc
    Since I can translate and compile the project with jdsk1.4.2 from the Jdev Make/Recompile menu point I assume I should be able to write Ant tasks to behave as I have want it to.
    Flemming

  • 10g BPEL process upgrade to 11g hangs in Jdeveloper and Ant script

    I have successfully upgraded several 10g (10.1.3.4) BPEL processes and ESB services using Jdeveloper 11g (11.1.1.6.0) migration wizard and deployed them to an 11g environment. Both 10g and 11g environments are up and running.
    However, my 11g jdeveloper hangs when migrating the next BPEL process. It hangs at the message box with the title: "Migration Status". I tried the Ant script and it hangs too. It hangs after printing out:
    "CompositeRefs
    [upgrade] WARNING: UPGBPEL-02009: No Binding setup for : "soapCheckPrivileges"
    . This will cause compilation of the upgraded project to fail. Check SOA Upgrade
    documentation on manual steps necessary to bind this composite reference. If ne
    cessary, upgrade and deploy any dependencies. If planning to retain 1013x nodes
    in this projects dependency tree, check earlier part of this log for 1013x WSDL
    URLs that can be used."
    I guess it makes sense since Jdeveloper and Ant script use the same code base for migration.
    One other observation is that if I kill the hanging jdeveloper process and reopen it and go through the migration wizard again, it will be successful without hanging. However, when I fix all the wsdl reference and do a build and deploy to sar. The resulting sar is defective and cannot be deployed to Weblogic even if both build and deploy to sar report success. The defective sar contains only scac.log and scac-log.xml, not even composite.xml.
    One difference between this BPEL process and others I have successfully upgraded is that it depends on an ESB service (this esb service has been upgraded and deployed to 11g).
    Any ideas?
    Thanks,

    I will answer my question. I killed the migrating Java process and the migrating wizard will report failure of migrating the .jpr file. Actually, the only thing missing in the migrated .jpr file is deployment profile which I can generate from deployment menu. And I can deploy the migrated process. This works as a workaround.

  • FlexBuilder 3 = MXMLC and ANT?

    Hi all-
    Admittedly I'm a flash / flex newbie, I have kindof a basic
    question... Flex Builder 3 has the .project and
    .actionScriptProperties files. I'm aware that MXMLC has a
    "--load-config" option. What is the best way to unify those two
    things? I've been trying for a week to get this stuff working using
    basic MXMLC stuff and I've got some things but I don't think it's
    the same thing that running a build in FlexBuilder does.
    The command I'm running is:
    mxmlc +FOO=something +BAR=something
    --load-config=./test-flex-config.xml MyFile.as -output MyOutput.swf
    ...so I think I've gotten far, but I don't understand why I
    can't use "mxmlc
    --load-actionScriptProperties=./.actionScriptProperties" ??? Aren't
    they all made by Adobe?
    --Robert

    No not really (thanks anyway). The link shows basically the same as my input except for the better formatting of the output.
    Both my and the example given both uses the Ant <exec> tag which start ojaudit from the command line. The problems still exist because I would like Ant to know if something was reported and the stop the Ant build process. A kind of "failOnValidationError".
    PMD has this (example below shows and Ant tag called pmd which is part of the PMD system.
    <pmd printToConsole="yes" failOnRuleViolation="on">
    Can ojaudit also do something like this? Or is there a way Ant can "scan" the result from the audit process and take the appropriate action?

  • Why do I get "Classpath to J2ME Ant extension library is not set" error?

    All of my mobile Netbeans projects have worked without problems for several years. Then suddenly I get this error message on all of them:
    nbproject\build-impl.xml:55: Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-modules-kjava-antext.jar file in the IDE installation directory.
    BUILD FAILED (total time: 0 seconds)
    I have not changed anything. Why do I suddenly get this error message?

    Hello,
    Welcome to Adobe Forums.
    1) Launch Task Manager (Keyboard Shortcut : Ctrl+Shift+Esc)
    2) Go to Processes Tab
    3) Make sure you have clicked on "Show processes from all users"
    4) Kill "iexplore.exe" process
    Use offline installer for Adobe Flash Player : Progress bar hangs during download / Unable to connect to server / Unable to download metafile
    Thanks,
    Vikram

  • Howto - JDev 10.1.3 - Audit tools and Ant

    Hi
    I'm playing around with Audit tools. I want to be able to call this from Ant. One primitive method is as follows:
    <target name="Audit" description="Running audit on source code">
    <property name="audit" value="ojaudit"/>
    <property name="profile" value="-profile MyRules"/>
    <property name="project" value="test3.jpr"/>
    <property name="output" value="-output d:\result.xml"/>
    <exec executable="cmd.exe" os="Windows XP" >
    <arg line="/c ${audit} ${profile} ${project} ${output}"/>
    </exec>
    </target>
    With results like:
    Audit:
    [exec] Oracle JDeveloper 10g Early Access Audit 10.1.3.0.3.3412
    [exec] Copyright (c) 2003-2005 Oracle. All Rights Reserved.
    [exec]
    [exec] Audit completed: 1 violation, no exceptions, 2 documents, 3 seconds
    BUILD SUCCESSFUL
    Total time: 3 seconds
    But then I'm unable to handle the result - unless I parse the output file. I want the Ant build file to fail if ojaudit find errors. Is this possible?
    I know the PMD extension exist but I really like the Jdev Audit stuff - but I need an interface to Ant to make it really useful: We have a build tool which build on every SCM check in. I would like the JDev Audit be part of that process so that source code problems (audit, metrics) are handles in the same process as well.
    By the way JDev 10.1.3 is great...
    johnny

    No not really (thanks anyway). The link shows basically the same as my input except for the better formatting of the output.
    Both my and the example given both uses the Ant <exec> tag which start ojaudit from the command line. The problems still exist because I would like Ant to know if something was reported and the stop the Ant build process. A kind of "failOnValidationError".
    PMD has this (example below shows and Ant tag called pmd which is part of the PMD system.
    <pmd printToConsole="yes" failOnRuleViolation="on">
    Can ojaudit also do something like this? Or is there a way Ant can "scan" the result from the audit process and take the appropriate action?

  • Difference happened between jar files by Jbuilder and ANT.

    I have a java project, and write an .xml file for it. I found that when I use this build.xml file to build the project in JBuilder, it generated a .jar file. Later when I go to command line and use this build.xml file directly with ANT, another .jar file is generated. The 2 files are different (The version of JDK and ANT are same).
    Has someone met such phenomenon before ? Or who can tell me what the reason is ?
    Thanks a lot.

    I too had the same. If U got any info plz do inform me........

  • How to correctly import the jUnit classpath into an Ant buildfile on OS X

    Hi,-
    I'm trying to automate compilation with Ant & jUnit which I run from command-line on my Mac OS X. My source files are in the /src folder, test classes are in the /test folder, the .class files go into the /build folder, and junit38.jar is in the /lib folder. The build.xml file looks like this:
    <?xml version="1.0"?>
    <project name="Money" default="build-source" basedir=".">
        <description>The Money project build file.</description>
        <property name="src" location="."/>
        <property name="build" location="build"/>
        <property name="junit" location="lib/junit38.jar"/>
        <path id="_classpath">
            <pathelement location="${junit}"/>
            <pathelement location="${build}"/>
        </path>
        <target name="prepare">
            <mkdir dir="${build}"/>
        </target>
        <target name="build-source" depends="prepare" description="compile the source ">
            <javac srcdir="${src}" destdir="${build}"/>
        </target>
        <target name="test" depends="build-source">
            <javac srcdir="${test}" destdir="${build}"/>
        </target>
    </project>When I try to import jUnit with these declarations:
    import org.junit.* ;
    import static org.junit.Assert.* ;
    public class MoneyTester {
    }it says "package org.junit does not exist" and I can't extend the TestCase class with my own test classes. Can anyone tell how to properly set the jUnit classpath?
    Much appreciated! Cheers, Vahagn

    I see what you mean. It now looks like this, but the error won't go away:
        <target name="build-source" depends="prepare" description="compile the source ">
            <javac srcdir="${src}" destdir="${build}">
                <classpath refid="_classpath"/>
            </javac>
        </target>
        <target name="test" depends="build-source">
            <javac srcdir="${test}" destdir="${build}">
                <classpath refid="_classpath"/>
            </javac>
        </target>Edited by: Vahagn on Aug 14, 2010 11:59 AM

  • Problems with ExcludeDoclet and Ant

    Greetings.
    I've been trying to use the ExcludeDoclet (http://java.sun.com/j2se/javadoc/excludedoclet/index.jsp)
    to generate docs for the classes that aren't excluded. My ant task looks like this:
    <target name="javadoc" depends="init"
            description="Build the javadoc in genericized form">
      <delete dir="${javadocdir}"/>
      <mkdir  dir="${javadocdir}"/>
      <javadoc packagenames="net.sf.jga.*,net.sf.jga.fn.*"
               sourcepathref="project.sourcepath"
               source="1.5"
               defaultexcludes="yes"
               destdir="${javadocdir}"
               version="true"
               overview="${basedir}/src/overview.html"
               windowtitle="jga: Java Generic Algorithms">
        <doctitle><![CDATA[<h1>jga: Generic Algorithms for Java</h1>]]></doctitle>
        <bottom><![CDATA[<i>Copyright � 2002-2005  David A. Hall. All Rights Reserved.</i>]]>
        </bottom>
        <classpath>
          <pathelement path="${jnlp.api}"/>
          <path refid="project.classpath"/>
        </classpath>
        <doclet name="tools.ExcludeDoclet" path=".">
            <param name="-excludefile" value="visitors.txt"/>
         </doclet>
       </javadoc>
      <jar jarfile="${javadocjar}" basedir="${javadocdir}"/>
    </target>I've also tried the form where the doclet information is passed as attributes of the javadoc tag, and I've tried skipping ant by building a shell script with the same collection of arguments. In all cases, I get output indicating that the ExcludeDoclet has successfully read the file, processed the list of classes in the indicated packages, and removed those from the visitors.txt file. It appears, however, that once the excluded list of source files has been procesed, javadoc exits without processing the remaining files.
    javadoc:
       [delete] Deleting directory /home/dave/projects/jga/doc/javadoc
       [delete] Deleting directory /home/dave/projects/jga/doc/javadoc
        [mkdir] Created dir: /home/dave/projects/jga/doc/javadoc
      [javadoc] Generating Javadoc
      [javadoc] Executing '/opt/jdk1.5.0/bin/javadoc' with arguments:
      [javadoc] '-d'
      [javadoc] '/home/dave/projects/jga/doc/javadoc'
      [javadoc] '-overview'
      [javadoc] '/home/dave/projects/jga/src/overview.html'
      [javadoc] '-windowtitle'
      [javadoc] 'jga: Java Generic Algorithms'
      [javadoc] '-doctitle'
      [javadoc] '<h1>jga: Generic Algorithms for Java</h1>'
      [javadoc] '-bottom'
      [javadoc] '<i>Copyright � 2002-2005  David A. Hall. All Rights Reserved.</i>
      [javadoc]     '
      [javadoc] '-classpath'
      [javadoc] '/opt/jdk1.5.0/sample/jnlp/servlet/jnlp.jar:...'
      [javadoc] '-sourcepath'
      [javadoc] '/home/dave/projects/jga/src:/home/dave/projects/jga/build/src'
      [javadoc] '-doclet'
      [javadoc] 'tools.ExcludeDoclet'
      [javadoc] '-docletpath'
      [javadoc] '/home/dave/projects/jga:/opt/ant/lib/ant-launcher.jar:...'
      [javadoc] '-excludefile'
      [javadoc] 'visitors.txt'
      [javadoc] '-source'
      [javadoc] '1.5'
      [javadoc] 'net.sf.jga.fn'
      [javadoc] 'net.sf.jga.util'
      [javadoc] 'net.sf.jga.parser'
      [javadoc]
      [javadoc] The ' characters around the executable and arguments are
      [javadoc] not part of the command.
      [javadoc] Javadoc execution
      [javadoc] Loading source files for package net.sf.jga.fn...
      [javadoc] Loading source files for package net.sf.jga.util...
      [javadoc] Loading source files for package net.sf.jga.parser...
      [javadoc] Constructing Javadoc information...
      [javadoc] Removing excluded source files.......
      [javadoc] Excluding net.sf.jga.fn.adaptor.OrBinary.Visitor
      [javadoc] Excluding net.sf.jga.fn.adaptor.OrUnary.Visitor
      [javadoc] Excluding net.sf.jga.fn.string.DefaultFormat.Visitor
      [javadoc] Excluding net.sf.jga.fn.string.Match.VisitorDoes anyone have any ideas how I can get this to work?
    Dave Hall
    http://jga.sf.net/
    http://jroller.com/page/dhall/

    I'd read Ant's documentation as being able to
    include/exclude whole packages, but not individual
    classes within packages: I may have read it this was
    because I expect that ant is simply assembling the
    command line arguments that it'll pass to javadoc.
    My expectation was that if there is no way for
    javadoc proper to exclude individual classes, that
    there would be no way for ant to do it either.Taken straight from the documentation of the Javadoc task in the ANT Manual:
    Parameters specified as nested elements
    fileset
    A FileSet. All matched files will be passed to javadoc as source files. Ant will automatically add the include pattern **/*.java to these filesets.
    Nested filesets can be used to document sources that are in the default package or if you want to exclude certain files from documentation. If you want to document all source files and don't use the default package, packagesets should be used instead as this increases javadocs performance.
    The packagenames, excludepackagenames and defaultexcludes attributes of the task have no effect on the nested <fileset> elements.
    ...  <javadoc
               destdir="docs/api"
               author="true"
               version="true"
               use="true"
               windowtitle="Test API">
        <fileset dir="src" defaultexcludes="yes">
          <include name="com/dummy/test/**" />
          <exclude name="com/dummy/test/doc-files/**"/>
        </fileset>
        <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
        <bottom><![CDATA[<i>Copyright � 2000 Dummy Corp. All Rights Reserved.</i>]]></bottom>
        <tag name="todo" scope="all" description="To do:" />
        <group title="Group 1 Packages" packages="com.dummy.test.a*"/>
        <group title="Group 2 Packages" packages="com.dummy.test.b*:com.dummy.test.c*"/>
        <link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api/" packagelistLoc="C:\tmp"/>
        <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
      </javadoc>Although this example illustrates how to exclude whole directories, this technique works for files, too.
    How hard would it be to turn ExcludeDoclet into
    something that could be passed to javadoc on the
    command line?I don't think that is possible.
    IMHO, there are 3 options you might want to investigate:
    1. Use the fileset parameter of ANT's Javadoc task to exclude files by name.
    2. Use ANT's Java task to run ExcludeDoclet as an application from within ANT.
    3. Try yDoc (a commercial Javadoc enhancement that allows you to define custom filter criteria)  http://www.yworks.com/products/ydoc/Each of these options has its drawbacks:
    Suppose there are multiple classes defined in one source file (visible nested classes count, too), then you have to specify all these classes in the excludefile for ExcludeDoclet to actually exclude that file from documentation (it's either all or nothing for any given source file).
    Since the fileset parameter of ANT's Javadoc task is - well - file based, it will always exclude all classes in a given source file from documentation, so ExcludeDoclet's behavior might be preferable in a "better too much than too less documentation" way, but both lack, IMHO.
    yDoc actually allows you to exclude on a documentation element basis - although it does a poor job when handling references (i.e. hyperlinks) to the excluded elements.

  • Weblogic.rmic and ant integration issue

    I am trying to call weblogic.rmic compiler through a ant script and was
    sucessful in doing so and generating the stubs and skelton for my RMI
    implementation.
    But i also want to pass a system property value (in the example i am passing
    file=stdout using -D to java) to weblogic.rmi compiler and don't know how to
    do that.
    Any help will be greatly appreciated...
    Thanks
    Kunjan Jhaveri
    781-372-3965
    [email protected]
    PS: Script enclosed.
    <target name="local.genStubs" depends="local.compile">
    <java classname="weblogic.rmic" fork="yes" failonerror="yes">
    <jvmarg value="-Dfile=stdout" />
    <arg value="-classpath" />
    <arg value="${WL_HOME}${file.separator}lib${file.separator}weblogic.jar" />
    <arg value="-d" />
    <arg value="${SRCDIR}${file.separator}build${file.separator}classes" />
    <arg value="com.ehealthdirect.ee.kernel.EEMutexManagerImpl" />
    <classpath>
    <pathelement
    path="${WL_HOME}${file.separator}lib${file.separator}weblogic.jar" />
    </classpath>
    </java>
    </target>

    As far as I know, rmic doesn't know anything about a "file" system property. Is
    there some reason you expect this to do something special?
    Kunjan Jhaveri wrote:
    I am trying to call weblogic.rmic compiler through a ant script and was
    sucessful in doing so and generating the stubs and skelton for my RMI
    implementation.
    But i also want to pass a system property value (in the example i am passing
    file=stdout using -D to java) to weblogic.rmi compiler and don't know how to
    do that.
    Any help will be greatly appreciated...
    Thanks
    Kunjan Jhaveri
    781-372-3965
    [email protected]
    PS: Script enclosed.
    <target name="local.genStubs" depends="local.compile">
    <java classname="weblogic.rmic" fork="yes" failonerror="yes">
    <jvmarg value="-Dfile=stdout" />
    <arg value="-classpath" />
    <arg value="${WL_HOME}${file.separator}lib${file.separator}weblogic.jar" />
    <arg value="-d" />
    <arg value="${SRCDIR}${file.separator}build${file.separator}classes" />
    <arg value="com.ehealthdirect.ee.kernel.EEMutexManagerImpl" />
    <classpath>
    <pathelement
    path="${WL_HOME}${file.separator}lib${file.separator}weblogic.jar" />
    </classpath>
    </java>
    </target>

  • JUnit and Ant, ClassNotFound

    hi,
    I'm trying to let ant run a batch of JUnitCase's but I keep bumping in to strange problems: This is the script:<target name="junit">
      <junit printsummary="yes" haltonfailure="yes">
        <classpath>
          <pathelement location="V:\Workspace\Build\bin"/>
          <pathelement path="${java.class.path}"/>
        </classpath>
        <test name="calypsox.build.test.UtilTest"/>//This one works so obviously the classpath is ok
        <batchtest todir="v:\temp">
          <formatter type="brief"/>
           <fileset dir="V:\Workspace\Build\calypsox\build\test">
             <include name="**/*Test*.java"/>
           </fileset>
        </batchtest>
      </junit>
    </target>The single Test is performed ok, no problems, the batch-test however gives a srange error:
    Testsuite: UtilTest
    Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    Null Test:      Caused an ERROR
    UtilTest
    java.lang.ClassNotFoundException: UtilTest
    In the folder 'V:\Workspace\Build\calypsox\build\test' there is only 1 TestCase (for the moment): UtilTest.java. Obviously (from the error), the file is found and executed (It WAS a null-test) but gives an error stating that it can't find the class?
    Any ideas?
    tx,
    Stijn

    <project name="UtilTest" default="UtilTest" basedir=".">
      <target name="UtilTest">
        <javac  srcdir="."
                destdir="."
                defaultexcludes="no"
                includes="UtilTest.java"
                classpath="${java.class.path}"
                target="1.4"
                extdirs=""
             />
      </target>
    </project>I'm going to be honest, I'm not familiar with xml style you are using for your compilation. I'm assuming that the xml you are listing above is from your "build.xml" file?
    Above is a sample of a "build.xml" that I might use for the compilation. I'm not saying that my way is the best way, or even the only way, but it works for me.

  • Javelin and Ant trouble

    Hi All,
    I'm trying to run Ant with the generated Ant build file (Controls application). And when I run Ant I've got this output :
    Buildfile: build.xml
    check-jar:
    [echo] Controls.jar is not up-to-date. Running build
    build:
    [delete] Deleting directory C:\DOCUME~1\lacaes\LOCALS~1\Temp\wlw-temp-6760\wlw_compile6557
    [mkdir] Created dir: C:\DOCUME~1\lacaes\LOCALS~1\Temp\wlw-temp-6760\wlw_compile6557
    [javelin] Errors found in csf\fr\edi\exceptions\ExceptionDataBase.jcx:
    [javelin] Error at line 54 column 10:
    [javelin] void insertionErreur(final ImpErrRow errRow);
    [javelin] <------------->
    [javelin] Description: Validation class for this value was not provided or was not found.
    [javelin] Prescription: Verify that the validation class for this type is available.
    [javelin] Error at line 54 column 10:
    [javelin] void insertionErreur(final ImpErrRow errRow);
    etc.....
    Some topics talks about this problem but I never saw a response. When I run setDomainEnv.cmd before Ant everything works fine: so I sure it's a classpath problem but I don't see which one ?
    Thx for help :)

    Hi
    Which version of 8.1 are you using? You should not see the issue on the latest 8.1sp6
    We have seen such issue on 8.1sp2 when you use jdk1.4.2.
    There is a patch available on 8.1sp2 for the issue via CR139151. Please open a bea support case at http://bea.support.com if you need the patch.
    Vimala-

Maybe you are looking for

  • How can I have my T420s Serviced under my ThinkPlus Warranty?

    I have a T420s with 3 years of Thinkpad Plus Priority Support. Over a month has past and my computer is still not working correctly. Please review my story below and provide any advice you may have. Thank you. On August 19th while browsing the intern

  • A few questions I really need answered!

    Hello, my name is Ryan. My Mom bought me an iPod Classic [80GB Black] and I get to open it before Christmas to put Music on it, Charge it, etc. After reading that many iPod Classic owners are having problems, I need these questions answered: I have h

  • Connecting AirPort Express to AirPort Extreme 802.11n

    The following steps helped me set up an AirPort Express base station connected to a set of wireless speakers with my new AirPort Extreme 802.11n base station. I’m posting this because the process was not entirely intuitive, at least not to me. I’ll a

  • 3 Displays.. well sort of

    Hey there, I have a Mac Pro currently running 2 Monitors.. I upgraded to a Radeon 1900Xt video card from the standard Nvidia that came with it. I have just purchased a Wacom Cintiq 12 display tablet which needs to be connected to a Dvi port. I read a

  • Acknowledgments in scenario having enhanced interface determination

    Dear Experts, I have noticed that in case of Idoc sender scenarios where PI is having an enhanced interface determination, the acknowledgments are not sent back to R/3. Is this something standard or is there a way to enable the acknowledgements in th