Got the same error with SpringSource's hibernate bundles : (Currently working under Virgo web server (Equinox) )
Code:
[my_secret_app_name].dataSource: 0.0.1
com.springsource.antlr: 2.7.7
com.springsource.com.mchange.v2.c3p0: 0.9.1.2
com.springsource.com.mysql.jdbc: 5.1.6
com.springsource.javassist: 3.9.0.GA
com.springsource.javax.sql.rowset: 1.0.1
com.springsource.net.sf.cglib: 2.2.0
com.springsource.org.apache.commons.collections: 3.2.0
com.springsource.org.apache.commons.pool: 1.5.3
com.springsource.org.dom4j: 1.6.1
com.springsource.org.hibernate: 3.3.2.GA
com.springsource.org.objectweb.asm: 1.5.3
[my_secret_app_name].MyProfile.API: 0.1.0
[my_secret_app_name].MyProfile.factory: 0.1.0
[my_secret_app_name].MyProfile.lang: 0.0.1
[my_secret_app_name].MyProfile.log: 0.0.1
[my_secret_app_name].MyProfile.modele: 0.1.0
[my_secret_app_name].MyProfile.provider: 2.4.0
[my_secret_app_name].security: 2.4.0
org.eclipse.virgo.apps.splash: 3.0.1.RELEASE
org.springframework.security.acls: 3.0.0.RELEASE
org.springframework.security.config: 3.0.0.RELEASE
org.springframework.security.core: 3.0.0.RELEASE
org.springframework.security.taglibs: 3.0.0.RELEASE
org.springframework.security.web: 3.0.0.RELEASE
Are resolved and started. I can see so
Code:
org.hibernate.cfg 3.3.2.GA 0 x-equinox-ee:=-1
uses:=org.dom4j, org.hibernate, org.hibernate.bytecode, org.hibernate.cache, org.hibernate.connection, org.hibernate.dialect, org.hibernate.dialect.function, org.hibernate.engine, org.hibernate.engine.query.sql, org.hibernate.event, org.hibernate.exception, org.hibernate.hql, org.hibernate.jdbc, org.hibernate.jdbc.util, org.hibernate.mapping, org.hibernate.proxy, org.hibernate.tool.hbm2ddl, org.hibernate.transaction, org.hibernate.tuple.entity, org.hibernate.type, org.w3c.dom, org.xml.sax
x-internal:=false
in com.springsource.org.hibernate: 3.3.2.GA. So the package exists.
In my bundle-context I got:
Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>/hibernate/MyProfile_document.xml</value>
<value>/hibernate/MyProfile_file.xml</value>
<value>/hibernate/MyProfile_group.xml</value>
<value>/hibernate/MyProfile_note.xml</value>
<value>/hibernate/MyProfile_user.xml</value>
<value>/hibernate/MyProfile_friend.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
And in my MANIFEST.MF, I got
Code:
Manifest-Version: 1.0
Private-Package: .... Many Packages ....
Built-By: Georges
Tool: Bnd-0.0.238
Bundle-Name: Spring OSGi Bundle
Created-By: Apache Maven Bundle Plugin
Import-Bundle: com.springsource.org.hibernate
Bundle-Version: 0.1
Build-Jdk: 1.6.0_22
Bnd-LastModified: 1321525831524
Bundle-ManifestVersion: 2
Import-Package: com.mysql.jdbc,[my_secret_app_name].modele.beans
.documents,[my_secret_app_name].modele.beans.users,[my_secret_app_name].services.consumer.contract,[my_secret_app_name].
services.modele.contract,javax.sql,org.hibernate;version="3.3.2.GA",o
rg.hibernate.cfg;version="3.3.2.GA",org.hibernate.classic;version="3.
3.2.GA",org.hibernate.criterion;version="3.3.2.GA",org.hibernate.dial
ect;version="3.3.2.GA",org.springframework.beans;version="2.5",org.sp
ringframework.context;version="2.5",org.springframework.jdbc.datasour
ce,org.springframework.orm.hibernate3
Bundle-SymbolicName: [my_secret_app_name].MyProfile.consumer
With the dataSource as a service (following Spring-DM good practices):
Code:
<osgi:reference id="dataSource" interface="javax.sql.DataSource"></osgi:reference>
And in the datasource bundle :
Code:
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:META-INF/spring/database.properties</value>
</property>
</bean>
<!-- Database Properties -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver.classname}"></property>
<property name="jdbcUrl" value="${database.url}"></property>
<property name="user" value="${database.username}"></property>
<property name="password" value="${database.password}"></property>
</bean>
<!-- Data Source service -->
<osgi:service id="dataSourceService" ref="dataSource" interface="javax.sql.DataSource"/>
I Also added <Import-Bundle>com.springsource.com.mysql.jdbc</Import-Bundle> to the com.springsource.com.mchange.v2.c3p0 library. (Using c3p0 instead of the SessionManager and it's annoying class.forName() )
I don't understand what I have done wrong....
When I run my bundle, got the following error:
Code:
[2011-11-17 14:19:21.417] start-signalling-4 <DE0006E> Start failed for bundle '[my_secret_app_name].consumer' version '0.1.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://148.fwk4098499/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
....
[2011-11-17 14:30:50.932] region-dm-7 <AG0000E> Application context creation failure for bundle '[my_secret_app_name].MyProfile.consumer' version '0.1.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://149.fwk4098499/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at ...
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:189)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 20 common frames omitted
[2011-11-17 14:30:50.937] start-signalling-4 <DE0006E> Start failed for bundle '[my_secret_app_name].MyProfile.consumer' version '0.1.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://149.fwk4098499/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
....
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
...
... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:189)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
... 20 common frames omitted
Why is org/hibernate/cfg/Configuration not found ???
Any help will be greatly apreciated !
Thank you !