You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Troy S <tr...@yahoo.com> on 2009/02/25 19:56:57 UTC

Can't find DocumentException

Hi Ant fans,

When I run codegen, I get the error can't find DocumentException.

The class file is in the jar file C:/java/dom4j-1.6.1/dom4j-1.6.1.jar

How do I track down why the class is not being picked up.

Troy

$ ant -verbose codegen
Apache Ant version 1.7.1 compiled on June 27 2008
Buildfile: build.xml
Detected Java version: 1.6 in: c:\Program Files\Java\jdk1.6.0_06\jre
Detected OS: Windows Vista
parsing buildfile c:\java\harnassinghibernate\examples\ch01\build.xml with
URI =
file:/c:/java/harnassinghibernate/examples/ch01/build.xml
Project base dir set to: c:\java\harnassinghibernate\examples\ch01
[antlib:org.apache.tools.ant] Could not load definitions from resource
org/apach
e/tools/ant/antlib.xml. It could not be found.
parsing buildfile
jar:file:/c:/java/apache-ant-1.7.1/lib/maven-ant-tasks-2.0.9.j
ar!/org/apache/maven/artifact/ant/antlib.xml with URI =
jar:file:/c:/java/apache
-ant-1.7.1/lib/maven-ant-tasks-2.0.9.jar!/org/apache/maven/artifact/ant/antlib.x
ml
[artifact:dependencies] Maven Ant Tasks version: 2.0.9
[artifact:dependencies] Using local repository: C:\Users\Troy S\.m2\rep
ository
[artifact:dependencies] Resolving dependencies...
[artifact:dependencies] Using remote repositories:
  - id=central, url=http://repo1.maven.org/maven2, releases=enabled,
snapshots=d
isabled
  - id=central, url=http://repo1.maven.org/maven2, releases=enabled,
snapshots=d
isabled
org.apache.maven:super-pom:jar:2.0 (selected)
  hsqldb:hsqldb:jar:1.8.0.7:compile (selected)
  org.hibernate:hibernate:jar:3.2.5.ga:compile (selected)
    net.sf.ehcache:ehcache:jar:1.2.3:compile (selected)
      commons-logging:commons-logging:jar:1.0.4:compile (selected)
      commons-collections:commons-collections:jar:2.1:compile (selected)
    commons-logging:commons-logging:jar:1.0.4:compile (removed - nearer
found: 1
.0.4)
    commons-logging:commons-logging:jar:1.0.4:compile (selected)
    asm:asm-attrs:jar:1.5.3:compile (selected)
    dom4j:dom4j:jar:1.6.1:compile (selected)
    antlr:antlr:jar:2.7.6:compile (selected)
    cglib:cglib:jar:2.1_3:compile (selected)
      asm:asm:jar:1.5.3:compile (selected)
    asm:asm:jar:1.5.3:compile (removed - nearer found: 1.5.3)
    asm:asm:jar:1.5.3:compile (selected)
    commons-collections:commons-collections:jar:2.1:compile (removed -
nearer fo
und: 2.1.1)
    commons-collections:commons-collections:jar:2.1.1:compile (selected)
  org.hibernate:hibernate-tools:jar:3.2.3.GA:compile (selected)
    org.beanshell:bsh:jar:2.0b4:compile (selected)
    freemarker:freemarker:jar:2.3.8:compile (selected)
    org.hibernate:jtidy:jar:r8-20060801:compile (selected)
  org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile (selected)
  log4j:log4j:jar:1.2.14:compile (selected)
