I'm working my way through Chapter 2 of Java Persistence with Hibernate and have run into a problem.
On page 65, there is an Ant taskdef for doing a schema export. However, when I run that Ant task, I get this error message:
BUILD FAILED
java.lang.NoSuchMethodError: org.hibernate.tool.hbm2ddl.SchemaExport.setHaltOnError(Z) Lorg/hibernate/tool/hbm2ddl/SchemaExport;
Presumably this indicates that I'm missing a jar file in my build path. (I'm using Eclipse.) However, I'm unable to figure out what is missing.
I have hibernate-tools.jar in there, but when I browse through that jar file, I see a package named org.hibernate.tool.hbm2x, but not one named org.hibernate.tool.hbm2ddl.
Am I missing a jar file? Here's what I have in my build path:
antlr-2.7.6rc1.jar
asm-attrs.jar
asm.jar
c3p0-0.9.0.jar
cglib-2.1.3.jar
commons-collections-3.1.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
ehcache-1.1.jar
hibernate-tools.jar
hibernate3.jar
jta.jar
log4j-1.2.13.jar
sqljdbc.jar
I'm using Java 1.5.0_10, Eclipse 3.2.1, Hibernate Core 3.2.2, Hibernate Tools 3.2.0 beta9, and Microsoft SQL Server on Windows XP.
Here's the full console output of the ant task:
Buildfile: C:\Documents and Settings\epauser\My Documents\Eclipse Workspace\JPWH Hello World\build.xml
clean:
[delete] Deleting directory C:\Documents and Settings\epauser\My Documents\Eclipse Workspace\JPWH Hello World\classes
[mkdir] Created dir: C:\Documents and Settings\epauser\My Documents\Eclipse Workspace\JPWH Hello World\classes
compile:
[javac] Compiling 3 source files to C:\Documents and Settings\epauser\My Documents\Eclipse Workspace\JPWH Hello World\classes
copymetafiles:
[copy] Copying 4 files to C:\Documents and Settings\epauser\My Documents\Eclipse Workspace\JPWH Hello World\classes
schemaexport:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 14:13:09,812 INFO Environment:456 - Hibernate 3.0rc1
[hibernatetool] 14:13:09,828 INFO Environment:469 - hibernate.properties not found
[hibernatetool] 14:13:09,828 INFO Environment:502 - using CGLIB reflection optimizer
[hibernatetool] 14:13:09,843 INFO Environment:532 - using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 14:13:09,843 INFO Configuration:1262 - configuring from file: hibernate.cfg.xml
[hibernatetool] 14:13:10,000 INFO Configuration:439 - Mapping resource: hello/Message.hbm.xml
[hibernatetool] 14:13:10,187 INFO HbmBinder:256 - Mapping class: hello.Message -> Message
[hibernatetool] 14:13:10,375 INFO Configuration:1340 - Configured SessionFactory: null
[hibernatetool] 14:13:10,375 INFO Configuration:844 - processing extends queue
[hibernatetool] 14:13:10,390 INFO Configuration:848 - processing collection mappings
[hibernatetool] 14:13:10,390 INFO Configuration:857 - processing association property references
[hibernatetool] 14:13:10,390 INFO Configuration:884 - processing foreign key constraints
[hibernatetool] 14:13:10,406 INFO Dialect:89 - Using dialect: org.hibernate.dialect.SQLServerDialect
[hibernatetool] 14:13:10,421 INFO Configuration:844 - processing extends queue
[hibernatetool] 14:13:10,421 INFO Configuration:848 - processing collection mappings
[hibernatetool] 14:13:10,421 INFO Configuration:857 - processing association property references
[hibernatetool] 14:13:10,421 INFO Configuration:884 - processing foreign key constraints
[hibernatetool] 14:13:10,500 INFO Configuration:844 - processing extends queue
[hibernatetool] 14:13:10,500 INFO Configuration:848 - processing collection mappings
[hibernatetool] 14:13:10,500 INFO Configuration:857 - processing association property references
[hibernatetool] 14:13:10,500 INFO Configuration:884 - processing foreign key constraints
BUILD FAILED
java.lang.NoSuchMethodError: org.hibernate.tool.hbm2ddl.SchemaExport.setHaltOnError(Z)Lorg/hibernate/tool/hbm2ddl/SchemaExport;
Total time: 3 seconds