-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: XDoclet Problem: No hbm.xml file generated [newbie]
PostPosted: Sat Sep 18, 2004 9:34 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
The XDoclet tool is not generating the hbm.xml files.
Here is what I did:

I downloaded xdoclet-1.2.2-SNAPSHOT
In my src foler, I put the:
xdoclet-1.2.2-SNAPSHOT\docs\ant\xdoclet folder

so now there's an src\xdoclet folder

In my lib directory I created a folde called xdoclet and in it I put the *.jar files from the xdoclet-1.2.2-SNAPSHOT\lib folder.

In my classpath I included the tools.jar file from my C:\j2sdk1.4.2_04\lib
in my CLASSPATH.


I also dl ANT and created a System environment variable called ANT_HOME with the C:\apache-ant-1.6.2-bin

In my PATH environemtn variable I included
%ANT_HOME%\bin

It does not seem like the HibernateDoclet is generating hbm.xml files.

Here is my build.xml file:

<?xml version="1.0"?>
<project name="test" default="compile" basedir=".">
<property name="source.root" value="src"/>
<property name="class.root" value="classes"/>
<property name="lib.dir" value="lib"/>
<property name="generated.home" value="generated"/>


<!-- Set up the class path for compilation and execution -->
<path id="project.class.path">
<!-- Include our own classes, of course -->
<pathelement location="${class.root}" />
<!-- Include jars in the project library directory -->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<pathelement path="${class.root}"/>
</path>

<path id="xdoclet.lib.path">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}/xdoclet">
<include name="*.jar"/>
</fileset>
</path>




<!-- Create our runtime subdirectories and copy resources into them -->
<target name="prepare" description="Sets up build structures">
<mkdir dir="${class.root}"/>
<mkdir dir="${generated.home}"/>

<!-- Copy our property files and O/R mappings for use at runtime -->
<copy todir="${class.root}" >
<fileset dir="${source.root}" >
<include name="**/*.properties"/>
</fileset>
</copy>
</target>

<!-- Compile the java source of the project -->
<target name="compile" depends="prepare"
description="Compiles all Java classes">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on"
classpathref="project.class.path">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${class.root}"/>
</classpath>
</javac>
</target>

<target name="generate" description="Generates Hibernate class descriptor files." depends="compile">
<!-- Define the hibernatedoclet task -->
<taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask" classpathref="xdoclet.lib.path"/>

<!-- Execut the hibernatedoclet task -->
<hibernatedoclet
destdir="${generated.home}"
excludedtags="@version,@author,@todo"
force="${generated.forced}"
mergedir="${generated.home}"
verbose="false">

<fileset dir="${source.root}">
<include name="**/*.java"/>
</fileset>

<hibernate version="2.0"/>

</hibernatedoclet>
</target>



</project>


When I type: 'ant generate' into the command line
I get:

C:\hibernate-2.1\practice9>ant generate
Buildfile: build.xml

prepare:
[mkdir] Created dir: C:\hibernate-2.1\practice9\classes
[mkdir] Created dir: C:\hibernate-2.1\practice9\generated
[copy] Copying 3 files to C:\hibernate-2.1\practice9\classes

compile:
[javac] Compiling 2 source files to C:\hibernate-2.1\practice9\classes

generate:
[hibernatedoclet] log4j:WARN No appenders could be found for logger (xdoclet.uti
l.Translator.getString).
[hibernatedoclet] log4j:WARN Please initialize the log4j system properly.

BUILD SUCCESSFUL
Total time: 14 seconds


So it BUILDS SUCCESSFUL but there is no hbm.xml files generated.
Why would that be?



Thank you,
John


Top
 Profile  
 
 Post subject: same problem
PostPosted: Sat Nov 20, 2004 2:44 pm 
Newbie

Joined: Sat Nov 20, 2004 2:26 pm
Posts: 5
I am having the same trouble.

My setup is as follows:
-ant 1.6.2
-xdoclet 1.2.2
-hibernate 2.1
-eclipse 3.0.1

I have the hibernatedoclet task defined in Eclipse, rather than in the build file, because I couldn't get ant to find the task class with the more common (and robust) method.

I have a simple pojo like (names have been changed to protect the innocent, but the structure is the same):
/**
* @hibernate.class table="dogs"
*/
public class Dog {

...

/**
* @hibernate.id column="dog_id" generator="increment"
*/
public long getId() {
return this.id;
}

...
}

