You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Bernd Foersterling <Fo...@pro-crm.de> on 2018/12/20 13:28:28 UTC

Problems using the servlet bridge

Hi all,
I'm currently working on a servlet running an embedded framework using the servlet bridge.
OSGi is fairly new for me, I recently finished reading my first book regarding OSGi.
But let's see what my problem is.
I started by just building the example servlet bridge from the felix-docs (http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/) after updating the dependencies to the most recent versions and adding some extra bundles to run my plugin.
After building the war-file and deploying it to a Tomcat application server v8.0 the frameworks seems to start correctly, so no missing dependencies e.g.
But if I try to access my servlet (that just prints "Hello World" to the browser) I just receive the following exception:

20-Dec-2018 14:04:52.116 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [proxy] in context with path [/CoreRunner] threw exception [Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context] with root cause
javax.servlet.ServletException: Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context

I inspected the corresponding source code a little bit. When the exception is thrown the proxy servlet tries to get the bundle context object from the servlet context attributes, but it does not seem to be there (obviously).
That irritates me a little bit, as the bundle context is set in the first line of the start method in the provision activator.

When I try to run my servlet in a standalone framework everything works fine. So the problem is definitely not my servlet, but the bridge.

Was there a recent change made to the bridge, that made the example stopped working?
Any other thoughts?

Kind regards
Bernd

AW: Problems using the servlet bridge

Posted by Bernd Foersterling <Fo...@pro-crm.de>.
Hi Karl,
thanks for your response!
My source code is the exact same as in the example, with one exception: I am using the WebListener-annotation to register the listener StartupListener. The example registers the listener in web.xml.

Kind regards,
Bernd


-----Ursprüngliche Nachricht-----
Von: Karl Pauls [mailto:karlpauls@gmail.com] 
Gesendet: Donnerstag, 20. Dezember 2018 14:44
An: users@felix.apache.org
Betreff: Re: Problems using the servlet bridge

It should be set by the listener:
http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java
(which creates the FramworkService that in turn sets the context
property). Did you maybe not keep the provided web.xml?

regards,

Karl

On Thu, Dec 20, 2018 at 2:28 PM Bernd Foersterling
<Fo...@pro-crm.de> wrote:
>
> Hi all,
> I'm currently working on a servlet running an embedded framework using the servlet bridge.
> OSGi is fairly new for me, I recently finished reading my first book regarding OSGi.
> But let's see what my problem is.
> I started by just building the example servlet bridge from the felix-docs (http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/) after updating the dependencies to the most recent versions and adding some extra bundles to run my plugin.
> After building the war-file and deploying it to a Tomcat application server v8.0 the frameworks seems to start correctly, so no missing dependencies e.g.
> But if I try to access my servlet (that just prints "Hello World" to the browser) I just receive the following exception:
>
> 20-Dec-2018 14:04:52.116 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [proxy] in context with path [/CoreRunner] threw exception [Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context] with root cause
> javax.servlet.ServletException: Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context
>
> I inspected the corresponding source code a little bit. When the exception is thrown the proxy servlet tries to get the bundle context object from the servlet context attributes, but it does not seem to be there (obviously).
> That irritates me a little bit, as the bundle context is set in the first line of the start method in the provision activator.
>
> When I try to run my servlet in a standalone framework everything works fine. So the problem is definitely not my servlet, but the bridge.
>
> Was there a recent change made to the bridge, that made the example stopped working?
> Any other thoughts?
>
> Kind regards
> Bernd



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Problems using the servlet bridge

Posted by Karl Pauls <ka...@gmail.com>.
It should be set by the listener:
http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java
(which creates the FramworkService that in turn sets the context
property). Did you maybe not keep the provided web.xml?

regards,

Karl

On Thu, Dec 20, 2018 at 2:28 PM Bernd Foersterling
<Fo...@pro-crm.de> wrote:
>
> Hi all,
> I'm currently working on a servlet running an embedded framework using the servlet bridge.
> OSGi is fairly new for me, I recently finished reading my first book regarding OSGi.
> But let's see what my problem is.
> I started by just building the example servlet bridge from the felix-docs (http://svn.apache.org/repos/asf/felix/trunk/http/samples/bridge/) after updating the dependencies to the most recent versions and adding some extra bundles to run my plugin.
> After building the war-file and deploying it to a Tomcat application server v8.0 the frameworks seems to start correctly, so no missing dependencies e.g.
> But if I try to access my servlet (that just prints "Hello World" to the browser) I just receive the following exception:
>
> 20-Dec-2018 14:04:52.116 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [proxy] in context with path [/CoreRunner] threw exception [Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context] with root cause
> javax.servlet.ServletException: Bundle context attribute [org.osgi.framework.BundleContext] not set in servlet context
>
> I inspected the corresponding source code a little bit. When the exception is thrown the proxy servlet tries to get the bundle context object from the servlet context attributes, but it does not seem to be there (obviously).
> That irritates me a little bit, as the bundle context is set in the first line of the start method in the provision activator.
>
> When I try to run my servlet in a standalone framework everything works fine. So the problem is definitely not my servlet, but the bridge.
>
> Was there a recent change made to the bridge, that made the example stopped working?
> Any other thoughts?
>
> Kind regards
> Bernd



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org