Maven 1.x Hibernate Plugin

schema-export throws error when mapping classes that contain PersistentEnum attributes

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Microsoft Windows XP [Version 5.1.2600]
    java version "1.4.1_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
    Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)
  • Number of attachments :
    1

Description

When exporting a database schema, if one of the classes has an enumerated type as one of it's attributes (in Hibernate these enumerated types have to be classes that implement the PersistentEnum interface), then the following exception is thrown:

BUILD FAILED
java.lang.NoClassDefFoundError: net/sf/hibernate/PersistentEnum
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:2
65)
at net.sf.hibernate.type.TypeFactory.hueristicType(TypeFactory.java:131)

at net.sf.hibernate.cfg.Binder.getTypeFromXML(Binder.java:787)
at net.sf.hibernate.cfg.Binder.bindValue(Binder.java:354)
at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:715)
at net.sf.hibernate.cfg.Binder.bindCollectionSecondPass(Binder.java:1055
)
at net.sf.hibernate.cfg.Binder.bindSetSecondPass(Binder.java:923)
at net.sf.hibernate.cfg.Binder$SetSecondPass.secondPass(Binder.java:1187
)
at net.sf.hibernate.cfg.Binder$SecondPass.doSecondPass(Binder.java:1135)

at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.ja
va:497)
at net.sf.hibernate.cfg.Configuration.generateDropSchemaScript(Configura
tion.java:352)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:5
1)
at org.apache.maven.hibernate.beans.SchemaExportBean.getSchemaExport(Sch
emaExportBean.java:358)
at org.apache.maven.hibernate.beans.SchemaExportBean.execute(SchemaExpor
tBean.java:268)
at org.apache.maven.hibernate.jelly.SchemaExportTag.execute(SchemaExport
Tag.java:83)
at org.apache.maven.hibernate.jelly.SchemaExportTag.doTag(SchemaExportTa
g.java:98)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
at com.werken.werkz.jelly.GoalTag$1.performAction(GoalTag.java:128)
at com.werken.werkz.Goal.fire(Goal.java:639)
at com.werken.werkz.Goal.attain(Goal.java:575)
at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:
434)
at org.apache.maven.MavenSession.attainGoals(MavenSession.java:348)
at org.apache.maven.cli.App.doMain(App.java:525)
at org.apache.maven.cli.App.main(App.java:1088)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.werken.forehead.Forehead.run(Forehead.java:543)
at com.werken.forehead.Forehead.main(Forehead.java:573)
File...... file:/C:/~home/.maven/plugins/maven-hibernate-plugin-1.0-SNAPHOT/
Element... h:schema-export
Line...... 27
Column.... 53
net/sf/hibernate/PersistentEnum
Total time: 41 seconds

Activity

Hide
Samuel Mulube added a comment -

This patch seemed to solve the problem for me, but I don't really know why. How the Java classloader works always seems a little bit like voodoo to me, so if anyone can explain to me what the difference between Thread.getCurrentThread().getContextClassLoader(), and this.getClass().getClassLoader() is I would be very grateful.

Show
Samuel Mulube added a comment - This patch seemed to solve the problem for me, but I don't really know why. How the Java classloader works always seems a little bit like voodoo to me, so if anyone can explain to me what the difference between Thread.getCurrentThread().getContextClassLoader(), and this.getClass().getClassLoader() is I would be very grateful.
Hide
dion gillard added a comment -

If someone can provided a test project, I'll happily test it.

Show
dion gillard added a comment - If someone can provided a test project, I'll happily test it.
Hide
Brett Porter added a comment -

patch was a little off, but I think I've fixed this properly.
Please test!

Show
Brett Porter added a comment - patch was a little off, but I think I've fixed this properly. Please test!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: