users@glassfish.java.net

Re: Embed Apache Felix in a Web Application

From: Sanjeeb Sahoo <Sahoo_at_Sun.COM>
Date: Tue, 22 Jun 2010 23:57:24 +0530

You must have configured system bundle to export javax.servlet package
for embedded Felix. What class loader have you configured as the parent
class loader for embedded Felix? Try setting

org.osgi.framework.bundle.parent=framework

in your felix config file.

Having said that why would you embed Felix in your webapp deployed in
GlassFish v3 when GlassFish v3 is already deployed inside Felix? Your
web app can already be deployed as an OSGi bundle allowing it to take
advantage of both Java EE and OSGi APIs.

Sahoo

On Tuesday 22 June 2010 09:25 PM, glassfish_at_javadesktop.org wrote:
> Hi all,
> I'm trying to develop an OSGI based WebApp embedding Apache Felix in it using Apache Felix Http Bridge to register a simple servlet. When deploying application on Glassfish V3 i get following exception when the bundle containing the servlet starts:
>
> [#|2010-06-22T17:07:07.281+0200|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|org.osgi.framework.BundleException: Activator start error in bundle com.test.basic.servlet [10].
> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1751)
> at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:902)
> at org.apache.felix.fileinstall.internal.DirectoryWatcher.start(DirectoryWatcher.java:1027)
> at org.apache.felix.fileinstall.internal.DirectoryWatcher.start(DirectoryWatcher.java:1013)
> at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1006)
> at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:396)
> at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:206)
> Caused by: java.lang.NoClassDefFoundError: javax/servlet/Servlet
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
> at java.lang.Class.getConstructor0(Class.java:2699)
> at java.lang.Class.newInstance0(Class.java:326)
> at java.lang.Class.newInstance(Class.java:308)
> at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3520)
> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1695)
> ... 8 more
> Caused by: java.lang.ClassNotFoundException: *** Package 'javax.servlet' is imported by bundle 10 from bundle 0, but the exported package from bundle 0 does not contain the requested class 'javax.servlet.Servlet'. Please verify that the class name is correct in the importing bundle 10 and/or that the exported package is correctly bundled in 0. ***
> at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1670)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> ... 15 more
> Caused by: java.lang.ClassNotFoundException: javax.servlet.Servlet
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at org.apache.felix.framework.ExtensionManager$ExtensionManagerModule.getClassByDelegation(ExtensionManager.java:670)
> at org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
> at org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1370)
> at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:683)
> at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:61)
> at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1656)
> ... 17 more
> |#]
>
>
> Looks like Glassfish is not exporting J2EE classes to Felix. I attach my eclipse test project. Any help is appreciated.
> [Message sent by forum member 'dboltri']
>
> http://forums.java.net/jive/thread.jspa?messageID=475373
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>