-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can not generate ".hbm.xml" from a java source cod
PostPosted: Sun Feb 05, 2006 8:23 pm 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
Hello,

Please help... I can not generate a ".hbm.xml" file from a java source file ".java" using XDoclet1.2 with Hibernate3.1.2 using Apache-ant-1.6.5 running upon WindowsXP. When I run Ant I can see the following messages on the screen, but I do not see an expected ".hbm.xml" file as an output. Is there anything I'm missing here?

---- Screen -----
> ant xdoclet
Buildfile: build.xml

xdoclet:
[xdoclet] (XDocletMain.start 47 ) Running <hibernate/>

BUILD SUCCESSFUL
Total time: 2 seconds
---- End of Screen ----

Following is a snippet from build.xml I used for this:

<target name="xdoclet">
<taskdef name="xdoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath refid="classpath" />
</taskdef>
<xdoclet
destdir="${output}"
excludedtags="@version,@author,@todo"
force="false"
mergedir="${output}"
verbose="true">
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
<hibernate version="3.0" />
</xdoclet>
</target>

I searched through all the information available in the Internet, read the book, Hibernate in action, and tried everything I could. However, I could not solve this problem even after spending 3 days; I'm completely exhausted and desperately need a help.

I really appreciate your help,
Keisuke Seya


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 2:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Here a snipit from an older project. Most of the time it an environment issue.


Code:
    <taskdef name="hibernatedoclet"
        classname="xdoclet.modules.hibernate.HibernateDocletTask"
        classpathref="libs"/>


and the Task
Code:
    <target name="hbmxdoclet"
        description="Generates Hibernate mapping files with XDoclet.">

        <hibernatedoclet
            destdir="${src.dir}"
            excludedtags="@version,@author,@todo"
            force="true"
            mergedir="${build.dir}"
            verbose="false">

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

            <hibernate version="3.0"/>

        </hibernatedoclet>

    </target>


I do suggest you use XDoclet 1.2.3 or later. Best to use the CVS version for the latest support of H3 (until 1.3.x comes out).

BTW: Try the tools forum next time.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 10:55 am 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
david,

Thank you for the snippet. I copied, modified, and put it into my build.xml but I still do not get the generated ".hbm.xml". I have "Message.java" under "src" directory and build.xml one directory above. Running Ant I'm hoping to get "Message.hbm.xml" under the src directory but I don't find any generated file there. I agree that most of the time it an environment issue, but I know Ant is finding "xdoclet.modules.hibernate.HibernateDocletTask" properly. Every time I run Ant with the command, "ant hbmxdoclet", I get "BUILD SUCCESSFUL" message.

I'm using the following snippet, which is basically identical to yours:

Taskdef
Code:
    <taskdef name="hibernatedoclet"
        classname="xdoclet.modules.hibernate.HibernateDocletTask">
        <classpath refid="classpath" />
    </taskdef>


and Task
Code:
    <target name="hbmxdoclet"
        description="Generates Hibernate mapping files with XDoclet.">
        <hibernatedoclet
            destdir="${src}"
            excludedtags="@version,@author,@todo"
            force="true"
            mergedir="${build}"
            verbose="true">
            <fileset dir="${src}">
                <include name="**/*.java"/>
            </fileset>
            <hibernate version="3.0"/>
        </hibernatedoclet>
    </target>


I tested the same build.xml with the same configuration (XDoclet1.2.3, Hibernate3.1.2, Apache-ant-1.6.5) upon both Linux and WinXP but no success. I have no clue for what's going here... Is there anything else I should check? I appreciate any advice.

BTW. I will post this kind of tool related topics to the TOOL forum next time.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 11:58 pm 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
By getting a strong help from david, I was able to identify the root cause of this problem. It was the "package" declaration that was causing this nasty problem. I would like to share my experience with people who would face to the same problem in future. Following is the story...

I had <property> tags in build.xml like below:

Code:
<project name="Xdoclet-Hibernate" default="all" basedir=".">
    <property name="src" value="src" />
    <property name="lib" value="lib" />
    <property name="output" value="classes" />
    <property name="build" value="build" />


And the Java source code (partial) was like below

Code:
package src;

/**
* Message Class
*
* @hibernate.class table="message"
*/

public class Message {
public Long id;
private String text;
private Message nextMessage;

private Message() {}
public Message(String text) {
  this.text = text;
}


I put this source code under the "src" directory. It was wrong! ".hbm.xml" will be generated if one of the followings is deployed:

1) Create a new directory "src" under the "src" directory and put the source code under /src/src. By doing this Ant will understand that the source code is properly placed under the "src package".

2) Removed the line, "package src;", from the source code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.