Hello Christoph, Thanks for your response. I was thinking in throwing the JAR in the plugins folder in Eclipse and the create a listener that waits for the service that the H2 bundle registers and then use it, that would be the "OSGi" way...but I'm not sure that fits my case, since only one bundle is going to access the H2 database, there is no need really for my other bundles to access this db....thus, I think the second scenario fits my needs better...that said, any example on how to setup the bundle classpath in the manifest so it doesn't throw NFE all the time? I've tried everything and is still crashing...
Regards, Alejandro On Thu, Feb 6, 2014 at 8:37 PM, Christoph Läubrich <[email protected]>wrote: > Use it as a bundle and use the JDBC Service instead. Thats what is how it > works in OSGi. Binding to a specific implementation like you plan make your > code less modular and more redundant. > That don't mean at all that other bundles can access the database in any > way and has nothing to do with OSGi itself. E.g. if you store the db in > filesystem ANYONE with read acces to that file can acess it. > > If you still want to embedd it, make sure you add it to the bundle > classpath in the manifest and not just somehwere to the java compile time > class path. > > Am 05.02.2014 18:15, schrieb Alejandro Villamarin: > > Hi! >> >> I'm trying to import h2-latest.jar in an existing OSGi (Eclipse) bundle. >> I've simply added the jar file to my project and added it to Java build >> path. While there are no problems at compiation time with this code in my >> bundle Activator: >> >> JdbcDataSource ds = new JdbcDataSource(); >> ds.setURL("jdbc:h2:~/test"); >> ds.setUser("sa"); >> ds.setPassword("sa"); >> Connection conn = ds.getConnection(); >> >> When executed I'm getting NFE: >> >> Caused by: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource >> at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal( >> BundleLoader.java:501) >> at org.eclipse.osgi.internal.loader.BundleLoader.findClass( >> BundleLoader.java:421) >> at org.eclipse.osgi.internal.loader.BundleLoader.findClass( >> BundleLoader.java:412) >> at org.eclipse.osgi.internal.baseadaptor. >> DefaultClassLoader.loadClass(DefaultClassLoader.java:107) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:268) >> >> That said...what I'm missing here? I've seen in the docs that the jar >> itself can be used as a bundle, but I don't want to try this yet, I don't >> need that all the rest of bundles can access the embedded database, the one >> I'm creating will act as a Facade to the data itself. >> >> Any clues? >> >> Thanks! >> Alex >> >> > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