and an ant-file something like (see above):
<project name="PetStore" basedir="." default="hibernate">
<property name="project.dir" value="c:/projects/PetStore" />
<property name="src.dir" value="${project.dir}/com/petstore" />
<property name="report.dir" value="${project.dir}/report" />
<property name="build.dir" value="${project.dir}/build" />
<property name="web-inf.dir" value="${build.dir}/WEB-INF" />
<property name="lib.dir" value="${web-inf.dir}/lib" />

<property name="merge.dir" value="${web-inf.dir}/merge"/>
<property name="classes.dir" value="${web-inf.dir}/classes" />
<property name="libs.dir" value="${web-inf.dir}/lib" />

<target name="hibernate" description="have XDoclet create Hibernate xml files">
<hibernatedoclet destDir="${classes.dir}"
force="true"
excludedtags="@version,@author,@todo"
verbose="true">

<fileset dir="${src.dir}" />

<!-- generate hbm files for each java class -->
<hibernate version="2.0" />

<!-- generate the global hibernate.cfg.xml --><!--
<hibernatecfg jndiName="/jndi/PetStoreHibernateFactory"
driver="org.hsqldb.jdbcDriver"
poolSize="4"
jdbcUrl="jdbc:hsqldb:."
userName="sa"
password=""
showSql="true"
dialect="net.sf.hibernate.dialect.HSQLDialect"
destDir="${classes.dir}" />-->
</hibernatedoclet>
</target>

</project>

When I run ant from within eclipse, I get
---
Buildfile: c:\projects\NewOrleans\developmentBuild.xml
hibernate:
[hibernatedoclet] (XDocletMain.start 47 ) Running <hibernate/>
BUILD SUCCESSFUL
Total time: 5 seconds
---

If I uncomment the hibernatecfg subtask, I get
---
Buildfile: c:\projects\NewOrleans\developmentBuild.xml
hibernate:
[hibernatedoclet] (XDocletMain.start 47 ) Running <hibernate/>
[hibernatedoclet] (XDocletMain.start 47 ) Running <hibernatecfg/>
[hibernatedoclet] Generating hibernate.cfg.xml configuration file
BUILD SUCCESSFUL
Total time: 5 seconds
---

So I know it's finding the task, it's just not building any hbm files. Does anyone have any thoughts? I've been banging my head against this one for hours. The things I've checked, or at least I think I have:
-the @hibernate tags are within javadoc-type comments, not just /* */ comments
-the ${src.dir} includes the java files
-the <hibernate> subtask is actually getting called
-Dog.java is not excluded from the path

I've even tried limiting the <fileset> to this one file, with no success.

Thanks for any help,
James


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 20, 2004 11:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Check out the Tools Workshop presentation from a year ago. Older versions of the tools but they do work so it may help provide the answers.
http://hibernate.bluemars.net/159.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 22, 2004 10:59 am 
Newbie

Joined: Mon Nov 22, 2004 10:58 am
Posts: 1
I have the same problem and it is slowly driving me insane. Anyway, I don't get any error output at all, Ant just finishes the build procedure correctly with the little exception of no class descriptors being generated.

My configuration:
Ant 1.6.2 (also tried with 1.5.3)
XDoclet 1.2.2
Hibernate 2.1.6
Eclipse 3.1 M2 (also ran Ant from the console)

Here is the Ant output of a typical run:

Code:
Buildfile: D:\smvonline\sourcen\SMV Online\build.xml
compile:
generate:
[hibernatedoclet] (XDocletMain.start                   47  ) Running <hibernate/>
BUILD SUCCESSFUL
Total time: 7 seconds


And here is an excerpt of my build.xml containing the relevant parts:

Code:
<!-- properties -->
<property name="web.inf" value="./WEB-INF" />
<property name="src.home" value="${web.inf}/src" />
<property name="bin.home" value="${web.inf}/classes" />
<property name="lib.home" value="./lib" />
<property name="lib.export" value="${web.inf}/lib" />
<property name="generated.home" value="./hibernate" />
<property name="generated.forced" value="${generated.home}/forced" />
<property name="entity.home" value="${src.home}/de/allianz/smvonline/entity" />
<property name="tomcat.home" value="D:/smvonline/tomcat" />
   
<!-- paths -->
<path id="xdoclet.classpath">
   <fileset dir="${entity.home}">
      <include name="**/*.class" />
   </fileset>
   <fileset dir="${lib.home}">
        <include name="*.jar" />
    </fileset>
   <fileset dir="${lib.export}">
      <include name="*.jar" />
   </fileset>
