Hi again,
Okey, I need to be more clear. I use two files (daohome.ftl, daointerface.ftl) and I used the first one as a template for the the second one so I will get the same method names for the interface. The changes I did in the daointerface.ftl were like this:
Code:
public interface ${declarationName}Dao {
/**
* Saves ${declarationName} to percistence store
* @param transientInstance the object to be saved
*/
public void save(${declarationName} transientInstance);
.... and so on.....
}
This is my Ant target method:
Code:
<target name="generateHibernateDaoInterfaceClasses" depends="generateHibernateDomainObjects" >
<hibernatetool>
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${root.dir}/hibernate/hibernate.cfg.xml"
revengfile="${root.dir}/hibernate/hibernate.reveng.xml"/>
<hbmtemplate
filepattern="{class-name}Dao.java"
templatepath="${root.dir}/hibernate/template/dao"
template="daointerface.ftl"
destdir="${hibernateGenerated.dir}/dao">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
</hibernatetool>
</target>
This is the error log in ant using -verbose
Code:
[hibernatetool] (freemarker.runtime 96 )
[hibernatetool] No signature of method getJavaTypeName matches (java.lang.Object
,java.lang.Boolean)
[hibernatetool] The problematic instruction:
[hibernatetool] ----------
[hibernatetool] ==> ${c2j.getJavaTypeName(clazz.identifierProperty, jdk5)} [on l
ine 54, column 41 in daointerface.ftl]
[hibernatetool] ----------
[hibernatetool] Java backtrace for programmers:
[hibernatetool] ----------
[hibernatetool] freemarker.template.TemplateModelException: No signature of meth
od getJavaTypeName matches (java.lang.Object,java.lang.Boolean)
[hibernatetool] at freemarker.ext.beans.MethodMap.getMostSpecific(Method
Map.java:191)
[hibernatetool] at freemarker.ext.beans.OverloadedMethodModel.exec(Overl
oadedMethodModel.java:105)
[hibernatetool] at freemarker.core.MethodCall._getAsTemplateModel(Method
Call.java:93)
[hibernatetool] at freemarker.core.Expression.getAsTemplateModel(Express
ion.java:89)
[hibernatetool] at freemarker.core.Expression.getStringValue(Expression.
java:93)
[hibernatetool] at freemarker.core.DollarVariable.accept(DollarVariable.
java:76)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java
:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.IfBlock.accept(IfBlock.java:82)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java
:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:23
3)
[hibernatetool] at freemarker.core.BlockAssignment.accept(BlockAssignmen
t.java:83)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java
:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:19
6)
[hibernatetool] at freemarker.core.Environment.process(Environment.java:
176)
[hibernatetool] at freemarker.template.Template.process(Template.java:23
1)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateHelper.processTempla
te(TemplateHelper.java:243)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produceToSt
ring(TemplateProducer.java:67)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(Tem
plateProducer.java:28)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(Tem
plateProducer.java:97)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(G
enericExporter.java:112)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.exportCompon
ent(GenericExporter.java:97)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.exportClasse
s(GenericExporter.java:91)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.doStart(Gene
ricExporter.java:69)
[hibernatetool] at org.hibernate.tool.hbm2x.AbstractExporter.start(Abstr
actExporter.java:93)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.start(Generi
cExporter.java:59)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.execute(ExporterT
ask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(Hibe
rnateToolTask.java:160)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownEl
ement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:
369)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Pro
ject.java:1216)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.ja
va:1185)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTa
rgets(DefaultExecutor.java:40)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.j
ava:1068)
[hibernatetool] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[hibernatetool] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[hibernatetool] at org.apache.tools.ant.launch.Launcher.run(Launcher.jav
a:246)
[hibernatetool] at org.apache.tools.ant.launch.Launcher.main(Launcher.ja
va:67)
[hibernatetool] An exception occurred while running exporter #2:generic exporter
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processi
ng template daointerface.ftl
[hibernatetool] freemarker.template.TemplateModelException: No signature of meth
od getJavaTypeName matches (java.lang.Object,java.lang.Boolean)
BUILD FAILED
C:\Dev\hibernateTest\build.xml:98: org.hibernate.tool.hbm2x.ExporterException: E
rror while processing template daointerface.ftl
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToo
lTask.java:194)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.ja
va:163)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing te
mplate daointerface.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:249)
at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplatePro
ducer.java:67)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:28)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:112)
at org.hibernate.tool.hbm2x.GenericExporter.exportComponent(GenericExpor
ter.java:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporte
r.java:91)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:69)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:93)
at org.hibernate.tool.hbm2x.GenericExporter.start(GenericExporter.java:5
9)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.ja
va:160)
... 12 more
Caused by: freemarker.template.TemplateModelException: No signature of method ge
tJavaTypeName matches (java.lang.Object,java.lang.Boolean)
at freemarker.ext.beans.MethodMap.getMostSpecific(MethodMap.java:191)
at freemarker.ext.beans.OverloadedMethodModel.exec(OverloadedMethodModel
.java:105)
at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.IfBlock.accept(IfBlock.java:82)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.visit(Environment.java:233)
at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:231)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:243)
... 23 more
--- Nested Exception ---
org.hibernate.tool.hbm2x.ExporterException: Error while processing template daoi
nterface.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:249)
at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplatePro
ducer.java:67)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:28)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:112)
at org.hibernate.tool.hbm2x.GenericExporter.exportComponent(GenericExpor
ter.java:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporte
r.java:91)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:69)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:93)
at org.hibernate.tool.hbm2x.GenericExporter.start(GenericExporter.java:5
9)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.ja
va:160)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: freemarker.template.TemplateModelException: No signature of method ge
tJavaTypeName matches (java.lang.Object,java.lang.Boolean)
at freemarker.ext.beans.MethodMap.getMostSpecific(MethodMap.java:191)
at freemarker.ext.beans.OverloadedMethodModel.exec(OverloadedMethodModel
.java:105)
at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.IfBlock.accept(IfBlock.java:82)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.visit(Environment.java:233)
at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:231)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:243)
... 23 more
I noticed another thing... when I build the dao implementation with ant task:
Code:
<target name="generateHibernateDaoImplClasses">
<hibernatetool>
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${root.dir}/hibernate/hibernate.cfg.xml"
revengfile="${root.dir}/hibernate/hibernate.reveng.xml"/>
<hbmtemplate
filepattern="{class-name}DaoImpl.java"
templatepath="${root.dir}/hibernate/template"
template="daohome.ftl"
exporterclass="org.hibernate.tool.hbm2x.DAOExporter"
destdir="${hibernateGenerated.dir}/dao">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
</hibernatetool>
</target>
I get the MyClassDaoImpl.java as I want them, but if I try to add a package.name attribute... I will get the standard file name MyClassHome.java
Code:
<target name="generateHibernateDaoImplClasses">
<hibernatetool>
<jdbcconfiguration
packagename="${hibernateGenerated.package}"
configurationfile="${root.dir}/hibernate/hibernate.cfg.xml"
revengfile="${root.dir}/hibernate/hibernate.reveng.xml"/>
<hbmtemplate
filepattern="{package-name}/{class-name}DaoImpl.java" <--- Here is the package.name
templatepath="${root.dir}/hibernate/template"
template="daohome.ftl"
exporterclass="org.hibernate.tool.hbm2x.DAOExporter"
destdir="${hibernateGenerated.dir}/dao">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
</hibernatetool>
</target>
I hope I made this a little more clear... so do you know why the interface template fails?
Thanks