dropping c:\java\harnassinghibernate\examples\ch01\classes from path as it
doesn
't exist
Build sequence for target(s) `codegen' is [codegen]
Complete build sequence is [codegen, db, print-classpath, ]

codegen:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)

BUILD FAILED
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
        at
org.hibernate.tool.ant.ConfigurationTask.createConfiguration(Configur
ationTask.java:62)
        at
org.hibernate.tool.ant.ConfigurationTask.getConfiguration(Configurati

<?xml version="1.0"?>
<project name="Harnessing Hibernate 3 (Developer's Notebook Second Edition)"
        default="db" basedir="."
        xmlns:artifact="antlib:org.apache.maven.artifact.ant">

  <!-- Set up properties containing important project directories -->
  <property name="source.root" value="src"/>
  <property name="class.root" value="classes"/>
  <property name="data.dir" value="data"/>

  <artifact:dependencies pathId="dependency.class.path">
    <dependency groupId="hsqldb" artifactId="hsqldb" version="1.8.0.7"/>
    <dependency groupId="org.hibernate" artifactId="hibernate"
                version="3.2.5.ga">
      <exclusion groupId="javax.transaction" artifactId="jta"/>
    </dependency>
    <dependency groupId="org.hibernate" artifactId="hibernate-tools"
                version="3.2.3.GA"/>
    <dependency groupId="org.apache.geronimo.specs"
                artifactId="geronimo-jta_1.1_spec" version="1.1"/>
    <dependency groupId="log4j" artifactId="log4j" version="1.2.14"/>
  </artifact:dependencies>

  <!-- Set up the class path for compilation and execution -->
  <path id="project.class.path">
      <!-- Include our own classes, of course -->
      <pathelement location="${class.root}" />
      <pathelement
location="c:/java/hibernate-distribution-3.3.1.GA/hibernate3.jar" />
      <pathelement location="C:/java/hsqldb1.8.0.10/hsqldb/lib/hsqldb.jar"
/>
      <pathelement location="C:/java/dom4j-1.6.1/dom4j-1.6.1.jar" />
      <!-- Add the dependencies classpath -->
      <path refid="dependency.class.path"/>
  </path>

 
  <!-- Teach Ant how to use the Hibernate Tools -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>

  <target name="db" description="Runs HSQLDB database management UI
against the database file--use when application is not running">
      <java classname="org.hsqldb.util.DatabaseManager"
            fork="yes">
        <classpath refid="project.class.path"/>
        <arg value="-driver"/>
        <arg value="org.hsqldb.jdbcDriver"/>
        <arg value="-url"/>
        <arg value="jdbc:hsqldb:${data.dir}/music"/>
        <arg value="-user"/>
   
        <arg value="sa"/>
      </java>
  </target>
<!-- Generate the java code for all mapping files in our source tree -->
<target name="codegen"
description="Generate Java source from the O/R mapping files">
<hibernatetool destdir="${source.root}">
<configuration>
<fileset dir="${source.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>
</target>
  <target name="print-classpath" description="Show the dependency class
path">
    <property name="class.path" refid="dependency.class.path"/>
    <echo>${class.path}</echo>
  </target>

</project>

-- 
View this message in context: http://www.nabble.com/Can%27t-find-DocumentException-tp22209309p22209309.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: Can't find DocumentException

Posted by Troy S <tr...@yahoo.com>.
Hi Milene,

I thought I was doing that with

 
  <!-- Teach Ant how to use the Hibernate Tools -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>

Is this not right?

Troy


mylene wrote:
> 
> Maybe you should add your classpath to your codegen too?
> 
> Mylène
> 
> 
> On Wed, Feb 25, 2009 at 7:56 PM, Troy S <tr...@yahoo.com> wrote:
> 
>>
>> Hi Ant fans,
>>
>> When I run codegen, I get the error can't find DocumentException.
>>
>> The class file is in the jar file C:/java/dom4j-1.6.1/dom4j-1.6.1.jar
>>
>> How do I track down why the class is not being picked up.
>>
>> Troy
>>
>> $ ant -verbose codegen
>>
> 
> 
>> <snip>
> 
> 
> 
>>
>> <target name="codegen"
>> description="Generate Java source from the O/R mapping files">
>> <hibernatetool destdir="${source.root}">
>> <configuration>
>> <fileset dir="${source.root}">
>> <include name="**/*.hbm.xml"/>
>> </fileset>
>> </configuration>
>> <hbm2java/>
>> </hibernatetool>
>> </target>
>>  <target name="print-classpath" description="Show the dependency class
>> path">
>>    <property name="class.path" refid="dependency.class.path"/>
>>    <echo>${class.path}</echo>
>>  </target>
>>
>> </project>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can%27t-find-DocumentException-tp22209309p22209309.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> 
> -- 
> Mylene
> 
> 

-- 
View this message in context: http://www.nabble.com/Can%27t-find-DocumentException-tp22209309p22231798.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: Can't find DocumentException

Posted by Mylene <my...@gmail.com>.
Maybe you should add your classpath to your codegen too?

Mylène


On Wed, Feb 25, 2009 at 7:56 PM, Troy S <tr...@yahoo.com> wrote:

>
> Hi Ant fans,
>
> When I run codegen, I get the error can't find DocumentException.
>
> The class file is in the jar file C:/java/dom4j-1.6.1/dom4j-1.6.1.jar
>
> How do I track down why the class is not being picked up.
>
> Troy
>
> $ ant -verbose codegen
>


> <snip>



>
> <target name="codegen"
> description="Generate Java source from the O/R mapping files">
> <hibernatetool destdir="${source.root}">
> <configuration>
> <fileset dir="${source.root}">
> <include name="**/*.hbm.xml"/>
> </fileset>
> </configuration>
> <hbm2java/>
> </hibernatetool>
> </target>
>  <target name="print-classpath" description="Show the dependency class
> path">
>    <property name="class.path" refid="dependency.class.path"/>
>    <echo>${class.path}</echo>
>  </target>
>
> </project>
>
> --
> View this message in context:
> http://www.nabble.com/Can%27t-find-DocumentException-tp22209309p22209309.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
Mylene

Re: Can't find DocumentException

Posted by da...@davidwbrown.name.
Hello Troy, maybe if you try this the following found at: http://ant.apache.org/manual/using.html


**********************************************************
You can specify PATH- and CLASSPATH-type references using both ":" and ";" as separator characters. Ant will convert the separator to the correct character of the current operating system.

Wherever path-like values need to be specified, a nested element can be used. This takes the general form of:

    <classpath>
      <pathelement path="${classpath}"/>
      <pathelement location="lib/helper.jar"/>
    </classpath>

The location attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path attribute accepts colon- or semicolon-separated lists of locations. The path attribute is intended to be used with predefined paths - in any other case, multiple elements with location attributes should be preferred.

As a shortcut, the <classpath> tag supports path and location attributes of its own, so:

    <classpath>
      <pathelement path="${classpath}"/>
    </classpath>

can be abbreviated to:

    <classpath path="${classpath}"/>

In addition, one or more Resource Collections can be specified as nested elements (these must consist of file-type resources only). Additionally, it should be noted that although resource collections are processed in the order encountered, certain resource collection types such as fileset, dirset and files are undefined in terms of order.

    <classpath>
      <pathelement path="${classpath}"/>
      <fileset dir="lib">
        <include name="**/*.jar"/>
      </fileset>
      <pathelement location="classes"/>
      <dirset dir="${build.dir}">
        <include name="apps/**/classes"/>
        <exclude name="apps/**/*Test*"/>
      </dirset>
      <filelist refid="third-party_jars"/>
    </classpath>

This builds a path that holds the value of ${classpath}, followed by all jar files in the lib directory, the classes directory, all directories named classes under the apps subdirectory of ${build.dir}, except those that have the text Test in their name, and the files specified in the referenced FileList.

If you want to use the same path-like structure for several tasks, you can define them with a <path> element at the same level as targets, and reference them via their id attribute--see References for an example.

A path-like structure can include a reference to another path-like structure (a path being itself a resource collection) via nested <path> elements:

    <path id="base.path">
      <pathelement path="${classpath}"/>
      <fileset dir="lib">
        <include name="**/*.jar"/>
      </fileset>
      <pathelement location="classes"/>
    </path>

    <path id="tests.path">
      <path refid="base.path"/>
      <pathelement location="testclasses"/>
    </path>

The shortcuts previously mentioned for <classpath> are also valid for <path>.For example:

    <path id="base.path">
      <pathelement path="${classpath}"/>
    </path>

can be written as:

    <path id="base.path" path="${classpath}"/>

Path Shortcut

In Ant 1.6 a shortcut for converting paths to OS specific strings in properties has been added. One can use the expression ${toString:pathreference} to convert a path element reference to a string that can be used for a path argument. For example:

  <path id="lib.path.ref">
    <fileset dir="lib" includes="*.jar"/>
  </path>
  <javac srcdir="src" destdir="classes">
    <compilerarg arg="-Xbootstrap/p:${toString:lib.path.ref}"/>
  </javac>

**********************************************************



Troy S wrote ..
> 
> Hi Ant fans,
> 
> When I run codegen, I get the error can't find DocumentException.
> 
> The class file is in the jar file C:/java/dom4j-1.6.1/dom4j-1.6.1.jar
> 
> How do I track down why the class is not being picked up.
> 
> Troy
> 
> $ ant -verbose codegen
> Apache Ant version 1.7.1 compiled on June 27 2008
> Buildfile: build.xml
> Detected Java version: 1.6 in: c:\Program Files\Java\jdk1.6.0_06\jre
> Detected OS: Windows Vista
> parsing buildfile c:\java\harnassinghibernate\examples\ch01\build.xml with
> URI =
> file:/c:/java/harnassinghibernate/examples/ch01/build.xml
> Project base dir set to: c:\java\harnassinghibernate\examples\ch01
> [antlib:org.apache.tools.ant] Could not load definitions from resource
> org/apach
> e/tools/ant/antlib.xml. It could not be found.
> parsing buildfile
> jar:file:/c:/java/apache-ant-1.7.1/lib/maven-ant-tasks-2.0.9.j
> ar!/org/apache/maven/artifact/ant/antlib.xml with URI =
> jar:file:/c:/java/apache
> -ant-1.7.1/lib/maven-ant-tasks-2.0.9.jar!/org/apache/maven/artifact/ant/antlib.x
> ml
> [artifact:dependencies] Maven Ant Tasks version: 2.0.9
> [artifact:dependencies] Using local repository: C:\Users\Troy S\.m2\rep
> ository
> [artifact:dependencies] Resolving dependencies...
> [artifact:dependencies] Using remote repositories:
>   - id=central, url=http://repo1.maven.org/maven2, releases=enabled,
> snapshots=d
> isabled
>   - id=central, url=http://repo1.maven.org/maven2, releases=enabled,
> snapshots=d
> isabled
> org.apache.maven:super-pom:jar:2.0 (selected)
>   hsqldb:hsqldb:jar:1.8.0.7:compile (selected)
>   org.hibernate:hibernate:jar:3.2.5.ga:compile (selected)
>     net.sf.ehcache:ehcache:jar:1.2.3:compile (selected)
>       commons-logging:commons-logging:jar:1.0.4:compile (selected)
>       commons-collections:commons-collections:jar:2.1:compile (selected)
>     commons-logging:commons-logging:jar:1.0.4:compile (removed - nearer
> found: 1
> .0.4)
>     commons-logging:commons-logging:jar:1.0.4:compile (selected)
>     asm:asm-attrs:jar:1.5.3:compile (selected)
>     dom4j:dom4j:jar:1.6.1:compile (selected)
>     antlr:antlr:jar:2.7.6:compile (selected)
>     cglib:cglib:jar:2.1_3:compile (selected)
>       asm:asm:jar:1.5.3:compile (selected)
>     asm:asm:jar:1.5.3:compile (removed - nearer found: 1.5.3)
>     asm:asm:jar:1.5.3:compile (selected)
>     commons-collections:commons-collections:jar:2.1:compile (removed -
> nearer fo
> und: 2.1.1)
>     commons-collections:commons-collections:jar:2.1.1:compile (selected)
>   org.hibernate:hibernate-tools:jar:3.2.3.GA:compile (selected)
>     org.beanshell:bsh:jar:2.0b4:compile (selected)
>     freemarker:freemarker:jar:2.3.8:compile (selected)
>     org.hibernate:jtidy:jar:r8-20060801:compile (selected)
>   org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile (selected)
>   log4j:log4j:jar:1.2.14:compile (selected)
> dropping c:\java\harnassinghibernate\examples\ch01\classes from path as it
> doesn
> 't exist
> Build sequence for target(s) `codegen' is [codegen]
> Complete build sequence is [codegen, db, print-classpath, ]
> 
> codegen:
> [hibernatetool] Executing Hibernate Tool with a Standard Configuration
> [hibernatetool] 1. task: hbm2java (Generates a set of .java files)
> 
> BUILD FAILED
> java.lang.NoClassDefFoundError: org/dom4j/DocumentException
>         at
> org.hibernate.tool.ant.ConfigurationTask.createConfiguration(Configur
> ationTask.java:62)
>         at
> org.hibernate.tool.ant.ConfigurationTask.getConfiguration(Configurati
> 
> <?xml version="1.0"?>
> <project name="Harnessing Hibernate 3 (Developer's Notebook Second Edition)"
>         default="db" basedir="."
>         xmlns:artifact="antlib:org.apache.maven.artifact.ant">
> 
>   <!-- Set up properties containing important project directories -->
>   <property name="source.root" value="src"/>
>   <property name="class.root" value="classes"/>
>   <property name="data.dir" value="data"/>
> 
>   <artifact:dependencies pathId="dependency.class.path">
>     <dependency groupId="hsqldb" artifactId="hsqldb" version="1.8.0.7"/>
>     <dependency groupId="org.hibernate" artifactId="hibernate"
>                 version="3.2.5.ga">
>       <exclusion groupId="javax.transaction" artifactId="jta"/>
>     </dependency>
>     <dependency groupId="org.hibernate" artifactId="hibernate-tools"
>                 version="3.2.3.GA"/>
>     <dependency groupId="org.apache.geronimo.specs"
>                 artifactId="geronimo-jta_1.1_spec" version="1.1"/>
>     <dependency groupId="log4j" artifactId="log4j" version="1.2.14"/>
>   </artifact:dependencies>
> 
>   <!-- Set up the class path for compilation and execution -->
>   <path id="project.class.path">
>       <!-- Include our own classes, of course -->
>       <pathelement location="${class.root}" />
>       <pathelement
> location="c:/java/hibernate-distribution-3.3.1.GA/hibernate3.jar" />
>       <pathelement location="C:/java/hsqldb1.8.0.10/hsqldb/lib/hsqldb.jar"
> />
>       <pathelement location="C:/java/dom4j-1.6.1/dom4j-1.6.1.jar" />
>       <!-- Add the dependencies classpath -->
>       <path refid="dependency.class.path"/>
>   </path>
> 
>  
>   <!-- Teach Ant how to use the Hibernate Tools -->
> <taskdef name="hibernatetool"
> classname="org.hibernate.tool.ant.HibernateToolTask"
> classpathref="project.class.path"/>
> 
>   <target name="db" description="Runs HSQLDB database management UI
> against the database file--use when application is not running">
>       <java classname="org.hsqldb.util.DatabaseManager"
>             fork="yes">
>         <classpath refid="project.class.path"/>
>         <arg value="-driver"/>
>         <arg value="org.hsqldb.jdbcDriver"/>
>         <arg value="-url"/>
>         <arg value="jdbc:hsqldb:${data.dir}/music"/>
>         <arg value="-user"/>
>    
>         <arg value="sa"/>
>       </java>
>   </target>
> <!-- Generate the java code for all mapping files in our source tree -->
> <target name="codegen"
> description="Generate Java source from the O/R mapping files">
> <hibernatetool destdir="${source.root}">
> <configuration>
> <fileset dir="${source.root}">
> <include name="**/*.hbm.xml"/>
> </fileset>
> </configuration>
> <hbm2java/>
> </hibernatetool>
> </target>
>   <target name="print-classpath" description="Show the dependency class
> path">
>     <property name="class.path" refid="dependency.class.path"/>
>     <echo>${class.path}</echo>
>   </target>
> 
> </project>
> 
> -- 
> View this message in context: http://www.nabble.com/Can%27t-find-DocumentException-tp22209309p22209309.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org