</path>

<!-- taskdefs -->
<taskdef name="hibernatedoclet"
    classname="xdoclet.modules.hibernate.HibernateDocletTask">
    <classpath refid="xdoclet.classpath" />
</taskdef>

<!-- generate target -->
<target
   name="generate"
   description="Generates Hibernate mapping files from XDoclet markup"
   depends="compile"
>
   <hibernatedoclet
       destdir="${generated.home}"
       excludedtags="@version,@author,@todo"
       force="${generated.forced}"
       mergedir="${generated.home}"
       verbose="true">
       <fileset dir="${entity.home}">
           <include name="**/*.java" />
       </fileset>
       <hibernate version="2.0"/>
   </hibernatedoclet>
</target>


Interestingly, when I change the path entry pointing to ${entity.home} (the package dir where my hibernate persistent classes are located) to ${bin.home} (the root directory of all compiled java classes), I get the following output:

Code:
Buildfile: D:\smvonline\sourcen\SMV Online\build.xml
compile:
generate:
[hibernatedoclet] java.util.zip.ZipException: error in opening zip file
[hibernatedoclet] at java.util.zip.ZipFile.open(Native Method)
[hibernatedoclet] at java.util.zip.ZipFile.<init>(Unknown Source)
[hibernatedoclet] at java.util.zip.ZipFile.<init>(Unknown Source)
[hibernatedoclet] at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:902)
[hibernatedoclet] at org.apache.tools.ant.AntClassLoader.getResource(AntClassLoader.java:831)
[hibernatedoclet] at org.apache.log4j.helpers.Loader.getResource(Loader.java:91)
[hibernatedoclet] at org.apache.log4j.LogManager.<clinit>(LogManager.java:94)
[hibernatedoclet] at org.apache.log4j.Logger.getLogger(Logger.java:85)
[hibernatedoclet] at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
.
.
.
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:326)
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:182)
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:158)
[hibernatedoclet] at org.apache.tools.ant.Task.perform(Task.java:363)
[hibernatedoclet] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatedoclet] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatedoclet] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:386)
[hibernatedoclet] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:136)
[hibernatedoclet] (XDocletMain.start                   47  ) Running <hibernate/>
BUILD SUCCESSFUL
Total time: 2 seconds


Again, no class descriptors are being generated...


Top
 Profile  
 
 Post subject: [hibernatedoclet] java.util.zip.ZipException / classloader?
PostPosted: Fri Dec 02, 2005 1:57 pm 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
hibernate.version=3.1
xdoclet.version=1.2.3
ant.version=1.6.5
java.version=1.4.2_09
eclipse.version=3.1

A few weeks ago, I tried to use the Hibernate SchemaExport Ant task and ran into a classloader problem. I can't recall exactly what class it couldn't find - but I googled and found a number of people with the same problem. Did not find a resolution.

The problem I'm having now:

This target runs and the output says successfully, but the *.hbm.xml files are not being generated. I'll post the verbose message below the target.

Code:
<target name="generate-hbm" depends="compile" description="--> Xdoclet to build hibernate mapping file">
        <taskdef name="hibernatedoclet"
           classname="xdoclet.modules.hibernate.HibernateDocletTask"
           classpathref="runtime.classpath" />
   
     <hibernatedoclet destdir="${build.classes.dir}" verbose="true">
        <fileset dir="${src.java.dir}">
           <include name="**/*.java" />
        </fileset>
     </hibernatedoclet>
</target>


