-->
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.  [ 5 posts ] 
Author Message
 Post subject: Annotation: NoClassDefFound: org/hibernate/cfg/Configuration
PostPosted: Mon Feb 25, 2008 4:27 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
Hi, I try to convert my current running application, which uses xml configuration file for hibernate mapping to annotation. I only do so partially for 1 class right now. However, I run into no class def found. This class is verified to be inside the hibernate.jar.

Could someone please glance down below to see where the problem maybe? Thanks.

Hibernate version:
3.2.6.ga

Annotation version: 3.3.0.GA

Mapping documents:
hibernate.cfg.xml
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <mapping class="com.someclass"/>
   </session-factory>
</hibernate-configuration>



beans-db.xml
Code:
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
      autowire="byName">
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">
               org.hibernate.dialect.Oracle9Dialect
            </prop>
                                <prop key="hibernate.hbm2ddl.auto">validate</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.use_sql_comments">true</prop>
            <prop key="hibernate.cache.provider_class">
               org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="net.sf.ehcache.configurationResourceName">/ehcache.xml</prop>
         </props>
      </property>
               <property  name="configurationClass">
                   <value>org.hibernate.cfg.AnnotationConfiguration</value>
               </property>
               <property name="configLocation">
                   <value>/hibernate.cfg.xml</value>
               </property>
      <property name="mappingResources">
      <list>
                       <value>/somefile.hbm.xml</value>
      </property>
   </bean>


Full stack trace of any exception that occurs:
Code:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/beans-db.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property 'configurationClass'; nested exception is java.lang.IllegalArgumentException: Error loading class [org.hibernate.cfg.AnnotationConfiguration]: problem with class file or dependent class. Root cause: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property 'configurationClass'; nested exception is java.lang.IllegalArgumentException: Error loading class [org.hibernate.cfg.AnnotationConfiguration]: problem with class file or dependent class. Root cause: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Caused by:
java.lang.IllegalArgumentException: Error loading class [org.hibernate.cfg.AnnotationConfiguration]: problem with class file or dependent class. Root cause: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
        at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:202)
        at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63)
        at org.springframework.beans.TypeConverterDelegate.convertValue(TypeConverterDelegate.java:253)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:177)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:127)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:775)
        at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:608)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:74)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:970)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:749)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:704)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
        at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at some.path.ApplicationContextLoader.contextInitialized(ApplicationContextLoader.java:31)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4236)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4760)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:292)

Name and version of the database you are using:
Oracle


Top
 Profile  
 
 Post subject: Re: Annotation: NoClassDefFound: org/hibernate/cfg/Configura
PostPosted: Mon Feb 25, 2008 4:30 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
This is a class loading issue. Delete extra hibernate jar files and you should be good.



Farzad-


Top
 Profile  
 
 Post subject: Re: Annotation: NoClassDefFound: org/hibernate/cfg/Configura
PostPosted: Mon Feb 25, 2008 5:35 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
[quote="farzad"]This is a class loading issue. Delete extra hibernate jar files and you should be good.
Farzad-[/quote]

Do you mean I only need the library hibernate-annotations.jar, but not hibernate.jar? When I remove that, I get some error such as the following not found:

org.hibernate.usertype.UserType
org.hibernate.HibernateException

Unless you mean I have two hibernate.jar in my library path. I didn't see that in my project's library path, but I can look deeper if that's the case. Thanks.


Top
 Profile  
 
 Post subject: Re: Annotation: NoClassDefFound: org/hibernate/cfg/Configura
PostPosted: Mon Feb 25, 2008 5:40 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
hovh03 wrote:
Unless you mean I have two hibernate.jar in my library path. I didn't see that in my project's library path, but I can look deeper if that's the case. Thanks.



That's what I meant. You have multiple hibernate.jar files on your classpath.



Farzad-


Top
 Profile  
 
 Post subject: Re: Annotation: NoClassDefFound: org/hibernate/cfg/Configura
PostPosted: Mon Feb 25, 2008 7:17 pm 
Newbie

Joined: Fri Oct 27, 2006 2:28 pm
Posts: 14
[quote="farzad"][quote="hovh03"]Unless you mean I have two hibernate.jar in my library path. I didn't see that in my project's library path, but I can look deeper if that's the case. Thanks.[/quote]

That's what I meant. You have multiple hibernate.jar files on your classpath.

Farzad-[/quote]

Thank you very much. I found another hibernate.jar in the deployment domain's lib.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.