ClassNotFoundException with hbm2java
------------------------------------
Key: MHIBERNATE-83
URL: http://jira.codehaus.org/browse/MHIBERNATE-83
Project: Maven 2.x Hibernate Plugin
Issue Type: Bug
Components: hbm2java
Affects Versions: 2.2
Environment: C:\Projects\java\trunk\harnesshibernate>mvn -v
Maven version: 2.0.9
Java version: 1.6.0_03
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
Reporter: md
Assignee: Johann Reyes
Priority: Critical
I have hand created a .hbm.xml file and I am attempting to generate the java
bean class using the hbm2java goal. I keep getting a ClassNotFoundException no
matter what I try. Neither the online documentation or web searches has turned
up anything useful. The class it is missing is the one I am trying to generate,
so of course it's not going to find it. The question is why is it looking for
it in the first place?
Here is the plugin tag from the pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<executions>
<execution>
<id>hbm2java</id>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<outputDirectory>src/main/java/</outputDirectory>
<implementation>configuration</implementation>
</component>
</components>
</configuration>
</execution>
</executions>
</plugin>
Here is the hbm.xml file:
<hibernate-mapping>
<class name="net.test.hh.data.Track" table="TRACK">
<meta attribute="class-description">
Represents a single playable track in the music database.
</meta>
<id name="id" column="track_id">
<meta attribute="scope-set">protected</meta>
<generator class="native" ></generator>
</id>
<property name="title" type="string" not-null="true"></property>
<property name="filePath" type="string" not-null="true"></property>
<property name="playTime" type="time">
<meta attribute="field-description">Playing Time</meta>
</property>
<property name="added" type="date">
<meta attribute="field-description">When the track was last
created</meta>
</property>
<property name="volume" type="short" not-null="true">
<meta attribute="field-description">How loud to play the track</meta>
</property>
</class>
</hibernate-mapping>
here is the hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/music</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="connection.shutdown">true</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="net/test/hh/data/Track.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Here's the exception I get:
Caused by: org.hibernate.MappingException: class net.test.hh.data.Track not
found while looking for property: id
at
org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
at
org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:401)
at
org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:334)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at
org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 30 more
Caused by: java.lang.ClassNotFoundException: net.test.hh.data.Track
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at
org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at
org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
at
org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at
org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:70)
... 38 more
This should have been an easy thing to do. Instead I have lost many hours
behind this issue.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email