We are using unbbayes in a third party Java application that we are releasing as a single JAR file. It appears as if loading of the jar flles in protege/bundles and protege/plugins from the classpath is not working. It seems to work when we run our code out of eclipse, but it doesn't work if we run the code from the commandline via "java -jar ...".
This seems to indicate that unbbayes has a dependency on Eclipse, e.g., specific class loaders being used.
Can you look into getting /unbbayes.gui.mebn.ontology.protege/src/main/java/unbbayes/prs/mebn/ontology/protege/ProtegeBundleLauncher.java to load the bundles from the standard classpath the JVM uses ?
This is unlikely to be some dependency to eclipse IDE. For instance, the binary distribution of UnBBayes is something that runs outside eclipse IDE.
If you are generating a single jar file, then probably you are extracting all the class and resource files of the dependencies and repacking them in your jar file (for instance, this is what happens if you use maven and its "jar-with-dependencies" assembly configuration).
Protege adheres to OSGi framework to load bundles/plugins.
If you extract the jar files of protege bundles/plugins and move them somewhere else, you are potentially breaking some OSGi format compatibility. Please, refer to OSGi framework (the actual implementation/API is Apache Felix). At this point, we don't plan to change this class loading scheme, especially because the classloader independence offered by OSGi is quite usefull.
I suspect that you did not experience this issue when you were running your program in eclipse, because on eclipse IDE you probably did not deassemble the original protege's bundle/plugin files.
My suggestion is to keep a separate folder for the protege bundles/plugins, instead of deassembling them and inserting to your jar.
If you don't want redundant classes/files, you may want to remove such classes from your single jar (after moving the protege bundles/plugins to separate folder) and edit your META-INF to include such external jars to the classpath of your application.
Hey Cardiafly,
thanks for the detailed response. Let me clarify a couple of points.
We are not trying to change the OSGi way of loading the bundles/plugins. When we build the single jar, the bundle/plugins jar files simply get included as part of that single jar for OSGi to load. We are not repackaging the classes within bundle/plugins jars, but rather, we are simply including the jar files in the single jar.
When we run out of eclipse, I believe what is happening is that the OSGi framework somehow figures out how to load the bundle/plugins from its classpath. I am pretty certain that these files are not loaded from the file system. When we run from the commandline with the single jar, the OSGi framework fails to load the bundle/plugins files from that single jar.
Keeping a separate disk folder for the bundle/plugins works, but we don't really like this, since it makes packaging our software difficult.
Can you help us figure out how to get OSGi to load the .jars from the classpath rather than from a disk folder ?