-->
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.  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: hibernatedoclet
PostPosted: Thu Mar 11, 2004 8:27 am 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
Hello forum,
i am trying to generate hbm.xml files from some java source files.
When I run this target I get the errors that comes after the target.
What's wrong ? I practically copied from tutorial page ...

.
.
.
<target name="genHbm" description="Generate HBM files">
<taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath path="${xdoclet_home}/lib/xdoclet-1.2.jar" />
<classpath path="${xdoclet_home}/lib/xdoclet-hibernate-module- 1.2.jar" />
<classpath path="${xdoclet_home}/lib/xdoclet-xdoclet-module- 1.2.jar" />
<classpath path="${xdoclet_home}/lib/xjavadoc-1.0.2.jar" />
<classpath path="${xdoclet_home}/lib/log4j.jar" />
<classpath path="${xdoclet_home}/lib/commons-collections- 2.0.jar" />
<classpath path="${xdoclet_home}/lib/commons-logging.jar" />
</taskdef>
<hibernatedoclet
destdir="${hbm_files}"
excludedtags="@version"
force="${generate_force}"
mergedir="${hbm_files}"
verbose="false"> ******** error is here

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

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

<replace dir="${hbm_files}">
<include name="**/*.hbm.xml"/>
<replacefilter token="readonly=" value="inverse="/>
<replacefilter token="role=" value="name="/>
<replacefilter token="hibernate-mapping.dtd" value="hibernate- mapping-2.0.dtd"/>
</replace>
</target>
.
.
.


The error is



BUILD FAILED

file:C:/minhasApps/webapp/controleAdm/build.xml:57: Unexpected error
at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:123)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:166)
at org.apache.tools.ant.Task.perform(Task.java:319)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
at org.apache.tools.ant.Main.runBuild(Main.java:610)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)
Caused by: java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getThrowableStrRep()[Ljava/lang/String;
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:295)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:150)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:56)
at org.apache.log4j.Category.callAppenders(Category.java:258)
at org.apache.log4j.Category.forcedLog(Category.java:454)
at org.apache.log4j.Category.log(Category.java:885)
at org.apache.commons.logging.impl.Log4JCategoryLog.info(Log4JCategoryLog.java:180)
at xdoclet.XDocletMain.start(XDocletMain.java:47)
at xdoclet.DocletTask.start(DocletTask.java:464)
at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:110)
... 9 more
--- Nested Exception ---
java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getThrowableStrRep()[Ljava/lang/String;
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:295)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:150)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:56)
at org.apache.log4j.Category.callAppenders(Category.java:258)
at org.apache.log4j.Category.forcedLog(Category.java:454)
at org.apache.log4j.Category.log(Category.java:885)
at org.apache.commons.logging.impl.Log4JCategoryLog.info(Log4JCategoryLog.java:180)
at xdoclet.XDocletMain.start(XDocletMain.java:47)
at xdoclet.DocletTask.start(DocletTask.java:464)
at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:110)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:166)
at org.apache.tools.ant.Task.perform(Task.java:319)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
at org.apache.tools.ant.Main.runBuild(Main.java:610)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:21 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Run Ant in verbose mode to see what is happening. Are the values you are passing into hibernatedoclet ie. ${hbm_files} being set?

You do not need to do the replace after running hibernatedoclet. The original problem was fixed in XDoclet 1.2.


Sherman


Top
 Profile  
 
 Post subject: hibernatedoclet (2)
PostPosted: Thu Mar 11, 2004 9:48 am 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
Yes, the values is being set:

.
.
<property name="hbm_files" value="./WEB-INF/hibernate" />
<property name="generate_force" value="false"/>
.
<delete dir="${hbm_files}" />
<mkdir dir="${hbm_files}" />
.
.


I can't understand what is show in verbose mode. The prompt stop in same error.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:57 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Give "-v" when you run Ant for verbose mode. Also "-debug" is useful at times. Lots of output, though!

