-->
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: XDoclet problem
PostPosted: Tue Mar 30, 2004 6:35 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
I use JBuilder 8 as my IDE, which has Ant 1.5.1, but Ant is not it's default build facility, so I've never had the fortune of using Ant or XDoclet before.

That being said, I'm posting here, rather than in the tools forum :-)

First off, I'm noticing that Ant xml files, when Ant is invoked by JBuilder, do not seem to get passed pretty much any of the default variables you always see in Ant scripts (${lib.dir}, etc)

So in order to get it to work, I had to set alot of these variables myself. Fine Fine...

So the Ant script runs without complaining, but it does not generate ANY hbm.xml files. I've tweaked the script to look for a *single* boring hibernated java class, and still no joy.

I know Ant is finding my source files because it warns me about a Class reference that wasn't fully qualified (guessing correctly that it was in the same package as the current class). I removed that class reference, and didn't get the complaint, but got no hbm.xml files either. (Fwiw, when I change the build script to have a mispelled class name, Ant again does not complain.

Here's my ant build xml file and resulting messages from Ant.

Anyone see any obvious flaws? Advice?

TIA

Code:
<?xml version="1.0" encoding="UTF-8"?>

<project name="bb" default="generate-hibernate" basedir=".">
<property name="src.dir" value=".\src\bb\model" />
<property name="hibernate.dir" value=".\src\bb\model\tmp" />
<property name="merge.dir" value=".\src\bb\model" />
<property name="xdoclet.lib.dir" value="C:\jbuilder8\thirdparty\xdoclet-1.2\lib" />
<property name="lib.dir" value="C:\jbuilder8\lib" />

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

  <target name="generate-hibernate">
    <taskdef name="hibernatedoclet"
        classname="xdoclet.modules.hibernate.HibernateDocletTask"
        classpathref="xdoclet.lib.path" />

    <!-- Generate Hibernate mapping files -->
    <hibernatedoclet destdir="${hibernate.dir}"
        mergeDir="${hibernate.dir}">
      <fileset dir="${src.dir}">
        <include name="Transaction.java" />
      </fileset>

      <hibernate version="2.0" />
    </hibernatedoclet>
  </target>
</project>


Code:
      Apache Ant version 1.5.1 compiled on October 2 2002
      Buildfile: build-hibernate.xml
      Detected Java version: 1.4 in: C:\JBuilder8\jdk1.4\jre
      Detected OS: Windows XP
      parsing buildfile build-hibernate.xml with URI = file:C:/Documents and Settings/critter/jbproject/bb/build-hibernate.xml
      Project base dir set to: C:\Documents and Settings\critter\jbproject\bb
      Build sequence for target `generate-hibernate' is [generate-hibernate]
      Complete build sequence is [generate-hibernate]
     
      generate-hibernate:
      [hibernatedoclet] (ModuleFinder.findModules            179 ) There is an entry on XDoclets classpath that doesn't exist: {0}. Ignoring it
      [hibernatedoclet] (XDocletMain.start                   47  ) Running <hibernate/>
      [hibernatedoclet] INFO:    Some classes refer to other classes that were not found among the sources or on the classpath.
      [hibernatedoclet]          (Perhaps the referred class doesn't exist? Hasn't been generated yet?)
      [hibernatedoclet]          The referring classes do not import any fully qualified classes matching these classes.
      [hibernatedoclet]          However, since no packages are imported, xjavadoc has assumed that the referred classes
      [hibernatedoclet]          belong to the same package as the referring class. The classes are:
      [hibernatedoclet] C:\Documents and Settings\critter\jbproject\bb\src\bb\model\Transaction.java --> Auditable qualified to bb.model.Auditable
      [hibernatedoclet] C:\Documents and Settings\critter\jbproject\bb\src\bb\model\Transaction.java --> Auditable qualified to bb.model.Auditable
     
      BUILD SUCCESSFUL
      Total time: 3 seconds


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 6:48 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
Class follows too.

I've also tried moving the basedir such that it begins in "src".

I am running out of bullets. Remember "extends Auditable" is optional.

Code:
package bb.model;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;


/**
* @author Hibernate CodeGenerator
* @hibernate.class table="Transaction"
*/
public class Transaction extends Auditable implements Serializable {

    /** identifier field */
    private java.lang.Integer transactionId;

    /** nullable persistent field */
    private String extTransactionId;

    /** nullable persistent field */
    private String parentExtTransactionId;

    /** nullable persistent field */
    private double amount;

    /** nullable persistent field */
    private String status;

    private String receiverEmail;

    /** nullable persistent field */
    private String method;

    /** nullable persistent field */
    private String itemName;

    /** nullable persistent field */
    private short quantity;

    /** nullable persistent field */
    private String reasonCode;

    /** nullable persistent field */
    private String pendingReason;

    /** persistent field */
    private bb.model.Userpurchase userpurchase;

    /** full constructor */
    public Transaction(java.lang.Integer transactionId, java.lang.String extTransactionId, java.lang.String parentExtTransactionId, double amount, java.lang.String status, java.lang.String method, java.lang.String itemName, short quantity, java.lang.String reasonCode, java.lang.String pendingReason, bb.model.Userpurchase userpurchase) {
        this.transactionId = transactionId;
        this.extTransactionId = extTransactionId;
        this.parentExtTransactionId = parentExtTransactionId;
        this.amount = amount;
        this.status = status;
        this.method = method;
        this.itemName = itemName;
        this.quantity = quantity;
        this.reasonCode = reasonCode;
        this.pendingReason = pendingReason;
        this.userpurchase = userpurchase;
    }

    /** default constructor */
    public Transaction() {
    }

    /** minimal constructor */
    public Transaction(java.lang.Integer transactionId, bb.model.Userpurchase userpurchase) {
        this.transactionId = transactionId;
        this.userpurchase = userpurchase;
    }

    /** @hibernate.id
     * generator-class="identity"
     * column="TransactionId"
     */
    public java.lang.Integer getTransactionId() {
        return this.transactionId;
    }

    public void setTransactionId(java.lang.Integer transactionId) {
        this.transactionId = transactionId;
    }
    /** @hibernate.property
     */
    public void setReceiverEmail(java.lang.String receiverEmail) {
        this.receiverEmail = receiverEmail;
    }

    /** @hibernate.property
     */
    public java.lang.String getReceiverEmail() {
        return this.receiverEmail;
    }

    /** @hibernate.property
     */
    public java.lang.String getExtTransactionId() {
        return this.extTransactionId;
    }

    public void setExtTransactionId(java.lang.String extTransactionId) {
        this.extTransactionId = extTransactionId;
    }

    /** @hibernate.property
     */
    public java.lang.String getParentExtTransactionId() {
        return this.parentExtTransactionId;
    }

    public void setParentExtTransactionId(java.lang.String parentExtTransactionId) {
        this.parentExtTransactionId = parentExtTransactionId;
    }

    /** @hibernate.property
     */
    public double getAmount() {
        return this.amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    /** @hibernate.property
     */
    public java.lang.String getStatus() {
        return this.status;
    }

    public void setStatus(java.lang.String status) {
        this.status = status;
    }

    /** @hibernate.property
     */
    public java.lang.String getMethod() {
        return this.method;
    }

    public void setMethod(java.lang.String method) {
        this.method = method;
    }

    /** @hibernate.property
     */
    public java.lang.String getItemName() {
        return this.itemName;
    }

    public void setItemName(java.lang.String itemName) {
        this.itemName = itemName;
    }

    /** @hibernate.property
     */
    public short getQuantity() {
        return this.quantity;
    }

    public void setQuantity(short quantity) {
        this.quantity = quantity;
    }

    /** @hibernate.property
     */

    public java.lang.String getReasonCode() {
        return this.reasonCode;
    }

    public void setReasonCode(java.lang.String reasonCode) {
        this.reasonCode = reasonCode;
    }

    /** @hibernate.property
     */
    public java.lang.String getPendingReason() {
        return this.pendingReason;
    }

    public void setPendingReason(java.lang.String pendingReason) {
        this.pendingReason = pendingReason;
    }


    public bb.model.Userpurchase getUserpurchase() {
        return this.userpurchase;
    }

    public void setUserpurchase(bb.model.Userpurchase userpurchase) {
        this.userpurchase = userpurchase;
    }

    public String toString() {
        return new ToStringBuilder(this)
            .append("transactionId", getTransactionId())
            .toString();
    }

    public boolean equals(Object other) {
        if ( !(other instanceof Transaction) ) return false;
        Transaction castOther = (Transaction) other;
        return new EqualsBuilder()
            .append(this.getTransactionId(), castOther.getTransactionId())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getTransactionId())
            .toHashCode();
    }

}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 12:01 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Joe,

I did initially have a problem with XDoclet when I tried to specify the file name in the build.xml as you have.

Instead just replace it with the following.


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


This should work. If it can't find the java file in your src.dir, try moving it to a package structure under src.dir like com.foo.bar. Hope that helps.


Top
 Profile  
 
 Post subject: Solved!
PostPosted: Tue Mar 30, 2004 4:10 pm 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
gpani wrote:
Joe,

Instead just replace it with the following.

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




THANK YOU!

That was alot of it. It didn't put them into the directories I wanted at first, but that was easy to fix.

Basically the secret appears to be, "Dont go and try and try to tell Ant where your hibernated classes are. Just let it go through your all of your java code and trust it to do the right thing if it does (or does NOT) find XDoclet tags.

_________________
"A statistician is a mathmetician, broken down by age and sex".


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.