3 Replies Latest reply: Mar 9, 2012 2:51 AM by Thomas Diesler RSS

Mysql+Dbcp+Jboss OSGI = Problems

willliam whitaker Newbie

Apologize if this has been asked before, I did search but found nothing.  Below are my manifest and the stack trace.  I have tried everything I can think of including repackaging dbcp and adding DynamicImport-Package: * to its Manifest.  All to no avail.  I'm desperate at this point.  Please help:)

 

 

 

Manifest-Version: 1.0

Bundle-Version: 1.0.0

Bundle-Name: MY COOL BUNDLE

Bundle-ManifestVersion: 2

Bundle-Description: COMPANY

Bundle-SymbolicName: com.test

Import-Package: javax.sql,

org.apache.commons.dbcp,

org.slf4j;version="[1.6.1,1.6.1]",

org.slf4j.helpers;version="1.6.1",

org.slf4j.spi;version="1.6.1"

Require-Bundle: org.springframework.core;bundle-version="3.0.5",

org.springframework.beans;bundle-version="3.0.5"

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

 

 

 

 

12:57:55,455 ERROR [stderr] (SpringOsgiExtenderThread-36) Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found from bundle [com.test]

12:57:55,456 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1138)

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       ... 21 more

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36) Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "deployment.com.test:1.0.0" from Service Module Loader]

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

12:57:55,457 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)

12:57:55,458 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)

12:57:55,458 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:115)

12:57:55,458 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.osgi.framework.internal.HostBundleRevision.loadClass(HostBundleRevision.java:114)

12:57:55,458 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.osgi.framework.internal.AbstractBundleState.loadClass(AbstractBundleState.java:415)

12:57:55,458 ERROR [stderr] (SpringOsgiExtenderThread-36)       at org.jboss.osgi.framework.internal.HostBundleState.loadClass(HostBundleState.java:150)

 

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Generating spring context file.

 

<bean id="abstractDatabase" abstract="true"
class="org.apache.commons.dbcp.BasicDataSource" p:username="${jdbc.username}"
p:password="${jdbc.password}" p:driverClassName="${jdbc.driverClassName}"
init-method="createDataSource" destroy-method="close" />
  • 1. Re: Mysql+Dbcp+Jboss OSGI = Problems
    Thomas Diesler Master

    This code

     

    org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1138)

     

    cannot see the mysql driver. How do you deploy dbcp?

     

    Here is the Manifest from commons-dbcp-1.4.jar

     

    Manifest-Version: 1.0 
    Archiver-Version: Plexus Archiver 
    Created-By: 1.6.0_17 (Apple Inc.) 
    Built-By: philsteitz 
    Build-Jdk: 1.6.0_17 
    Implementation-Title: Commons DBCP 
    Implementation-Vendor: The Apache Software Foundation 
    Implementation-Vendor-Id: org.apache 
    Implementation-Version: 1.4 
    Specification-Title: Commons DBCP 
    Specification-Vendor: The Apache Software Foundation 
    Specification-Version: 1.4 
    X-Compile-Source-JDK: 1.6 
    X-Compile-Target-JDK: 1.6 
    Export-Package: org.apache.commons.dbcp.cpdsadapter;version="1.4",org. 
     apache.commons.dbcp;version="1.4",org.apache.commons.dbcp.managed;ver 
     sion="1.4",org.apache.commons.jocl;version="1.4",org.apache.commons.d 
     bcp.datasources;version="1.4" 
    Tool: Bnd-0.0.238 
    Bundle-Name: Commons DBCP 
    Bundle-Vendor: The Apache Software Foundation 
    Bundle-Version: 1.4 
    Bnd-LastModified: 1265565112392 
    Bundle-ManifestVersion: 2 
    Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt 
    Bundle-Description: Commons Database Connection Pooling 
    Import-Package: javax.naming,javax.naming.spi,javax.sql,javax.transact 
     ion,javax.transaction.xa,org.apache.commons.dbcp;version="1.4",org.ap 
     ache.commons.dbcp.cpdsadapter;version="1.4",org.apache.commons.dbcp.d 
     atasources;version="1.4",org.apache.commons.dbcp.managed;version="1.4 
     ",org.apache.commons.jocl;version="1.4",org.apache.commons.pool,org.a 
     pache.commons.pool.impl,org.xml.sax,org.xml.sax.helpers 
    Bundle-SymbolicName: org.apache.commons.dbcp 
    Bundle-DocURL: http://commons.apache.org/dbcp/ 
    

     

    From this I cannot see how dbcp could see the driver class. Lets have a look at the code ...

     

    You don't seem to be using 1.4. Please dig up the code and show how dbcp loads the driver.

    Given the above manifest, a likely approach would be that it somehow uses the bundle context of the caller.

    In which case the caller would need to see the driver.

     

    You can enable DEBUG on org.jboss.osgi to see the wiring details for the resolved bundles.

  • 2. Re: Mysql+Dbcp+Jboss OSGI = Problems
    willliam whitaker Newbie

    Manifest-Version: 1.0

    Bundle-Version: 1.0.0

    Bundle-Name: MY COOL BUNDLE

    Bundle-ManifestVersion: 2

    Bundle-Description: COMPANY

    Bundle-SymbolicName: com.test

    Import-Package: javax.sql,

    org.slf4j;version="[1.6.1,1.6.1]",

    org.slf4j.helpers;version="1.6.1",

    org.slf4j.spi;version="1.6.1"

    Require-Bundle: com.springsource.org.apache.commons.dbcp;bundle-version="1.2.2"

     

     

     

     

     

    Thanks for the reply.  I had many different manifest attempts.  Here is another using Require-Bundle.  I am using 1.2.2.  I am deploying it like everything else.  I dump dbcp into jboss/standalone/deployments.  It looks good.  Then I refer to it from the manifest.  I have tried to include the mysql Driver bundle directly and that is a no-go.  You are correct that dbcp doesn't see it and I am guessing it is because of the classpath partitioning of the plugins.  I tried dbcp 1.4 with the same results.  I also tried creating a fragment with parent plugin dbcp and that includes mysql driver.  No go there either.  Then I tried repackaging dbcp with DynamicImport-Package: * in the Manifest.  That didn't help either.

     

    Two things are making me crazy here.  1.) Is noone using mysql out there in this way?  2.) This EXACT same deployment strategy works in Virgo/DM Server. 

     

    I will try to turn on DEBUG as you suggested. 

     

    Please let me know if you have any suggestions of other things I might try in the meantime. 

     

    Bill.

  • 3. Re: Mysql+Dbcp+Jboss OSGI = Problems
    Thomas Diesler Master

    I suggest we get to the bottom of this instead of guessing a solution that "happens to work" ;-)

     

    In standalone.conf you can uncomment this line

     

    # Sample JPDA settings for remote socket debugging

    #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

     

    and connect your debugger to the running AS7. Then set a breakpoint in BasicDataSource.createDataSource and step through that code until you know how dbcp is trying to load the driver. There might be several strategies with fall back options and so on. We like to understand how this is supposed to work. From that we can derive what needs to be done at app level. We might even be able to uncover a bug in the framework.

     

    Please descibe how dbcp is trying to load the driver (i.e. show code). I look forward to your finding - then we see further.