-->
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.  [ 6 posts ] 
Author Message
 Post subject: XDoclet does not generate ".hbm.xml" from a Java s
PostPosted: Mon Feb 06, 2006 9:35 pm 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
I 'm trying to generate ".hbm.xml" from a Java source code using the tool chain, XDoclet1.2.3, Hibernate3.1.2 and Apache-ant-1.6.5, but so far I have no success. I thought this is a very simple process but somehow I can not get out this hell for the last four days. I'm so exhausted. Please help...

Following is the snippet I use for this.

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 have "Message.java" under the src directory and "build.xml" one directory above. I'm hoping to get "Message.hbm.xml" under the src directory by running Ant with the command, "ant hbmxdoclet". However, XDoclet does not generate any file even though Ant finds "xdoclet.modules.hibernate.HibernateDocletTask" properly and gives me the "BUILD SUCCESSFUL" message on the screen.

I've tested the same thing on both Linux and WinXP but the result is the same. Am I doing something worng here? Is there anything else I should check? I appreciate any advice.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 4:01 pm 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
Sounds like a classpath issue. Make sure the path to your compiled .class files are in your <classpath refid="classpath">.

See the last few posts here:
http://forum.hibernate.org/viewtopic.php?t=934609&highlight=

Also, the hibernate-tools would be another solution - Eclipse/Ant. <hbm2hbmxml />

Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 6:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If you create a very very small project as a sample and send it to me I will have a look at it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 4:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have sent you the changes and it works now.
There were 3 items that were wrong.
1) Project organisation
2) build.xml has a few problems
3) The XDoclet markup was not correct in most places.

I know its alot to learn but you should be on your way now.


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

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

Thank you very much for your strong help. As I have a proper set of working files you sent to me, 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  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 10:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your welcome.


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