java.lang.NoClassDefFoundError: java/lang/Enu

Help
2008-10-10
2013-04-17
  • Martin Ross
    Martin Ross
    2008-10-10

    Not sure if this is the right place for this. I'm using the retrotranslator maven plugin to generate java 1.4 compatible code. I have the following in my pom.xml

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>retrotranslator-maven-plugin</artifactId>
                    <version>1.0-alpha-4</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>translate-project</goal>
                            </goals>
                            <configuration>
                                <classifier>jdk14</classifier>
                                <attach>true</attach>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

    And when depending on the generated jar file, I add the jdk14 classifier and it pulls in the right version. However, when I'm calling it, I'm getting an error saying the code can't find Enum. It seems to be happening when Hibernate is parsing the generated class:

    java.lang.NoClassDefFoundError: java/lang/Enum
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
        at java.lang.Class.getDeclaredMethods(Class.java:1139)
        at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:317)
        at org.hibernate.property.BasicPropertyAccessor.getGetterOrNull(BasicPropertyAccessor.java:297)
        at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:280)
        at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
        at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
        at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:118)
        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)

    Has anyone seen this before?

     
    • Taras Puchko
      Taras Puchko
      2008-10-10

      Hi!

      It looks like the generated jar file has not been translated completely. To be sure use verification options when translating (you'll have to specify path to jars from JDK 1.4). You can also try adding a dependency on retrotranslator-runtime.

      If you have troubles with the plugin you may ask for help on mojo users mailing list.

      Cheers,
      Taras