You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Richard Snowden <ri...@gmail.com> on 2014/12/23 15:31:14 UTC
Karaf 3.0.2: Adding H2 Database support
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?
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
I suspect more an issue in the datasource XML.
Let me check.
Regards
JB
On 12/24/2014 01:36 PM, Richard Snowden wrote:
> Yes, the H2 bundle is installed (has been automatically installed by
> "jdbc:create -t h2 -u test2 -i test2").
>
> By the way: I also get this error when using Postgres. Only Derby seems
> to work with "jdbc:create ...".
>
> On Wed, Dec 24, 2014 at 8:04 AM, Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
> Hi Richard,
>
> Can you check (with la command) that the H2 bundle is installed ?
>
> Regards
> JB
>
> On 12/23/2014 10:03 PM, Richard Snowden wrote:
>
> OK, this seems to work for Derby.
> feature:install jdbc
> jdbc:create -t derby -u test -i test
>
>
> But when I do the same for H2 ...
> jdbc:create -t h2 -u test2 -i test2
>
> ... I get this error:
>
>
> 2014-12-23 21:57:44,854 | ERROR | l for user karaf |
> JdbcServiceImpl | 245 -
> org.apache.karaf.jdbc.core -
> 3.0.2 | Can't get information about datasource jdbc/test2
> java.sql.SQLException: No suitable driver found for null
> at
> org.h2.jdbcx.JdbcDataSource.__getJdbcConnection(__JdbcDataSource.java:183)
> at
> org.h2.jdbcx.JdbcDataSource.__getConnection(JdbcDataSource.__java:156)
> at
> Proxy6eb370cb_8e6e_4d06_914b___aeae4440bd27.getConnection(__Unknown
> Source)
> at
> org.apache.karaf.jdbc.__internal.JdbcConnector.__connect(JdbcConnector.java:52)
> at
> org.apache.karaf.jdbc.__internal.JdbcServiceImpl.info
> <http://org.apache.karaf.jdbc.internal.JdbcServiceImpl.info>
> <http://org.apache.karaf.jdbc.__internal.JdbcServiceImpl.info
> <http://org.apache.karaf.jdbc.internal.JdbcServiceImpl.info>>__(JdbcServiceImpl.java:217)
>
> at Proxy9daa3030_80a4_4467_9c66___0e7ff672d27a.info
> <http://0e7ff672d27a.info>(Unknown Source)
> at Proxy413bb2d4_9950_4f87_97c3___3ddf66300a75.info
> <http://3ddf66300a75.info>(Unknown Source)
> at
> org.apache.karaf.jdbc.command.__DataSourcesCommand.doExecute(__DataSourcesCommand.java:40)
> at
> org.apache.karaf.shell.__console.AbstractAction.__execute(AbstractAction.java:__33)[25:org.apache.karaf.shell.__console:3.0.2]
> at
> org.apache.karaf.shell.__console.OsgiCommandSupport.__execute(OsgiCommandSupport.__java:39)[25:org.apache.karaf.__shell.console:3.0.2]
> at
> org.apache.karaf.shell.__commands.basic.__AbstractCommand.execute(__AbstractCommand.java:33)[25:__org.apache.karaf.shell.__console:3.0.2]
> at
> Proxy7a296bd8_2a11_49a3_a5a4___e913fe60ec5f.execute(Unknown
> Source)[:]
> at
> Proxy7a296bd8_2a11_49a3_a5a4___e913fe60ec5f.execute(Unknown
> Source)[:]
> at
> org.apache.felix.gogo.runtime.__CommandProxy.execute(__CommandProxy.java:78)[25:org.__apache.karaf.shell.console:3.__0.2]
> at
> org.apache.felix.gogo.runtime.__Closure.executeCmd(Closure.__java:477)[25:org.apache.karaf.__shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.__Closure.executeStatement(__Closure.java:403)[25:org.__apache.karaf.shell.console:3.__0.2]
> at
> org.apache.felix.gogo.runtime.__Pipe.run(Pipe.java:108)[25:__org.apache.karaf.shell.__console:3.0.2]
> at
> org.apache.felix.gogo.runtime.__Closure.execute(Closure.java:__183)[25:org.apache.karaf.__shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.__Closure.execute(Closure.java:__120)[25:org.apache.karaf.__shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.__CommandSessionImpl.execute(__CommandSessionImpl.java:92)
> at
> org.apache.karaf.shell.__console.impl.jline.__ConsoleImpl.run(ConsoleImpl.__java:203)
> at
> org.apache.karaf.shell.__console.impl.jline.__LocalConsoleManager$2$1$1.run(__LocalConsoleManager.java:115)
> at java.security.__AccessController.doPrivileged(__Native
> Method)[:1.7.0_60]
> at
> org.apache.karaf.jaas.modules.__JaasHelper.doAs(JaasHelper.__java:57)[26:org.apache.karaf.__jaas.modules:3.0.2]
> at
> org.apache.karaf.shell.__console.impl.jline.__LocalConsoleManager$2$1.run(__LocalConsoleManager.java:108)[__25:org.apache.karaf.shell.__console:3.0.2]
>
> On Tue, Dec 23, 2014 at 4:04 PM, Jean-Baptiste Onofré
> <jb@nanthrax.net <ma...@nanthrax.net>
> <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> wrote:
>
> 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
> <ktschmidt@gmail.com <ma...@gmail.com>
> <mailto:ktschmidt@gmail.com <ma...@gmail.com>>
> <mailto:ktschmidt@gmail.com
> <ma...@gmail.com> <mailto:ktschmidt@gmail.com
> <ma...@gmail.com>>>> 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"
> <richard.t.snowden@gmail.com
> <ma...@gmail.com>
> <mailto:richard.t.snowden@__gmail.com
> <ma...@gmail.com>>
> <mailto:richard.t.snowden@
> <mailto:richard.t.snowden@>__gm__ail.com <http://gmail.com>
> <mailto:richard.t.snowden@__gmail.com
> <ma...@gmail.com>>>>
> 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é
> <jb@nanthrax.net <ma...@nanthrax.net>
> <mailto:jb@nanthrax.net <ma...@nanthrax.net>>
> <mailto:jb@nanthrax.net <ma...@nanthrax.net>
> <mailto:jb@nanthrax.net <ma...@nanthrax.net>>>> 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é
> jbonofre@apache.org <ma...@apache.org>
> <mailto:jbonofre@apache.org <ma...@apache.org>>
> <mailto:jbonofre@apache.org
> <ma...@apache.org> <mailto:jbonofre@apache.org
> <ma...@apache.org>>>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> <mailto:jbonofre@apache.org <ma...@apache.org>>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Richard Snowden <ri...@gmail.com>.
Yes, the H2 bundle is installed (has been automatically installed by
"jdbc:create
-t h2 -u test2 -i test2").
By the way: I also get this error when using Postgres. Only Derby seems to
work with "jdbc:create ...".
On Wed, Dec 24, 2014 at 8:04 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:
> Hi Richard,
>
> Can you check (with la command) that the H2 bundle is installed ?
>
> Regards
> JB
>
> On 12/23/2014 10:03 PM, Richard Snowden wrote:
>
>> OK, this seems to work for Derby.
>> feature:install jdbc
>> jdbc:create -t derby -u test -i test
>>
>>
>> But when I do the same for H2 ...
>> jdbc:create -t h2 -u test2 -i test2
>>
>> ... I get this error:
>>
>>
>> 2014-12-23 21:57:44,854 | ERROR | l for user karaf |
>> JdbcServiceImpl | 245 - org.apache.karaf.jdbc.core -
>> 3.0.2 | Can't get information about datasource jdbc/test2
>> java.sql.SQLException: No suitable driver found for null
>> at
>> org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:183)
>> at
>> org.h2.jdbcx.JdbcDataSource.getConnection(JdbcDataSource.java:156)
>> at
>> Proxy6eb370cb_8e6e_4d06_914b_aeae4440bd27.getConnection(Unknown Source)
>> at
>> org.apache.karaf.jdbc.internal.JdbcConnector.
>> connect(JdbcConnector.java:52)
>> at org.apache.karaf.jdbc.internal.JdbcServiceImpl.info
>> <http://org.apache.karaf.jdbc.internal.JdbcServiceImpl.info>
>> (JdbcServiceImpl.java:217)
>>
>> at Proxy9daa3030_80a4_4467_9c66_0e7ff672d27a.info(Unknown
>> Source)
>> at Proxy413bb2d4_9950_4f87_97c3_3ddf66300a75.info(Unknown
>> Source)
>> at
>> org.apache.karaf.jdbc.command.DataSourcesCommand.doExecute(
>> DataSourcesCommand.java:40)
>> at
>> org.apache.karaf.shell.console.AbstractAction.
>> execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.karaf.shell.console.OsgiCommandSupport.
>> execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.
>> shell.console:3.0.2]
>> at
>> org.apache.karaf.shell.commands.basic.AbstractCommand.execute(
>> AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.2]
>> at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
>> Source)[:]
>> at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
>> Source)[:]
>> at
>> org.apache.felix.gogo.runtime.CommandProxy.execute(
>> CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.
>> java:477)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.Closure.executeStatement(
>> Closure.java:403)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:
>> org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:
>> 183)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:
>> 120)[25:org.apache.karaf.shell.console:3.0.2]
>> at
>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>> CommandSessionImpl.java:92)
>> at
>> org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.
>> java:203)
>> at
>> org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1$1.run(
>> LocalConsoleManager.java:115)
>> at java.security.AccessController.doPrivileged(Native
>> Method)[:1.7.0_60]
>> at
>> org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.
>> java:57)[26:org.apache.karaf.jaas.modules:3.0.2]
>> at
>> org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1.run(
>> LocalConsoleManager.java:108)[25:org.apache.karaf.shell.console:3.0.2]
>>
>> On Tue, Dec 23, 2014 at 4:04 PM, Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>> 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
>> <ktschmidt@gmail.com <ma...@gmail.com>
>> <mailto:ktschmidt@gmail.com <ma...@gmail.com>>> 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"
>> <richard.t.snowden@gmail.com
>> <ma...@gmail.com>
>> <mailto:richard.t.snowden@__gmail.com
>> <ma...@gmail.com>>>
>> 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é
>> <jb@nanthrax.net <ma...@nanthrax.net>
>> <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> 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é
>> jbonofre@apache.org <ma...@apache.org>
>> <mailto:jbonofre@apache.org <ma...@apache.org>>
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>>
>>
>>
>> --
>> Jean-Baptiste Onofré
>> jbonofre@apache.org <ma...@apache.org>
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Richard,
Can you check (with la command) that the H2 bundle is installed ?
Regards
JB
On 12/23/2014 10:03 PM, Richard Snowden wrote:
> OK, this seems to work for Derby.
> feature:install jdbc
> jdbc:create -t derby -u test -i test
>
>
> But when I do the same for H2 ...
> jdbc:create -t h2 -u test2 -i test2
>
> ... I get this error:
>
>
> 2014-12-23 21:57:44,854 | ERROR | l for user karaf |
> JdbcServiceImpl | 245 - org.apache.karaf.jdbc.core -
> 3.0.2 | Can't get information about datasource jdbc/test2
> java.sql.SQLException: No suitable driver found for null
> at
> org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:183)
> at
> org.h2.jdbcx.JdbcDataSource.getConnection(JdbcDataSource.java:156)
> at
> Proxy6eb370cb_8e6e_4d06_914b_aeae4440bd27.getConnection(Unknown Source)
> at
> org.apache.karaf.jdbc.internal.JdbcConnector.connect(JdbcConnector.java:52)
> at org.apache.karaf.jdbc.internal.JdbcServiceImpl.info
> <http://org.apache.karaf.jdbc.internal.JdbcServiceImpl.info>(JdbcServiceImpl.java:217)
> at Proxy9daa3030_80a4_4467_9c66_0e7ff672d27a.info(Unknown Source)
> at Proxy413bb2d4_9950_4f87_97c3_3ddf66300a75.info(Unknown Source)
> at
> org.apache.karaf.jdbc.command.DataSourcesCommand.doExecute(DataSourcesCommand.java:40)
> at
> org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.2]
> at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
> Source)[:]
> at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
> Source)[:]
> at
> org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[25:org.apache.karaf.shell.console:3.0.2]
> at
> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
> at
> org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:203)
> at
> org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1$1.run(LocalConsoleManager.java:115)
> at java.security.AccessController.doPrivileged(Native
> Method)[:1.7.0_60]
> at
> org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:57)[26:org.apache.karaf.jaas.modules:3.0.2]
> at
> org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1.run(LocalConsoleManager.java:108)[25:org.apache.karaf.shell.console:3.0.2]
>
> On Tue, Dec 23, 2014 at 4:04 PM, Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
> 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
> <ktschmidt@gmail.com <ma...@gmail.com>
> <mailto:ktschmidt@gmail.com <ma...@gmail.com>>> 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"
> <richard.t.snowden@gmail.com
> <ma...@gmail.com>
> <mailto:richard.t.snowden@__gmail.com
> <ma...@gmail.com>>>
> 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é
> <jb@nanthrax.net <ma...@nanthrax.net>
> <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> 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é
> jbonofre@apache.org <ma...@apache.org>
> <mailto:jbonofre@apache.org <ma...@apache.org>>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Richard Snowden <ri...@gmail.com>.
OK, this seems to work for Derby.
feature:install jdbc
jdbc:create -t derby -u test -i test
But when I do the same for H2 ...
jdbc:create -t h2 -u test2 -i test2
... I get this error:
2014-12-23 21:57:44,854 | ERROR | l for user karaf |
JdbcServiceImpl | 245 - org.apache.karaf.jdbc.core - 3.0.2
| Can't get information about datasource jdbc/test2
java.sql.SQLException: No suitable driver found for null
at
org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:183)
at
org.h2.jdbcx.JdbcDataSource.getConnection(JdbcDataSource.java:156)
at Proxy6eb370cb_8e6e_4d06_914b_aeae4440bd27.getConnection(Unknown
Source)
at
org.apache.karaf.jdbc.internal.JdbcConnector.connect(JdbcConnector.java:52)
at org.apache.karaf.jdbc.internal.JdbcServiceImpl.info
(JdbcServiceImpl.java:217)
at Proxy9daa3030_80a4_4467_9c66_0e7ff672d27a.info(Unknown Source)
at Proxy413bb2d4_9950_4f87_97c3_3ddf66300a75.info(Unknown Source)
at
org.apache.karaf.jdbc.command.DataSourcesCommand.doExecute(DataSourcesCommand.java:40)
at
org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.2]
at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
Source)[:]
at Proxy7a296bd8_2a11_49a3_a5a4_e913fe60ec5f.execute(Unknown
Source)[:]
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[25:org.apache.karaf.shell.console:3.0.2]
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
at
org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:203)
at
org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1$1.run(LocalConsoleManager.java:115)
at java.security.AccessController.doPrivileged(Native
Method)[:1.7.0_60]
at
org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:57)[26:org.apache.karaf.jaas.modules:3.0.2]
at
org.apache.karaf.shell.console.impl.jline.LocalConsoleManager$2$1.run(LocalConsoleManager.java:108)[25:org.apache.karaf.shell.console:3.0.2]
On Tue, Dec 23, 2014 at 4:04 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:
> 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 <ktschmidt@gmail.com
>> <ma...@gmail.com>> 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"
>> <richard.t.snowden@gmail.com <ma...@gmail.com>>
>> 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é
>> <jb@nanthrax.net <ma...@nanthrax.net>> 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é
>> jbonofre@apache.org <ma...@apache.org>
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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 <ktschmidt@gmail.com
> <ma...@gmail.com>> 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"
> <richard.t.snowden@gmail.com <ma...@gmail.com>>
> 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é
> <jb@nanthrax.net <ma...@nanthrax.net>> 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é
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Richard Snowden <ri...@gmail.com>.
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 <kt...@gmail.com> 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" <ri...@gmail.com>
> 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é <jb...@nanthrax.net>
>> 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é
>>> jbonofre@apache.org
>>> http://blog.nanthrax.net
>>> Talend - http://www.talend.com
>>>
>>
>>
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Kevin Schmidt <kt...@gmail.com>.
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" <ri...@gmail.com>
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é <jb...@nanthrax.net>
> 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é
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
>
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Yes, as the classloaders is not the same in OSGi.
Try to use a TCCL and check your import package.
Regards
JB
On 12/23/2014 03:45 PM, Richard Snowden 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é <jb@nanthrax.net
> <ma...@nanthrax.net>> 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é
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Richard Snowden <ri...@gmail.com>.
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é <jb...@nanthrax.net>
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é
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Karaf 3.0.2: Adding H2 Database support
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com