I made some progress finally. I had to make some dependency hacks to install jpa2 (hard dependency on 1.0 in ...catalina.springsource, spring.orm won't resolve or at least bind to wrong version when both versions installed)
Now guess I have my own hibernate library bundle (latest version) that wants to load a PostUpdateEventListener from my services bundle. I tried the buddy-policies from eclipse but they seem not to be supported on virgo. I tried to import the package from my services in the hibernate bundle (which should be circular then) but still I get CNF Exception.
What would we the best way to make hibernate load my class? What about the entites (yet another bundle) I used to solve that with buddy class loading and it would be great if you give me an idea how to achieve that on virgo.
Btw I had to install spring 3.0.4 to make jpa2 work (bugs in 3.0.0) and then I find the admin console broken (depency on springframework.js -- I have to search for this)
I guess I could use import-scope:application but then I need a dummy bundle to import that package. Would be nice if we could see Buddy-Class Loading here
Btw I had to install spring 3.0.4 to make jpa2 work (bugs in 3.0.0) and then I find the admin console broken (depency on springframework.js -- I have to search for this)
To use Spring 3.0.4, you should replace just the Spring framework JARs and the Spring .libd file in repository ext with the later version. The org.springframework.js bundle is actually part of Spring web and need not be replaced. Did you delete it from repository/ext and not replace it?
import-scope:=application will only import into the other bundles of the application, so why not code import-scope:=application in one of those bundles rather than add a dummy bundle?
Hi Glyn, sorry for putting that in bugzilla, I guess here is the better place. The package hibernate needs is in my services bundle which is currently at the top if my bundle hierarchy. So the package is currently imported from nowhere else. Where would you put the import ? In the service bundle ? will that work ? I guess import wont reference packages inside the actual bundle.
Yes, let's continue this conversation here so others may benefit.
the basics of OSGi are that a class can only be loaded by the bundle that contains it or by another bundle that is wired to a package export of the bundle that contains it. Wiring is specified using import-package, import-bundle, or occasionally import-library. The crucial thing in this situation is to make sure the bundle containing the class to be loaded from elsewhere actually exports the class. If you have used bundlor or bnd to generate the manifest, then it should.
As for scoped plans, see the Virgo programmer guide for starters.
So if I have an export in a bundle thats contained in a plan its automatically visible to other bundles in the plan ? Thats different from what I'm used to.
Other bundles in the same plan still have to import the package (or import-bundle etc.) but the crucial point is that exports of all bundles in the plan are imported by the synthetic context bundle and made available for thread context class loading for the likes of Hibernate.
I double checked. Package is exported, plan is scoped.
I get
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: de.eiswind.mango.server.hibernate.PostUpdateEventListener in KernelBundleClassLoader: [bundle=eiswind-publishing-server.plan-1-de.eiswind.org.hibernate_3.5.6]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:139)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.cfg.Configuration.setListeners(Configuration.java:1763)
... 36 common frames omitted
Caused by: java.lang.ClassNotFoundException: de.eiswind.mango.server.hibernate.PostUpdateEventListener
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:135)
... 41 common frames omitted
Any ideas ? Regarding to your post this should work
It looks like you are including Hibernate in the plan, which is not the normal approach as multiple applications may wish to share Hibernate. If you place Hibernate in repository/usr instead and take it out of your plan, Virgo will fault it in when your application is installed (because parts of your app import Hibernate packages) and then the thread context class loader will be set when Hibernate is called, since it will be outside the scope and IIRC that's what drives us to set the TCCL.
That's a shame. It seems like Hibernate is not doing its usual thread context class loading. However, this is a newer version of Hibernate than we've used in the past, so maybe it has changed significantly.
Have you tried hacking a package import for de.eiswind.mango.server.hibernate into the Hibernate manifest? Although this is not a long-term solution, it might get you further. If it works, there is a proper way to do it by attaching a fragment to the Hibernate bundle, but let's cross that bridge if we get to it.
You were right that I had the hibernate bundle in my plan. I removed it and put in in repository/usr which caused sts tooling obvously some trouble. I guess I will habe more questions coming up Thanks again for the great support.
I am also getting this CNF exception - I tried cleaning and restarting but with no luck.
I would like to know which jars are supposed to go into the usr folder and how the manifest file should look like.