... verbose message
[hibernatedoclet] java.util.zip.ZipException: error in opening zip file
[hibernatedoclet] at java.util.zip.ZipFile.open(Native Method)
[hibernatedoclet] at java.util.zip.ZipFile.<init>(ZipFile.java:111)
[hibernatedoclet] at java.util.zip.ZipFile.<init>(ZipFile.java:127)
[hibernatedoclet] at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:919)
[hibernatedoclet] at org.apache.tools.ant.AntClassLoader.getResource(AntClassLoader.java:832)
[hibernatedoclet] at org.apache.log4j.helpers.Loader.getResource(Loader.java:100)
[hibernatedoclet] at org.apache.log4j.LogManager.<clinit>(LogManager.java:103)
[hibernatedoclet] at org.apache.log4j.Logger.getLogger(Logger.java:103)
[hibernatedoclet] at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
[hibernatedoclet] at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:65)
[hibernatedoclet] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[hibernatedoclet] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[hibernatedoclet] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[hibernatedoclet] at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
[hibernatedoclet] at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
[hibernatedoclet] at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
[hibernatedoclet] at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)
[hibernatedoclet] at xdoclet.util.LogUtil.getLog(LogUtil.java:26)
[hibernatedoclet] at xdoclet.ConfigParamIntrospector.fillConfigParamsHashMapUsingReflectionFor(ConfigParamIntrospector.java:140)
[hibernatedoclet] at xdoclet.ConfigParamIntrospector.fillConfigParamsFor(ConfigParamIntrospector.java:102)
[hibernatedoclet] at xdoclet.DocletTask.getConfigParams(DocletTask.java:442)
[hibernatedoclet] at xdoclet.DocletTask.createContext(DocletTask.java:622)
[hibernatedoclet] at xdoclet.DocletTask.validateSubTasks(DocletTask.java:524)
[hibernatedoclet] at xdoclet.DocletTask.validateOptions(DocletTask.java:498)
[hibernatedoclet] at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:89)
[hibernatedoclet] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatedoclet] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatedoclet] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatedoclet] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatedoclet] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[hibernatedoclet] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[hibernatedoclet] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[hibernatedoclet] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[hibernatedoclet] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[hibernatedoclet] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

Thanks for your feedback.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 11:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Configuration is hard to sort out via a forum like this. Maybe another (limited) tools demo is in order. XDoclet does work fine - I would suggest you download one of the example (or otherwise) applications that are on the Wiki (or the net) as many have used XDoclet.


Top
 Profile  
 
 Post subject: XDoclet not working for me either
PostPosted: Mon Dec 12, 2005 7:46 pm 
Newbie

Joined: Sat Nov 26, 2005 5:39 am
Posts: 5
Location: Cumbria, UK
Hi,

I am having a similar problem to the others...it seems to say it works, but I can't find any hbm.xml files generated. Has anyone come up with a solution yet?

And I'm sure XDoclet does work, its just knowing the trick with the ANT task.

That, and not being able to buy the XDoclet e-book - its been a really frustrating evening.

-david


Top
 Profile  
 
 Post subject: XDoclet Wiki down
PostPosted: Mon Dec 12, 2005 7:47 pm 
Newbie

Joined: Sat Nov 26, 2005 5:39 am
Posts: 5
Location: Cumbria, UK
Trouble is, the XDoclet Wiki is offline at the mo'. Something about being spammed. There are some prats on the Internet, aren't there?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 11:39 am 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
Sorry, I should have posted this fix before...

I had two problems:

(1) I didn't have this element in the taskdef - <hibernate version="3.0" />
(2) In runtime.classpath I had a <path refid...> to what I call project.classpath (the location of my .class files). In project.classpath I *was* using a fileset like this:
Code:
<fileset dir="${build.classes.dir}">
   <include name="**/*.class"/>
</fileset>    


(DON'T DO THIS) just use a pathelement as listed below.

Code:
<path id="project.classpath">
  <pathelement location="${build.classes.dir}" />
</path>


Code:
<path id="runtime.classpath">
  <path refid="project.classpath" />
  <path refid="hibernate.classpath" />
  <path refid="xdoclet.classpath" />
  <pathelement location="${jdbc.driver.jar}" />
<!--   this pathelement is needed to pick up
         the hibernate configuration file (hibernate.cfg.xml)   -->
  <pathelement location="${src.java.dir}" />
</path>


Code:
<target name="generate-hbm" depends="compile" description="--> Xdoclet to build hibernate mapping file">
  <taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask" classpathref="runtime.classpath" />
  <hibernatedoclet destdir="${build.classes.dir}" verbose="true">
    <fileset dir="${src.java.dir}">
        <include name="**/*.java" />
    </fileset>
   <hibernate version="3.0" />
  </hibernatedoclet>
</target>


Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 8:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Glad you have it working. I suggest you use the CVS version as it has many more enhancements than the current 1.2.3 release. But if you find all your needs are covered then great. BTW: Thanks for following up on your solution.


Top
 Profile  
 
 Post subject: Thankyou mr ruffin - credit to you.
PostPosted: Thu Dec 15, 2005 12:52 pm 
Newbie

Joined: Sat Nov 26, 2005 5:39 am
Posts: 5
Location: Cumbria, UK
Thanks for your detailed reply. It is probably the lack of a reference to the hibernate.cfg.xml that is throwing my task and making it not do anything. I will try it this evening.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.