I am extremely unfamiliar with Ant, so I copied the build.xml from the book:
And then made another file, build.properties:
I have the following files:
And I have hibernate3.jar, freemarker.jar, and hibernate-tools.jar in the Referenced Libraries of my project. Can anyone tell me why I'm receiving the "taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found" error at line 27? From what the book says, I thought this was in the hibernate-tools.jar file or freemarker.jar file.
Look very carefully at lines 7, 8 and 9 of the output. Do you see anything amiss with the file names given? You posted earlier that those files exist, and even posted the full path for those files. So why is Ant saying "it doesn't exist"?
Once you see the problem, fix line 7 in the build.xml. Or fix either line 2 or 3 in the build.properties file.
Thanks Peter that was a good hint. With a little more tweaking of things the results of running the thing are:
According to the book, I'm assuming this is the expected results because it said I should see the script represented by lines 50 - 65, but I have to
admit I'm not sure what I've accomplished. Should I just continue to read and the answer will come?
Yes, continue reading the book. Hopefully the authors will explain what is going on. Usually, authors provide ant scripts to automatically build examples in the book. In some cases the authors list all of the code in the book itself and explain what all of the code does. Hopefully the authors of your book do the same. Unfortunately, I have seen too many cases where the authors only discuss a small fraction of a larger piece of code leaving you in the dark about the rest. Personally, I have never understood that. I prefer books that have small simple complete examples that I can type in by hand and compile/run, rather than long, involved examples that the author barely touches on. (I have also run into "getting started guides" where the entire "tutorial" consists of running an ant script. As if that explains how to build anything that works with the software!)
A little more FYI for others experiencing this (since I am new with Ant and Hibernate this was a bit frustrating), the books examples were
developed for HSQLDB, so I had to modify the hibernate.cfg.xml to be MySQL compliant since that's what I'm using. After changing that,
I received the com.mysql.jdbc.Driver class not found exception. To make a long story short, the build.xml file had
which I changed to
And tried to run it all again for the gazillionth time. This time it was successful and the empty tables were created. The moral of the story for
all you newbies like me: make sure your hibernate.cfg.xml, build.xml, and build.properties files are all compliant for the database being used.
I hope this shortens the error solving time for others.