Hi folks,
This is my first post here so wish me luck. :)
I'm a bit of a Hibernate and Ant noob and I'm having a problem running the HibernateToolTask via Ant in Eclipse when the ant build is configured to "Run in the same JRE as the workspace". By contrast, the same ant build works fine when run from the command line and even works in Eclipse when the ant build is set to run in a "separate JRE".
When running it in the "same JRE as the workspace" the build completes (BUILD SUCCESSFUL) but two things are evident. (1) The Log4J messages are not written to the console and (2) the <hbm2ddl /> does not create the database table.
I'm sure Log4J is configured properly because the logging level (debug) is successfully written for this exact same ant build when run from the command line or run through Eclipse with the ant build set to run in a "separate JRE". Same thing goes for the <hbm2ddl /> which runs successfully from the command line, etc.
I'm using code that I modified from the examples in the Harnessing Hibernate book.
I'm using the following versions:
Eclipse Java EE IDE for Web Developers Helios SR 2 (v. 3.6.2)
Ant v1.8.2
Java JDK 1.6.0_24
HibernateTools-3.2.4.GA-R200905070146-H18
hibernate-distribution-3.6.2.Final
HSQL Database Engine 2.1.0
Windows XP
I'm happy to add any other info that might be helpful such as the build.xml, hibernate.cfg.xml, , Track.hbm.xml, log4j.properties. For now I'll just add a couple of snippets that I think are relevant.
Code:
<!-- Generate the schemas for all mapping files in our class tree -->
<target name="schema" depends="prepare, refresh.local"
description="Generate DB schema from the O/R mapping files">
<hibernatetool destdir="${source.dir}">
<configuration configurationfile="${props.dir}/hibernate.cfg.xml" />
<hbm2ddl drop="yes" />
</hibernatetool>
</target>
<target name="print.classpath">
<!-- Write the classpath to the console. Helpful for debugging -->
<!-- Create one line per classpath element-->
<pathconvert pathsep="${line.separator}" property="echo.classpath" refid="project.classpath" />
<!-- Write the result to the console -->
<echo message="The classpath is set to the following: " />
<echo message="${echo.classpath}" />
</target>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:data/music;</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.shutdown">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="com/oreilly/hh/data/Track.hbm.xml" />
</session-factory>
</hibernate-configuration>
Code:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=warn, stdout
log4j.logger.com.oreilly.hh.data=debug
log4j.logger.org.hibernate=debug
log4j.logger.org.hibernate.type=debug
log4j.logger.org.hibernate.tool.hbm2ddl=debug
Below is the classpath that Ant is using when running the build.xml
Code:
print.classpath:
[echo] The classpath is set to the following:
[echo] C:\dev\source_code\HarnessingHibernate\examples\ch02\src
[echo] C:\dev\source_code\HarnessingHibernate\examples\ch02\classes
[echo] C:\dev\source_code\HarnessingHibernate\examples\ch02\properties
[echo] C:\dev\source_code\HarnessingHibernate\examples\ch02\lib\hsqldb.jar
[echo] C:\dev\source_code\HarnessingHibernate\examples\ch02\lib\slf4j-simple-1.6.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\hibernate-testing.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\hibernate3.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\bytecode\cglib\cglib-2.2.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\bytecode\javassist\javassist-3.12.0.GA.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\c3p0\c3p0-0.9.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\ehcache\ehcache-1.5.0.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\infinispan\infinispan-core-4.2.1.CR1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\jbosscache\jbosscache-core-3.2.1.GA.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\oscache\oscache-2.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\proxool\proxool-0.8.3.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\optional\swarmcache\swarmcache-1.0RC2.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\antlr-2.7.6.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\commons-collections-3.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\dom4j-1.6.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\javassist-3.12.0.GA.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\jta-1.1.jar
[echo] C:\dev\plugins\hibernate-distribution-3.6.2.Final\lib\required\slf4j-api-1.6.1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse.console_3.2.4.GA-R200905070146-H18\org.hibernate.eclipse.console.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse.help_3.2.4.GA-R200905070146-H18\help.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse.jdt.apt.ui_3.2.4.GA-R200905070146-H18.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse.jdt.ui_3.2.4.GA-R200905070146-H18.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse.mapper_3.2.4.GA-R200905070146-H18\org.hibernate.eclipse.mapper.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\ejb3-persistence.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\hibernate-annotations.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\hibernate-commons-annotations.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\hibernate-entitymanager.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\hibernate-search.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\hibernate-validator.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\annotations\lucene-core-2.2.0.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\bsh-core-2.0b4.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\antlr-2.7.6.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\asm-attrs.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\asm.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\c3p0-0.9.1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\cglib-2.1.3.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\commons-collections-2.1.1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\commons-logging-1.0.4.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\concurrent-1.3.2.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\connector.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\dom4j-1.6.1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\ehcache-1.2.3.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\hibernate3.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jaas.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\javassist.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jboss-cache.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jboss-common.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jboss-jmx.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jboss-system.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jdbc2_0-stdext.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jgroups-2.2.8.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\jta.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\log4j-1.2.15.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\oscache-2.1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\proxool-0.8.3.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\hibernate\swarmcache-1.0rc2.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\tools\bsh-2.0b1.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\tools\freemarker.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\tools\hibernate-tools.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\lib\tools\jtidy-r8-20060801.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.hibernate.eclipse_3.2.4.GA-R200905070146-H18\org.hibernate.eclipse.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.jboss.tools.hibernate.jpt.core_3.2.4.GA-R200905070146-H18.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.jboss.tools.hibernate.jpt.ui_3.2.4.GA-R200905070146-H18.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.jboss.tools.hibernate.ui.veditor_3.2.4.GA-R200905070146-H18\orm2-veditor.jar
[echo] C:\dev\plugins\HibernateTools-3.2.4.GA-R200905070146-H18\plugins\org.jboss.tools.hibernate.ui.view_3.2.4.GA-R200905070146-H18\view.jar
BUILD SUCCESSFUL