-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ClassFormatException running Hello World Message
PostPosted: Fri Jan 26, 2007 3:31 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Hello, I'm trying to run the simple HelloWorld examples in the Java Persistence With Hibernate (Manning 06)

I was successful in running the Hello World Message example using XML mapping, but when I switched over to annotations, I get the following exception. Any ideas on why I get the ClassFormatException?

Code:
14:22:00,468 DEBUG [main] cfg.Configuration (Configuration.java:1282) - Preparing to build session factory with filters : {}
14:22:00,468 DEBUG [main] cfg.AnnotationConfiguration (AnnotationConfiguration.java:235) - Execute first pass mapping processing
14:22:00,531 DEBUG [main] cfg.AnnotationConfiguration (AnnotationConfiguration.java:435) - Process hbm files
14:22:00,531 DEBUG [main] cfg.AnnotationConfiguration (AnnotationConfiguration.java:443) - Process annotated classes
Exception in thread "main" java.lang.ExceptionInInitializerError
   at hibernate.scratchpad.persistence.HibernateUtil.<clinit>(HibernateUtil.java:15)
   at hibernate.scratchpad.hello.HelloWorld.main(HelloWorld.java:23)
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/InheritanceType
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClassInternal(Unknown Source)
   at org.hibernate.cfg.InheritanceState.extractInheritanceType(InheritanceState.java:51)
   at org.hibernate.cfg.InheritanceState.<init>(InheritanceState.java:21)
   at org.hibernate.cfg.AnnotationBinder.buildInheritanceStates(AnnotationBinder.java:2058)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:446)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
   at hibernate.scratchpad.persistence.HibernateUtil.<clinit>(HibernateUtil.java:12)
   ... 1 more


The code for Message.java is:

Code:
package hibernate.scratchpad.hello.annotations;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "MESSAGES")
public class Message {
   
   @Id @GeneratedValue
   @Column(name = "MESSAGE_ID")
   private Long id;
   
   @Column(name = "MESSAGE_TEXT")
   private String text;
   
   @ManyToOne(cascade = CascadeType.ALL)
   @JoinColumn(name = "NEXT_MESSAGE_ID")
   private Message nextMessage;
etc.


The snippet from HibernateUtil:

Code:
static {
      try {
         sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
         //sessionFactory = new Configuration().configure().buildSessionFactory();
      } catch(Throwable ex) {
         throw new ExceptionInInitializerError(ex);
      }
   }


..and the only mapping entry i have in hibernate.config.xml ->

Code:
<mapping class="hibernate.scratchpad.hello.annotations.Message"/>

[/u]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 5:15 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Solved.

http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html

I was pulling this jar in with maven. This jar is interface only. Classloader apparently loads this first before hibernate jars when trying to load classes that implement some of the JPA interfaces.

If you order the jars so the java-ee5-api.jar is after hibernate, this problem goes away. Hope that helps somebody.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.