servicemix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@gmail.com>
Subject Re: SMX4 and classloading of JDBC driver (MySQL, ...) - question ??
Date Fri, 20 Mar 2009 14:20:22 GMT
The first version of commons-dbcp bundle was missing the dynamic import package.
The most recent version should work:
  http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-dbcp/1.2.2_2/

On Fri, Mar 20, 2009 at 15:16, cmoulliard <cmoulliard@gmail.com> wrote:
>
> I have created a osgi bundles including the spring config file posted in this
> message. The jdbc driver of Mysql has been deployed as a bundle. Here is the
> headers of MySql:
>
> MySQL AB's JDBC Driver for MySQL (126)
> --------------------------------------
> Manifest-Version = 1.0
> Bundle-Vendor = SpringSource
> Bundle-Name = MySQL AB's JDBC Driver for MySQL
> Ant-Version = Apache Ant 1.6.5
> Built-By = mysqldev
> Import-Package = com.mchange.v2.c3p0;version="[0.9.1.2,
> 1.0.0)";resolution:=optional,javax.naming,javax.naming.spi,javax.net,javax.net.ssl,javax.sql,javax.transaction.xa;
> version="[1.0.1,
> 2.0.0)";resolution:=optional,javax.xml.parsers,javax.xml.stream;version="[1.0.1,
> 2.0.0)";resolution:=optional,javax.xml.transform,javax.xml.transform.dom
> ,javax.xml.transform.sax,javax.xml.transform.stax;resolution:=optional,javax.xml.transform.stream,org.apache.commons.logging;version="[1.1.1,2.0.0)",org.apache.log4j;vers
> ion="[1.2.15,
> 2.0.0)";resolution:=optional,org.jboss.resource.adapter.jdbc;resolution:=optional,org.jboss.resource.adapter.jdbc.vendor;resolution:=optional,org.w3c.dom,or
> g.xml.sax,org.xml.sax.helpers
> Bundle-SymbolicName = com.springsource.com.mysql.jdbc
> Export-Package =
> com.mysql.jdbc;version="5.1.6";uses:="com.mysql.jdbc.log,javax.naming,javax.net.ssl,javax.xml.transform,org.xml.sax",com.mysql.jdbc.configs;version="5.1.
> 6",com.mysql.jdbc.exceptions;version="5.1.6",com.mysql.jdbc.exceptions.jdbc4;version="5.1.6";uses:="com.mysql.jdbc",com.mysql.jdbc.integration.c3p0;version="5.1.6",com.my
> sql.jdbc.integration.jboss;version="5.1.6",com.mysql.jdbc.interceptors;version="5.1.6";uses:="com.mysql.jdbc",com.mysql.jdbc.jdbc2.optional;version="5.1.6";uses:="com.mys
> ql.jdbc,com.mysql.jdbc.log,javax.naming,javax.sql,javax.transaction.xa",com.mysql.jdbc.log;version="5.1.6",com.mysql.jdbc.profiler;version="5.1.6";uses:="com.mysql.jdbc",
> com.mysql.jdbc.util;version="5.1.6";uses:="com.mysql.jdbc.log",org.gjt.mm.mysql;version="5.1.6"
> Bundle-Classpath = .
> Bundle-Version = 5.1.6
> Created-By = 1.4.2-b28 (Sun Microsystems Inc.)
> Bundle-ManifestVersion = 2
>
> and those of my bundle
>
> Report Incident Persistence Bundle (115)
> ----------------------------------------
> Tool = Bnd-0.0.255
> Export-Package =
> org.apache.camel.example.reportincident.dao;uses:="org.apache.camel.example.reportincident.model"
> Bundle-Version = 1.0.0.SNAPSHOT
> Build-Jdk = 1.6.0_12
> Created-By = Apache Maven Bundle Plugin
> Bundle-ManifestVersion = 2
> Manifest-Version = 1.0
> Bnd-LastModified = 1237555603991
> Private-Package = org.apache.camel.example.reportincident.dao.impl
> Bundle-Name = Report Incident Persistence Bundle
> Built-By = Charlesm
> Import-Package =
> META-INF.org.apache.camel.example.reportincident.model.Incident.hbm.xml,com.mysql.jdbc,net.sf.ehcache,org.apache.camel.example.reportincident.dao,org.apa
> che.camel.example.reportincident.model,org.apache.commons.dbcp,org.hibernate,org.hibernate.cfg,org.hibernate.classic,org.springframework.jdbc.support;version="2.5",org.sp
> ringframework.jdbc.support.lob;version="2.5",org.springframework.orm;version="2.5",org.springframework.orm.hibernate3;version="2.5",org.springframework.transaction;versio
> n="2.5"
> Bundle-SymbolicName = reportincident.persistence
>
> So Is the problem related to commons-dbcp who cannot find this class using
> its classloader ?
>
> Regards,
>
>
>
> gnodet wrote:
>>
>> Did you package this spring app in a bundle ?
>> If yes, you need to make sure your bundle import (statically or
>> dynamically, or through a RequiredBundle header) the com.mysql.jdbc
>> package.
>> Spring applications deployed through the deployer have a dynamic
>> import package declaration on everything iirc, so it should work that
>> way.
>>
>> On Fri, Mar 20, 2009 at 14:57, cmoulliard <cmoulliard@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I would like to know if someones has resolved top of SMX4 the issue
>>> related
>>> with the loading of JDBC driver like MySQL, ...
>>>
>>> I have created the following Spring configuration
>>>
>>> <?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:context="http://www.springframework.org/schema/context"
>>>       xmlns:osgi="http://www.springframework.org/schema/osgi"
>>>        xsi:schemaLocation="
>>>       http://www.springframework.org/schema/beans
>>>       http://www.springframework.org/schema/beans/spring-beans.xsd
>>>       http://www.springframework.org/schema/context
>>>       http://www.springframework.org/schema/context/spring-context.xsd
>>>       http://www.springframework.org/schema/osgi
>>>       http://www.springframework.org/schema/osgi/spring-osgi.xsd">
>>>
>>>    <context:annotation-config/>
>>>
>>>        <!--  DB connection and persistence layer -->
>>>        <!--  DataSource Definition  -->
>>>        <bean id="dataSource"
>>> class="org.apache.commons.dbcp.BasicDataSource"
>>> destroy-method="close">
>>>                <property name="driverClassName"
>>> value="com.mysql.jdbc.Driver" />
>>>                <property name="url" value="jdbc:mysql:///report" />
>>>                <property name="username" value="root" />
>>>                <property name="password" value="" />
>>>        </bean>
>>>
>>>
>>>        <!--  Spring Data Access Exception Translator Definition
>>>  -->
>>>        <bean id="jdbcExceptionTranslator"
>>> class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
>>>                <property name="dataSource">
>>>                        <ref bean="dataSource" />
>>>                </property>
>>>        </bean>
>>>
>>>        <!--  Hibernate SessionFactory Definition -->
>>>        <bean id="sessionFactory"
>>> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>>
>>>                <!-- Classloading does not work under OSGI
>>>                <property name="mappingResources">
>>>                        <list>
>>>
>>> <value>META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml</value>
>>>                        </list>
>>>                </property>
>>>                 -->
>>>
>>>                <!-- see here
>>>
>>> http://www.carbonfive.com/community/archives/2007/05/using_classpath.html
>>> and
>>>                     http://jira.springframework.org/browse/SPR-3965
>>>                     for more info about the classloading issue on OSGI
>>> -->
>>>                <property name="mappingLocations">
>>>                        <list>
>>>
>>> <value>classpath*:META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml</value>
>>>                        </list>
>>>                </property>
>>>
>>>
>>>                <property name="hibernateProperties">
>>>                        <props>
>>>                                <prop
>>> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>>>                                <prop
>>> key="hibernate.show_sql">false</prop>
>>>                                <prop
>>> key="hibernate.format_sql">true</prop>
>>>                                <prop
>>> key="hibernate.cglib.use_reflection_optimizer">true</prop>
>>>                                <prop
>>> key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
>>>                                <prop
>>> key="hibernate.jdbc.batch_size">10</prop>
>>>                        </props>
>>>                </property>
>>>                <property name="dataSource">
>>>                        <ref bean="dataSource" />
>>>                </property>
>>>        </bean>
>>>
>>>        <!--  Hibernate Transaction Manager Definition -->
>>>        <bean id="transactionManager"
>>> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>>>                <property name="sessionFactory">
>>>                        <ref local="sessionFactory" />
>>>                </property>
>>>        </bean>
>>>
>>>
>>>        <!--  Hibernate Transaction Manager exported as OSGI service
>>> because used
>>>              org.apache.camel.example.reportincident.service -->
>>>        <osgi:service id="transactionManagerOsgi"
>>>                      ref="transactionManager"
>>>
>>> interface="org.springframework.transaction.PlatformTransactionManager"/>
>>>
>>> </beans>
>>>
>>> but I receive the following error :
>>>
>>> 14:42:30,382 | WARN  | xtenderThread-15 | SQLErrorCodesFactory
>>>   |
>>> dbc.support.SQLErrorCodesFactory  230 | Error while extracting database
>>> product name - falling back to empty error codes
>>> org.springframework.jdbc.support.MetaDataAccessException: Could not get
>>> Connection for extracting meta data; nested exception is
>>> org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get
>>> JDBC Connection; nested exception is
>>> org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class
>>> 'com.mysql.jdbc.Driver'
>>>        at
>>> org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:293)
>>>        at
>>> org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:320)
>>>        at
>>> org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:216)
>>>        at
>>> org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:140)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at
>>> org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:840)
>>>        at
>>> org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
>>>        at
>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
>>>        at
>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
>>>        at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
>>>        at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
>>>        at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
>>>        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:429)
>>>        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:136)
>>>        at java.lang.Thread.run(Thread.java:619)
>>> Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException:
>>> Could
>>> not get JDBC Connection; nested exception is
>>> org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class
>>> 'com.mysql.jdbc.Driver'
>>>        at
>>> org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
>>>        at
>>> org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:280)
>>>        ... 30 more
>>> Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC
>>> driver class 'com.mysql.jdbc.Driver'
>>>        at
>>> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
>>>        at
>>> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>>>        at
>>> org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
>>>        at
>>> org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
>>>        ... 31 more
>>> Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>>>        at
>>> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:558)
>>>        at
>>> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
>>>        at
>>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1427)
>>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>>        at java.lang.Class.forName0(Native Method)
>>>        at java.lang.Class.forName(Class.java:169)
>>>        at
>>> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
>>>        ... 34 more
>>>
>>> Apparently, this point has been discussed by Spring user :
>>> http://forum.springframework.org/showthread.php?t=59588
>>>
>>> Regards,
>>>
>>>
>>>
>>> -----
>>> Charles Moulliard
>>> SOA Architect
>>>
>>> My Blog :  http://cmoulliard.blogspot.com/
>>> http://cmoulliard.blogspot.com/
>>> --
>>> View this message in context:
>>> http://www.nabble.com/SMX4-and-classloading-of-JDBC-driver-%28MySQL%2C-...%29---question----tp22620802p22620802.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: http://www.nabble.com/SMX4-and-classloading-of-JDBC-driver-%28MySQL%2C-...%29---question----tp22620802p22621153.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Mime
View raw message