I am getting a similar stack trace when generating DAOs for my schema. The schema consists of 54 classes, some have composite keys. When running a custom <hbmtemplate> from ant, it seems that my 54 DAOs are generated, but the task fails while attempting to generate a DAO for a primary key class. Below is a snippet from my build file and a snippet from my ant logging. Notice the "TemplateHelper.putInContex" log entries immediately following the last successfully-generated DAO.
From build.xml:
Code:
<target name="genAll" depends="init">
<delete includeemptydirs="true">
<fileset dir="${gen.source.dir}" includes="**/*"/>
</delete>
<hibernatetool destdir="${gen.source.dir}">
<jdbcconfiguration
configurationfile="${hibernate.cfg.xml}"
packagename="${dao.package.name}"
revengfile="${hibernate.reveng.xml}"/>
<hbm2hbmxml/>
<hbm2java jdk5="${jdk5.flag}" ejb3="${ejb3.flag}"/>
<hbmtemplate filepattern="{package-name}/{class-name}DAO.java"
templatepath="${dao.template.path}"
template="${dao.template}">
<property key="jdk5" value="${jdk5.flag}" />
<property key="ejb3" value="${ejb3.flag}" />
</hbmtemplate>
</hibernatetool>
</target>
From the log:
Code:
[hibernatetool] 2006-05-08 17:48:49,377 INFO TemplateProducer.produce - Writing onstarDAO to D:\workspaces\workshop\dataservices\gen_src\com\onstar\dataservices\model\DacsiDAO.java
[hibernatetool] 2006-05-08 17:48:49,387 DEBUG TemplateHelper.putInContext - putInContext pojo=org.hibernate.tool.hbm2x.pojo.ComponentPOJOClass(com.onstar.dataservices.mod
el.VehiclealertconfigurationId)
[hibernatetool] 2006-05-08 17:48:49,387 DEBUG TemplateHelper.putInContext - putInContext clazz=org.hibernate.mapping.Component([org.hibernate.mapping.Property(dtcstatusmask), org.hibernate.mapping.Property(vehicleid)])
[hibernatetool] 2006-05-08 17:48:49,387 DEBUG Log4JLoggerFactory$Log4JLogger.debug - onstarDAO.ftl[en_US,Cp1252,parsed] cached copy not yet stale; using cached.
[hibernatetool] 2006-05-08 17:48:49,387 DEBUG Log4JLoggerFactory$Log4JLogger.debug - Key 'entityName' was not found on instance of org.hibernate.mapping.Component.
... <snipping lots of class introspection output>
[hibernatetool] 2006-05-08 17:48:49,397 ERROR Log4JLoggerFactory$Log4JLogger.error -
[hibernatetool] Expression clazz.entityName is undefined on line 150, column 34 in onstarDAO.ftl.
[hibernatetool] The problematic instruction:
[hibernatetool] ----------
[hibernatetool] ==> ${clazz.entityName} [on line 150, column 32 in onstarDAO.ftl]
[hibernatetool] ----------
[hibernatetool] Java backtrace for programmers:
[hibernatetool] ----------
[hibernatetool] freemarker.core.InvalidReferenceException: Expression clazz.entityName is undefined on line 150, column 34 in onstarDAO.ftl.
Thanks,
Scott