title: java.lang.ClassCastException: Cannot cast org.glassfish.web.loader.WebappClassLoader to org.osgi.framework.BundleReference
body: <p>I'm working on a simple application with Glassfish and OSGI. I found this tutorial:
  <a href="http://blogs.oracle.com/arungupta/entry/totd_154_dynamic_osgi_services" rel="nofollow">http://blogs.oracle.com/arungupta/entry/totd_154_dynamic_osgi_services</a>
  I modified the example. You can find my customized example file:
  <a href="http://uploading.com/files/cf1ffd63/test.zip/" rel="nofollow">http://uploading.com/files/cf1ffd63/test.zip/</a>
  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:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Maybe the problem is missing dependency. I can't find the problem? Do you have any idea what may be the problem?</p>