0

I'm working on a simple application with Glassfish and OSGI. I found this tutorial: http://blogs.oracle.com/arungupta/entry/totd_154_dynamic_osgi_services I modified the example. You can find my customized example file: http://uploading.com/files/cf1ffd63/test.zip/ I created EAR package with web module and EJB module. I created a session bean which calls the OSGI bundle. I successfully compiled the project. The problem is that when i uploaded the packages into Glassfish application server and tried to open the simple applet into the web module this error message appears:

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.ClassCastException: Cannot cast org.glassfish.web.loader.WebappClassLoader to org.osgi.framework.BundleReference

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
GlassFish Server Open Source Edition 3.1.1

Maybe the problem is missing dependency. I can't find the problem? Do you have any idea what may be the problem?

2
  • Post the full stacktrace from the Glassfish logs. Commented Jan 12, 2012 at 11:45
  • this is the error stack pastebin.com/FNaTd9jP Commented Jan 12, 2012 at 12:09

2 Answers 2

2

Section 3.8.9 of the OSGi Core 4.2 spec (org.osgi.framework;version=1.5) requires that all bundle class loaders must implement the BundleReference interface. Perhaps the class loader in GlassFish does not do this? What version of the OSGi Core spec does your version of GlassFish support?

Sign up to request clarification or add additional context in comments.

Comments

2

You shouldn'tdeploy the app as an ear, both modules must be deployed separately as OSGi bundles

3 Comments

The problem is that I'm developing an application which uses JNI. As far as I know only EAR package can contain resource adapter in order to make java->C bridge. Is it possible to develop WAR archive which can invoke JNI?
Your resource adapter can also be deployed as a module, likely non-osgi one.
It turns out that EAR package cannot call methods from OSGI bundle by design. Here if someone wants he can vote for this: java.net/jira/browse/GLASSFISH-6741

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.