Announcement Announcement Module
Collapse
No announcement yet.
spring osgi+Hibernate org.hibernate.MappingException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring osgi+Hibernate org.hibernate.MappingException

    Dear Spring Community,

    Recently I tried to modify an existing spring web application for spring OSGi. During the application's startup process the DM Server reports a "ClassNotFoundException: org.hibernate.MappingException".

    spring DM - 1.2.1
    spring-2.5.6.SEC01.jar
    hibernate-3.2.7.ga.jar

    HTML Code:
    Exception in thread "SpringOsgiExtenderThread-4" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://540.fwk29293232/META-INF/spring/spring-core-persist-hibernate.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
    	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    	at java.lang.Class.getConstructor0(Class.java:2699)
    	at java.lang.Class.getDeclaredConstructor(Class.java:1985)
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
    	... 18 more
    Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
    	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
    	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
    	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
    	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    	... 24 more
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    
    	<!-- Hibernate SessionFactory -->
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    
    		<!-- dataSource-->
    		<property name="dataSource" ref="dataSource" />
    				
    		<!-- hibernateProperties-->
    		<property name="hibernateProperties" ref="hibernateProperties" />		
    	</bean>	
    	
    	<!-- Hibernate hibernateProperties -->
    	<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    		<property name="properties">
    			<props>
    				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
    				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    				<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
    				<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
    				<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
    				</prop>
    				<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
    			</props>
    		</property>
    	</bean>			
    	
           <bean id="property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
               <property name="order" value="1" />   
               <property name="ignoreUnresolvablePlaceholders" value="true" />          
               <property name="location">
                   <value>classpath:jdbc.properties</value>
               </property>
           </bean>
        
    </beans>
    maven pom dependencies jars
    Code:
    <dependency>
        	<groupId>commons-dbcp</groupId>
        	<artifactId>commons-dbcp</artifactId>
        	<version>1.2.2</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring</artifactId>
        	<version>2.5.6.SEC01</version>
        </dependency>       
        <dependency>
          	<groupId>org.springframework</groupId>
           	<artifactId>spring-aspects</artifactId>
           	<version>2.5.6.SEC01</version>
        </dependency>                 
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate</artifactId>
        	<version>3.2.7.ga</version>
        </dependency>
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate-annotations</artifactId>
        	<version>3.4.0.GA</version>
        </dependency> 
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate-validator</artifactId>
        	<version>3.0.0.ga</version>
        </dependency>        
        <dependency>
        	<groupId>flexjson</groupId>
        	<artifactId>flexjson</artifactId>
        	<version>1.7</version>
        </dependency>
        <dependency>
        	<groupId>net.sf.json-lib</groupId>
        	<artifactId>json-lib</artifactId>
        	<version>2.3</version>
        	<classifier>jdk15</classifier>
        </dependency>          
        <dependency>
        	<groupId>javax.transaction</groupId>
        	<artifactId>jta</artifactId>
        	<version>1.1</version>
        </dependency>
        <dependency>
        	<groupId>org.slf4j</groupId>
        	<artifactId>slf4j-jdk14</artifactId>
        	<version>1.5.8</version>
        </dependency>
        <dependency>
        	<groupId>org.slf4j</groupId>
        	<artifactId>slf4j-api</artifactId>
        	<version>1.5.8</version>
        </dependency>             
        <dependency>
        	<groupId>mysql</groupId>
        	<artifactId>mysql-connector-java</artifactId>
        	<version>5.1.12</version>
        </dependency>
        <dependency>
        	<groupId>javax.persistence</groupId>
        	<artifactId>persistence-api</artifactId>
        	<version>1.0</version>
        </dependency>   
        <dependency>
        	<groupId>xerces</groupId>
        	<artifactId>xerces</artifactId>
        	<version>2.4.0</version>
        </dependency> 
     </dependencies>
    Last edited by sixsun; Nov 26th, 2011, 08:26 AM.
Working...
X