Caused by: java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getThrowableStrRep()[Ljava/lang/String;

This is suspicious. Have you got a version mismatch between commons-logging and log4j?


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:20 am 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
"This is suspicious. Have you got a version mismatch between commons-logging and log4j?"

Your suspicious was right !!!
I was another log4j in my classpath (log4j-core.jar , necessary to Interbase). When I eliminate it, the error is over !!!

Thank you...

But, another question:

after run, I got BUILD SUCCESSFUL, but any HBM file was created.
I used on my java class

/**
*@hibernate.class table="TEST"
*@hibernate.collection-one-to-many class="TEST_CHILD"
*/
public class Banco {
.
.
/**
* @hibernate-property type="string"
* @hibernate-column column="DESCR" sql-type="VARCHAR(50)" not-null="true" unique="true" insert="true"
*/
public String getDescr() {
return descr;
}
.
.

Any opinion ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:41 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Read http://www.hibernate.org/72.html

Try


/**
*@hibernate.class table="TEST"
*/
/**
* @hibernate.set
* inverse="true"
* cascade="all"
*
* @hibernate.collection-key
* column="ChildId"
*
* @hibernate.collection-one-to-many
* class="com.yourcompany.TestChild"
*
* @return Set
*/

/**
* @hibernate.property
* column="DESCR"
* type="string"
* length="50"
* not-null="true"
*/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:52 am 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
I used page .../72.html to make my build file. Actualy, it's my "favorite page"...

To test, I used just

@hibernate.class table="TEST"

but any file is created on WEB-INF/hibernate. The folder is created, but any file.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 1:19 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Try to get a class to run that has XDoclet tags for hibernate.class, hibernate.id and hibernate.property. The id one is critical.


Sherman


Top
 Profile  
 
 Post subject: hibernatedoclet
PostPosted: Thu Mar 11, 2004 1:42 pm 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
Nothing...

I need like this:

CREATE TABLE BANCO (
BANCO_ID NUMERIC(5) NOT NULL,
BANCO_DESCR VARCHAR(50) NOT NULL,
PRIMARY KEY (BANCO_ID));
CREATE TABLE AGENCIA (
BANCO_ID NUMERIC(5) NOT NULL,
AGENCIA_ID NUMERIC(5) NOT NULL,
AG_DESCR VARCHAR(50) NOT NULL,
PRIMARY KEY (BANCO, AGENCIA_ID));
ALTER TABLE AGENCIA ADD FOREIGN KEY (BANCO_ID) REFERENCES BANCO (BANCO_ID);



I put XDoclet tags only Banco.java, like this:

==========================
package br.gov.ibge.bean;

import br.gov.ibge.bean.Agencia;
import java.util.ArrayList;

/**
*@hibernate.class table="BANCO"
*@hibernate.collection-one-to-many class="AGENCIA"
*/
public class Banco {

private int numeroBanco;
private String descricao;
public ArrayList agencia = new ArrayList(); // type Agencia


/**
* @return int Identificador do cargo.
*/
public void addAgencia(Agencia umaAgencia) {
agencia.add(umaAgencia);
}

/**
* @hibernate.collection-one-to-many class="br.gov.ibge.bean.Agencia"
* @return ArrayList
*/
public ArrayList getAgencia() {
return agencia;
}

/**
* @hibernate-property type="string"
* @hibernate-column column="DESCRICAO" sql-type="VARCHAR(50)" not-null="true" unique="true" insert="true"
* @return String Nome do banco
*/
public String getDescricao() {
return descricao;
}

/**
* @hibernate.id type="integer" generator-class="sequence"
* @hibernate-column column="NUMERO_BANCO" sql-type="INTEGER"
* @return int
*/
public int getNumeroBanco() {
return numeroBanco;
}

/**
* @param umaLista
*/
public void setAgencia(ArrayList umaLista) {
this.agencia = umaLista;
}

/**
* @param umaDesc Nome do banco
*/
public void setDescricao(String umaDesc) {
this.descricao = umaDesc;
}

/**
* @param umNr
*/
public void setNumeroBanco(int umNr) {
this.numeroBanco = umNr;
}
}


But the Banco.hbm.xml was't created.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 3:30 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
You are way off.

Try:


package br.gov.ibge.bean;

import br.gov.ibge.bean.Agencia;
import java.util.Set;

/**
*@hibernate.class table="BANCO"
*/
public class Banco {

private Integer numeroBanco;
private String descricao;
public ArrayList agencia = new ArrayList(); // type Agencia


/**
* @hibernate.id
* generator-class="sequence"
* column="BANCO_ID"
* type="integer"
*
* @hibernate.generator-param
* name="sequence"
* value="NumeroBancoSeq"
*
* @return Integer
*/
public Integer getNumeroBanco() {
return numeroBanco;
}

/**
* @param umNr
*/
public void setNumeroBanco(Integer umNr) {
this.numeroBanco = umNr;
}

/**
* @hibernate.property
* column="BANCO_DESCR"
* type="string"
* length="50"
* not-null="true"
* unique="true"
* insert="true"
*
* @return String Nome do banco
*/
public String getDescricao() {
return descricao;
}

/**
* @param umaDesc Nome do banco
*/
public void setDescricao(String umaDesc) {
this.descricao = umaDesc;
}


/**
* @hibernate.set
* inverse="true"
* cascade="all"
*
* @hibernate.collection-key
* column="BANCO_ID"
*
* @hibernate.collection-one-to-many
* class="br.gov.ibge.bean.Agencia"
* @return Set
*/
public Set getAgencia() {
return agencia;
}

/**
* @param umaLista
*/
public void setAgencia(Set umaLista) {
this.agencia = umaLista;
}

/**
* @return int Identificador do cargo.
*/
public void addAgencia(Agencia umaAgencia) {
getAgencia().add(umaAgencia);
}

}




package br.gov.ibge.bean;

import br.gov.ibge.bean.Banco;
import java.util.Set;

/**
*@hibernate.class table="BANCO"
*/
public class Agencia {

private Integer numeroAgencia;
private String descricao;
private Banco banco;
/**
* @hibernate.id
* generator-class="sequence"
* column="AGENCIA_ID"
* type="integer"
*
* @hibernate.generator-param
* name="sequence"
* value="NumeroAgenciaSeq"
*
* @return Integer
*/
public Integer getNumeroAgencia() {
return numeroAgencia;
}

/**
* @param umNr
*/
public void setNumeroAgencia(Integer umNr) {
this.numeroAgencia = umNr;
}

/**
* @hibernate.property
* column="AG_DESCR"
* type="string"
* length="50"
* not-null="true"
* unique="true"
* insert="true"
*
* @return String Nome do agencia
*/
public String getDescricao() {
return descricao;
}

/**
* @param umaDesc Nome do agencia
*/
public void setDescricao(String umaDesc) {
this.descricao = umaDesc;
}

/**
* @hibernate.many-to-one
* column="BANCO_ID"
* class="br.gov.ibge.bean.Banco"
*/
public Banco getBanco() {
return banco;
}

/**
* @param newBanco
*/
public void setBanco(Banco newBanco) {
this.banco = umaLista;
}

}


Top
 Profile  
 
 Post subject: hibernatedoclet
PostPosted: Thu Mar 11, 2004 4:27 pm 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
Ok, I remake the java files.
But the hbm files was't created.

Isn't my target wrong ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 4:33 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Probably.

Try:

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


Top
 Profile  
 
 Post subject: hibernatedoclet
PostPosted: Thu Mar 11, 2004 4:55 pm 
Newbie

Joined: Thu Mar 11, 2004 7:17 am
Posts: 14
Location: Goiania
No success...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 5:21 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Run ant with "-v -debug" to see what is happening.


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 6:14 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
if this can help you...
<hibernatedoclet
destdir="${src.home}"
excludedtags="@version,@author,@todo"
mergedir="${generated.home}"
verbose="true">
<fileset dir="${src.home}">
<include name="**/bo/*.java"/>
</fileset>

<hibernate version="2.0"/>


</hibernatedoclet>

try to search *.hbm.xml, maybe the are generated on another folder[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 23 posts ]  Go to page 1, 2  Next

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.