I am setting up hyperjaxb
to run in eclipse using this tutorial. So far, I have gotten it to marshal
and unmarshal
, but it does not yet trigger hbm2ddl
to create the tables in the database, and it is not clear where in the eclipse directory structure I should locate the Main.java
and TestFunctions.java
classes that I created to run the code from the tutorial link above. How can I alter my eclipse configuration to enable these things to happen?
Here is my main.java:
package maintest;
public class Main {
public static void main(String[] args) {
TestFunctions mf = new TestFunctions();
try {mf.setUp();} catch (Exception e) {e.printStackTrace();}
mf.unmarshal();
mf.setUpPersistence();
Long id = mf.saveToDatabase();
System.out.println("hjid is: "+id);
mf.loadFromDatabase(id);
mf.marshal();
}
}
You can read the more lengthy code from TestFunctions.java
by clicking on this link. Note that the file sharing site mistakenly center-justifies the code, despite the fact that the code is left-justified on my machine.
persistence.properties
is:
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.username=someusername
hibernate.connection.password=somepassword
hibernate.connection.url=jdbc:mysql://localhost/sometestdatabase
hibernate.hbm2ddl.auto=create-drop
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
hibernate.jdbc.batch_size=0
I am currently getting the following stack trace when I right click Main.java
and click run as.. java application
:
Exception in thread "main" java.lang.NoClassDefFoundError: maintest/TestFunctions
at maintest.Main.main(Main.java:7)
Caused by: java.lang.ClassNotFoundException: maintest.TestFunctions
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
Here is the directory structure: