Thread Context Class Loader: Thread.currentThread.getClassLoader() / setClassLoader(). Like this, if you have the correct Import-Package, you can "gather" the classloaders.

Anyway, even for a demo, you can do:

feature:install jdbc
jdbc:create to create a datasource

and just use the datasource via the OSGi service or the JNDI name.

Regards
JB

On 12/23/2014 04:00 PM, Richard Snowden wrote:
I won't support multiple databases (it's only for a demo) - so a quick &
dirty solution is OK.

What's a TCCL?

On Tue, Dec 23, 2014 at 3:53 PM, Kevin Schmidt <[email protected]
<mailto:[email protected]>> wrote:

    It is "wrong" but more work to manage imports and drivers especially
    if you need to optionally support multiple databases. It is cleaner
    to configure a data source and just look it up from your code.

    On Dec 23, 2014 6:45 AM, "Richard Snowden"
    <[email protected] <mailto:[email protected]>>
    wrote:

        I just tried Derby - got the same issue:
        java.lang.ClassNotFoundException:
        org.apache.derby.jdbc.EmbeddedDriver

        This is what I do to initialize the DB:
        Derby:

        Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
                     dbConnection =
        DriverManager.getConnection("jdbc:derby:memory:myDB;create=true;");

        H2:
                     Class.forName("org.h2.Driver");
                     dbConnection =
        DriverManager.getConnection("jdbc:h2:~/myDB", "", "");

        Is this wrong?

        On Tue, Dec 23, 2014 at 3:37 PM, Jean-Baptiste Onofré
        <[email protected] <mailto:[email protected]>> wrote:

            Hi Richard,

            I suspect more an issue in the way that you use the h2
            package in your application.

            Do you have h2 package in Import-Package of your application ?
            How do you use the driver ? Class.forName() ?
            Do you use a datasource ?

            Regards
            JB


            On 12/23/2014 03:31 PM, Richard Snowden wrote:

                What I did:

                - added H2 Database to my application. It works fine
                outside of Karaf.

                - installed H2 to Karaf with "install -s
                mvn:com.h2database/h2/1.4.184"

                I can see the H2 bundle as "Active" (H2 Database Engine).

                But when I install my application bundle in Karaf, I get
                this:
                java.lang.__ClassNotFoundException: org.h2.Driver not found

                What's the proper way to install H2 to Karaf?


            --
            Jean-Baptiste Onofré
            [email protected] <mailto:[email protected]>
            http://blog.nanthrax.net
            Talend - http://www.talend.com




--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to