On 6/22/10 6:29 PM, jamie campbell wrote:
On 10-06-21 02:02 PM, Richard S. Hall wrote:
On 6/21/10 14:57, Kelvin Chan wrote:
Hi guys,
I just started with OSGi/Felix and went through a lot of reading
over the weekend regarding classloading/osgi/felix. I still don't
have a clear idea of how to incorporate an external library into my
app.
I understand that OSGi do class loading through Import-Package, no
more linear class loading like in an traditional Java app. That
means if a bundle does not specify what packages it want to import,
it will not be available to that bundle. On the other hand,
everything on classpath, if specified by Import-Package, will be
available to a bundle. (did I get that right?)
A bundle can only see stuff it imports as long as there is someone
else exporting it. For class path packages, the system bundle (i.e.,
the framework) will export everything in the JRE by default. If you
have some other non-JRE packages on the class path that you want
bundles to be able to import, then you must add them to the
org.osgi.framework.system.packages.extra property in the
conf/config.properties file.
This is actually very pertinent to a problem I'm facing as well. I'm
trying to get openjpa as a bundle working with mysql, but I keep
getting ClassNotFound com.mysql.jdbc.Driver exceptions.
Based on the above info, I changed my launching script (adding the
mysql connector jar entry, which I even carefully selected to make
sure it has bundling info, although I don't know if that's important) to:
java -splash:/home/jamie/1x1.gif -classpath
system/org.apache.felix.karaf/org.apache.felix.karaf.main/1.6.0/org.apache.felix.karaf.main-1.6.0.jar:system/org.apache.felix.karaf.jaas/org.apache.felix.karaf.jaas.boot/1.6.0/org.apache.felix.karaf.jaas.boot-1.6.0.jar:/home/jamie/applications/com.springsource.com.mysql.jdbc/5.1.6/com.springsource.com.mysql.jdbc-5.1.6.jar
-Dkaraf.base=$FELBASE -Dkaraf.home=$FELBASE
-Dstorage.location=$FELBASE/instances
-Dkaraf.default.repository=system -Dkaraf.startLocalConsole=true
-Dkaraf.startRemoteShell=false org.apache.felix.karaf.main.Main "$@"
and changed the extra property in etc/config.properties from
org.osgi.framework.system.packages.extra=\
org.apache.felix.karaf.jaas.boot; version=1.6.0, \
org.apache.felix.karaf.version; version=1.6.0
to
org.osgi.framework.system.packages.extra=\
org.apache.felix.karaf.jaas.boot; version=1.6.0, \
org.apache.felix.karaf.version; version=1.6.0, \
com.mysql.jdbc;
(Actually I tried both with and without the final trailing ';' )
You don't need the trailing semi-colon, that separates the package from
any attributes. Was your bundle importing this package when you tried this?
But, the class not found exceptioning is still occurring :( ... any
other stuff I should be changing? It's not an openjpa idiosyncrasy
because I traced openjpa to where it's trying to do the resolution and
mirrored the resolution code to my own module, specifically
Class getme = Class.forName("com.mysql.jdbc.Driver");
Which goes up the resolution stack ended up in ModuleImpl's
findClassOrResourceByDelegation function...
I also tried changing bootdelegation from
org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
to
org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*,com.mysql.jdbc.*
For boot delegation, I think you have to set
org.osgi.framework.bundle.parent to "app" in config.properties, but
importing is probably better than boot delegation.
-> richard
but still no lovin'...
-Jamie
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]