You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Anders Engström <ep...@gmail.com> on 2016/02/04 15:34:40 UTC

Setting up Http Servlet Bridge (relative paths)

Hi -

I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 

I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).

The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).

Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.

Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?

The behaviour I was expecting was that when registering the servlet like this:

`httpService.registerServlet(“/demo”, theServlet, null, null);`

a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo%60> would be dispatched to the `theServlet`.

If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/

Best regards //Anders

Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Hi -

it took some time, but I’ve created an issue for this now: https://issues.apache.org/jira/browse/FELIX-5219 <https://issues.apache.org/jira/browse/FELIX-5219>

Best Regards //Anders

> On 16 Feb 2016, at 07:26, Carsten Ziegeler <cz...@apache.org> wrote:
> 
> This definitely sounds like a bug in the new version.
> Patches are welcome :)
> 
> Thanks
> Carsten
> 
> Anders Engström wrote
>> Hi again -
>> 
>> One thing that differs between the jackrabbit standalone-sample and my sample code is the *version* of the http proxy/bridge libraries.
>> 
>> I’m using org.apache.felix.http.proxy/3.0.0 and org.apache.felix.http.bridge/3.0.6 - in your sample both those libraries are at version 2.3.2.
>> 
>> Guess what - If I downgrade to 2.3.2 everything works just as expected! If I set the org.apache.felix.http.bridge dependency to 3.0.0 it no longer works.
>> 
>> I assume this isn’t a known issue (I’ve had a quick look at the Jira issue tracker). If a maintainer could verify this as a bug it would be super-sweet. I’d be happy to help out with a patch.
>> 
>> Best regards //Anders
>> 
>> 
>> 
>>> On 11 Feb 2016, at 09:24, Anders Engström <ep...@gmail.com> wrote:
>>> 
>>> Thanks a lot for replying!
>>> 
>>> I’ll dig into the oak-standalone sample code to see what’s different from my sample application.
>>> 
>>> I’ve added the Felix WebConsole to my sample app @ https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole <https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole><https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole <https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole>> as well — but in order to access the console at http://localhost:8080/osgi/system/console <http://localhost:8080/osgi/system/console> <http://localhost:8080/osgi/system/console <http://localhost:8080/osgi/system/console>> I’m forced to mount the WebConsole root servlet at the full path (-Dfelix.webconsole.manager.root=/osgi/system/console).
>>> 
>>> I still haven’t seen a plain, bare-bone, no fuzz, example of using the Felix Http Bridge/Proxy when the proxy-servlet isn’t bound to the “/*”.   My sample-app is, imo, as clean and bare-bone as possible - but I can’t find a way to dispatch requests to the osgi-servlets without binding them to the full (in-context) path :/
>>> 
>>> /Anders
>>> 
>>>> On 11 Feb 2016, at 04:43, Chetan Mehrotra <chetan.mehrotra@gmail.com <ma...@gmail.com> <mailto:chetan.mehrotra@gmail.com <ma...@gmail.com>>> wrote:
>>>> 
>>>> HI Anders,
>>>> 
>>>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>>>> 
>>>> Have a look at [1] where there ProxyServlet is registered with
>>>> '/osgi/*' and it works fine. The application is based on Felix Connect
>>>> and Spring Boot but the OSGi constructs used should be common to your
>>>> usecase
>>>> 
>>>> You can launch the app using
>>>> 
>>>> java -jar target/oak-standalone-1.4-SNAPSHOT.jar --server.contextPath=/foo
>>>> 
>>>> Then the Felix WebConsole is accessible at
>>>> http://localhost:8080/foo/osgi/system/console <http://localhost:8080/foo/osgi/system/console> <http://localhost:8080/foo/osgi/system/console <http://localhost:8080/foo/osgi/system/console>> where 'foo' is
>>>> contextPath and 'osgi' is the path against which the ProxyServlet is
>>>> bound
>>>> 
>>>> Chetan Mehrotra
>>>> [1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java <https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java><https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java <https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java>>
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org> <mailto:users-unsubscribe@felix.apache.org <ma...@felix.apache.org>>
>>>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org> <mailto:users-help@felix.apache.org <ma...@felix.apache.org>>
>>>> 
>>> 
>> 
>> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziegeler@apache.org <ma...@apache.org>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>

Re: Setting up Http Servlet Bridge (relative paths)

Posted by Carsten Ziegeler <cz...@apache.org>.
This definitely sounds like a bug in the new version.
Patches are welcome :)

Thanks
Carsten

Anders Engström wrote
> Hi again -
> 
> One thing that differs between the jackrabbit standalone-sample and my sample code is the *version* of the http proxy/bridge libraries.
> 
> I’m using org.apache.felix.http.proxy/3.0.0 and org.apache.felix.http.bridge/3.0.6 - in your sample both those libraries are at version 2.3.2.
> 
> Guess what - If I downgrade to 2.3.2 everything works just as expected! If I set the org.apache.felix.http.bridge dependency to 3.0.0 it no longer works.
> 
> I assume this isn’t a known issue (I’ve had a quick look at the Jira issue tracker). If a maintainer could verify this as a bug it would be super-sweet. I’d be happy to help out with a patch.
> 
> Best regards //Anders
> 
> 
> 
>> On 11 Feb 2016, at 09:24, Anders Engström <ep...@gmail.com> wrote:
>>
>> Thanks a lot for replying!
>>
>> I’ll dig into the oak-standalone sample code to see what’s different from my sample application.
>>
>> I’ve added the Felix WebConsole to my sample app @ https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole <https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole> as well — but in order to access the console at http://localhost:8080/osgi/system/console <http://localhost:8080/osgi/system/console> I’m forced to mount the WebConsole root servlet at the full path (-Dfelix.webconsole.manager.root=/osgi/system/console).
>>
>> I still haven’t seen a plain, bare-bone, no fuzz, example of using the Felix Http Bridge/Proxy when the proxy-servlet isn’t bound to the “/*”.   My sample-app is, imo, as clean and bare-bone as possible - but I can’t find a way to dispatch requests to the osgi-servlets without binding them to the full (in-context) path :/
>>
>> /Anders
>>
>>> On 11 Feb 2016, at 04:43, Chetan Mehrotra <chetan.mehrotra@gmail.com <ma...@gmail.com>> wrote:
>>>
>>> HI Anders,
>>>
>>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>>>
>>> Have a look at [1] where there ProxyServlet is registered with
>>> '/osgi/*' and it works fine. The application is based on Felix Connect
>>> and Spring Boot but the OSGi constructs used should be common to your
>>> usecase
>>>
>>> You can launch the app using
>>>
>>> java -jar target/oak-standalone-1.4-SNAPSHOT.jar --server.contextPath=/foo
>>>
>>> Then the Felix WebConsole is accessible at
>>> http://localhost:8080/foo/osgi/system/console <http://localhost:8080/foo/osgi/system/console> where 'foo' is
>>> contextPath and 'osgi' is the path against which the ProxyServlet is
>>> bound
>>>
>>> Chetan Mehrotra
>>> [1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java <https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
>>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>
>>>
>>
> 
> 


 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

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


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Hi again -

One thing that differs between the jackrabbit standalone-sample and my sample code is the *version* of the http proxy/bridge libraries.

I’m using org.apache.felix.http.proxy/3.0.0 and org.apache.felix.http.bridge/3.0.6 - in your sample both those libraries are at version 2.3.2.

Guess what - If I downgrade to 2.3.2 everything works just as expected! If I set the org.apache.felix.http.bridge dependency to 3.0.0 it no longer works.

I assume this isn’t a known issue (I’ve had a quick look at the Jira issue tracker). If a maintainer could verify this as a bug it would be super-sweet. I’d be happy to help out with a patch.

Best regards //Anders



> On 11 Feb 2016, at 09:24, Anders Engström <ep...@gmail.com> wrote:
> 
> Thanks a lot for replying!
> 
> I’ll dig into the oak-standalone sample code to see what’s different from my sample application.
> 
> I’ve added the Felix WebConsole to my sample app @ https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole <https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole> as well — but in order to access the console at http://localhost:8080/osgi/system/console <http://localhost:8080/osgi/system/console> I’m forced to mount the WebConsole root servlet at the full path (-Dfelix.webconsole.manager.root=/osgi/system/console).
> 
> I still haven’t seen a plain, bare-bone, no fuzz, example of using the Felix Http Bridge/Proxy when the proxy-servlet isn’t bound to the “/*”.   My sample-app is, imo, as clean and bare-bone as possible - but I can’t find a way to dispatch requests to the osgi-servlets without binding them to the full (in-context) path :/
> 
> /Anders
> 
>> On 11 Feb 2016, at 04:43, Chetan Mehrotra <chetan.mehrotra@gmail.com <ma...@gmail.com>> wrote:
>> 
>> HI Anders,
>> 
>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>> 
>> Have a look at [1] where there ProxyServlet is registered with
>> '/osgi/*' and it works fine. The application is based on Felix Connect
>> and Spring Boot but the OSGi constructs used should be common to your
>> usecase
>> 
>> You can launch the app using
>> 
>> java -jar target/oak-standalone-1.4-SNAPSHOT.jar --server.contextPath=/foo
>> 
>> Then the Felix WebConsole is accessible at
>> http://localhost:8080/foo/osgi/system/console <http://localhost:8080/foo/osgi/system/console> where 'foo' is
>> contextPath and 'osgi' is the path against which the ProxyServlet is
>> bound
>> 
>> Chetan Mehrotra
>> [1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java <https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>
>> 
> 


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Thanks a lot for replying!

I’ll dig into the oak-standalone sample code to see what’s different from my sample application.

I’ve added the Felix WebConsole to my sample app @ https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole <https://github.com/metamorph/http-osgi-bridge/tree/add-felix-webconsole> as well — but in order to access the console at http://localhost:8080/osgi/system/console <http://localhost:8080/osgi/system/console> I’m forced to mount the WebConsole root servlet at the full path (-Dfelix.webconsole.manager.root=/osgi/system/console).

I still haven’t seen a plain, bare-bone, no fuzz, example of using the Felix Http Bridge/Proxy when the proxy-servlet isn’t bound to the “/*”.   My sample-app is, imo, as clean and bare-bone as possible - but I can’t find a way to dispatch requests to the osgi-servlets without binding them to the full (in-context) path :/

/Anders

> On 11 Feb 2016, at 04:43, Chetan Mehrotra <ch...@gmail.com> wrote:
> 
> HI Anders,
> 
>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
> 
> Have a look at [1] where there ProxyServlet is registered with
> '/osgi/*' and it works fine. The application is based on Felix Connect
> and Spring Boot but the OSGi constructs used should be common to your
> usecase
> 
> You can launch the app using
> 
> java -jar target/oak-standalone-1.4-SNAPSHOT.jar --server.contextPath=/foo
> 
> Then the Felix WebConsole is accessible at
> http://localhost:8080/foo/osgi/system/console where 'foo' is
> contextPath and 'osgi' is the path against which the ProxyServlet is
> bound
> 
> Chetan Mehrotra
> [1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Chetan Mehrotra <ch...@gmail.com>.
HI Anders,

> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.

Have a look at [1] where there ProxyServlet is registered with
'/osgi/*' and it works fine. The application is based on Felix Connect
and Spring Boot but the OSGi constructs used should be common to your
usecase

You can launch the app using

java -jar target/oak-standalone-1.4-SNAPSHOT.jar --server.contextPath=/foo

Then the Felix WebConsole is accessible at
http://localhost:8080/foo/osgi/system/console where 'foo' is
contextPath and 'osgi' is the path against which the ProxyServlet is
bound

Chetan Mehrotra
[1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-examples/standalone/src/main/java/org/apache/jackrabbit/oak/standalone/WebConsoleSupport.java

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


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Hi again -

I guess it’s just me that’s having problems with this (judging from the number of replies) *smile*.

So, I get the behaviour I need if I drop the servlet-path from the request. That way a request to the proxy-servlet on “/<context>/proxy-servlet/foo” ends up as a call to `org.apache.felix.http.base.internal.registry.HandlerRegistry#resolveServlet` with the parameter `/foo` (instead of `/proxy-servlet/foo`).

https://github.com/metamorph/http-osgi-bridge/tree/feature/add-filter-to-remove-servlet-path <https://github.com/metamorph/http-osgi-bridge/tree/feature/add-filter-to-remove-servlet-path>

This way the same servlet-alias can be used both when using the servlet-bridge or when using a stand-alone HttpService-impl (like pax-web or the Felix HttpService).

Would it make sense to add an option (either to the Proxy servlet or to the org.apache.felix.http.base.internal.dispatch.Dispatcher) to exclude the `servletPath` from the path fed to the `HandlerRegistry#resolveServlet`?

Best regards //Anders

> On 05 Feb 2016, at 08:27, Anders Engström <ep...@gmail.com> wrote:
> 
> Thanks for the link, Carsten - I’ve had a look and, as you mentioned, the way Sling is mounting servlets isn’t comparable to how it’s done in a  straight forward web-app.
> 
> I’ve been digging through the code of org.apache.felix.http.(proxy | bridge) and debugging to see how it all fits together. As far as I can understand there is no way that the proxy+bridge can work if the ProxyServlet isn’t bound to “/*”.  I’d be happy to be proven wrong though :)
> 
> Maybe it’s possible to do some fancy HttpServletRequestWrapper hacking in order to pass on the request to the DispatcherServlet *without* the ProxyServlet path?
> 
> I’ve created a reference projekt @ https://github.com/metamorph/http-osgi-bridge <https://github.com/metamorph/http-osgi-bridge> that illustrates the issue. It embeds and starts Felix from the web-application then loads a set of bundles to enable the bridge component.
> 
> It would be great if you’d check my sample code and let me know if I’m doing something horribly wrong :)
> 
> Best regards //Anders
> 
> 
>> On 04 Feb 2016, at 17:26, Carsten Ziegeler <cziegeler@apache.org <ma...@apache.org>> wrote:
>> 
>> Anders Engström wrote
>>> Hi, thanks for replying - 
>>> 
>>> that’s interesting.. code you provide a pointer to some sample code?
>> 
>> The code for Sling can be found at:
>> 
>> http://svn.apache.org/repos/asf/sling/trunk/launchpad/base/ <http://svn.apache.org/repos/asf/sling/trunk/launchpad/base/>
>> 
>> It's a whole module and more complicated than what you probably need,
>> but maybe it gives you a good hint
>> 
>> Carsten
>> 
>>> 
>>> /Anders
>>> 
>>>> On 04 Feb 2016, at 16:45, Carsten Ziegeler <cziegeler@apache.org <ma...@apache.org>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I dont know the details, but we use the bridge in Apache Sling and in
>>>> some other projects. And if we register a servlet at /demo it's not
>>>> directly reachable at /demo, but /context/{servlet}/demo
>>>> 
>>>> Carsten
>>>> 
>>>> Anders Engström wrote
>>>>> Hi -
>>>>> 
>>>>> I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 
>>>>> 
>>>>> I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).
>>>>> 
>>>>> The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).
>>>>> 
>>>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>>>>> 
>>>>> Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?
>>>>> 
>>>>> The behaviour I was expecting was that when registering the servlet like this:
>>>>> 
>>>>> `httpService.registerServlet(“/demo”, theServlet, null, null);`
>>>>> 
>>>>> a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`> <http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`>> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60>>> would be dispatched to the `theServlet`.
>>>>> 
>>>>> If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/
>>>>> 
>>>>> Best regards //Anders
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> Carsten Ziegeler
>>>> Adobe Research Switzerland
>>>> cziegeler@apache.org <ma...@apache.org> <mailto:cziegeler@apache.org <ma...@apache.org>>
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org> <mailto:users-unsubscribe@felix.apache.org <ma...@felix.apache.org>>
>>>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org> <mailto:users-help@felix.apache.org <ma...@felix.apache.org>>
>>> 
>> 
>> 
>> 
>> -- 
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziegeler@apache.org <ma...@apache.org>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Thanks for the link, Carsten - I’ve had a look and, as you mentioned, the way Sling is mounting servlets isn’t comparable to how it’s done in a  straight forward web-app.

I’ve been digging through the code of org.apache.felix.http.(proxy | bridge) and debugging to see how it all fits together. As far as I can understand there is no way that the proxy+bridge can work if the ProxyServlet isn’t bound to “/*”.  I’d be happy to be proven wrong though :)

Maybe it’s possible to do some fancy HttpServletRequestWrapper hacking in order to pass on the request to the DispatcherServlet *without* the ProxyServlet path?

I’ve created a reference projekt @ https://github.com/metamorph/http-osgi-bridge <https://github.com/metamorph/http-osgi-bridge> that illustrates the issue. It embeds and starts Felix from the web-application then loads a set of bundles to enable the bridge component.

It would be great if you’d check my sample code and let me know if I’m doing something horribly wrong :)

Best regards //Anders


> On 04 Feb 2016, at 17:26, Carsten Ziegeler <cz...@apache.org> wrote:
> 
> Anders Engström wrote
>> Hi, thanks for replying - 
>> 
>> that’s interesting.. code you provide a pointer to some sample code?
> 
> The code for Sling can be found at:
> 
> http://svn.apache.org/repos/asf/sling/trunk/launchpad/base/ <http://svn.apache.org/repos/asf/sling/trunk/launchpad/base/>
> 
> It's a whole module and more complicated than what you probably need,
> but maybe it gives you a good hint
> 
> Carsten
> 
>> 
>> /Anders
>> 
>>> On 04 Feb 2016, at 16:45, Carsten Ziegeler <cz...@apache.org> wrote:
>>> 
>>> Hi,
>>> 
>>> I dont know the details, but we use the bridge in Apache Sling and in
>>> some other projects. And if we register a servlet at /demo it's not
>>> directly reachable at /demo, but /context/{servlet}/demo
>>> 
>>> Carsten
>>> 
>>> Anders Engström wrote
>>>> Hi -
>>>> 
>>>> I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 
>>>> 
>>>> I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).
>>>> 
>>>> The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).
>>>> 
>>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>>>> 
>>>> Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?
>>>> 
>>>> The behaviour I was expecting was that when registering the servlet like this:
>>>> 
>>>> `httpService.registerServlet(“/demo”, theServlet, null, null);`
>>>> 
>>>> a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`> <http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`>> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60>>> would be dispatched to the `theServlet`.
>>>> 
>>>> If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/
>>>> 
>>>> Best regards //Anders
>>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> Carsten Ziegeler
>>> Adobe Research Switzerland
>>> cziegeler@apache.org <ma...@apache.org> <mailto:cziegeler@apache.org <ma...@apache.org>>
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org> <mailto:users-unsubscribe@felix.apache.org <ma...@felix.apache.org>>
>>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org> <mailto:users-help@felix.apache.org <ma...@felix.apache.org>>
>> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziegeler@apache.org <ma...@apache.org>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>

Re: Setting up Http Servlet Bridge (relative paths)

Posted by Carsten Ziegeler <cz...@apache.org>.
Anders Engström wrote
> Hi, thanks for replying - 
> 
> that’s interesting.. code you provide a pointer to some sample code?

The code for Sling can be found at:

http://svn.apache.org/repos/asf/sling/trunk/launchpad/base/

It's a whole module and more complicated than what you probably need,
but maybe it gives you a good hint

Carsten

> 
> /Anders
> 
>> On 04 Feb 2016, at 16:45, Carsten Ziegeler <cz...@apache.org> wrote:
>>
>> Hi,
>>
>> I dont know the details, but we use the bridge in Apache Sling and in
>> some other projects. And if we register a servlet at /demo it's not
>> directly reachable at /demo, but /context/{servlet}/demo
>>
>> Carsten
>>
>> Anders Engström wrote
>>> Hi -
>>>
>>> I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 
>>>
>>> I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).
>>>
>>> The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).
>>>
>>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>>>
>>> Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?
>>>
>>> The behaviour I was expecting was that when registering the servlet like this:
>>>
>>> `httpService.registerServlet(“/demo”, theServlet, null, null);`
>>>
>>> a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60>> would be dispatched to the `theServlet`.
>>>
>>> If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/
>>>
>>> Best regards //Anders
>>>
>>
>>
>>
>> -- 
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> cziegeler@apache.org <ma...@apache.org>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>
> 


 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

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


Re: Setting up Http Servlet Bridge (relative paths)

Posted by Anders Engström <ep...@gmail.com>.
Hi, thanks for replying - 

that’s interesting.. code you provide a pointer to some sample code?

/Anders

> On 04 Feb 2016, at 16:45, Carsten Ziegeler <cz...@apache.org> wrote:
> 
> Hi,
> 
> I dont know the details, but we use the bridge in Apache Sling and in
> some other projects. And if we register a servlet at /demo it's not
> directly reachable at /demo, but /context/{servlet}/demo
> 
> Carsten
> 
> Anders Engström wrote
>> Hi -
>> 
>> I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 
>> 
>> I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).
>> 
>> The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).
>> 
>> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
>> 
>> Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?
>> 
>> The behaviour I was expecting was that when registering the servlet like this:
>> 
>> `httpService.registerServlet(“/demo”, theServlet, null, null);`
>> 
>> a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo`> <http://host:port/context/bundles/demo%60 <http://host:port/context/bundles/demo%60>> would be dispatched to the `theServlet`.
>> 
>> If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/
>> 
>> Best regards //Anders
>> 
> 
> 
> 
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziegeler@apache.org <ma...@apache.org>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org <ma...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>

Re: Setting up Http Servlet Bridge (relative paths)

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

I dont know the details, but we use the bridge in Apache Sling and in
some other projects. And if we register a servlet at /demo it's not
directly reachable at /demo, but /context/{servlet}/demo

Carsten

Anders Engström wrote
> Hi -
> 
> I’m trying to set up the Felix Servlet Bridge in Tomcat (8) as a proxy to a bunch of services running in an embedded OSGi container. 
> 
> I’ve registered the `org.apache.felix.http.proxy.impl.ProxyServletContextListener` in web.xml and I’ve got a servlet setup that uses the `org.apache.felix.http.proxy.DispatcherTracker` to dispatch request to the bridge (which is installed in the OSGi container).
> 
> The reason I’m using a custom servlet is because our OSGi container isn’t started until after the web-application have started (and the org.apache.felix.http.proxy.ProxyServlet requires that the BundleContext is defined on servlet initiation).
> 
> Everything seems to work, if I register servlets (in the OSGi container) to the path `/bundles/{servlet}`. That is — the OSGi component registering the Servlet *needs* to know to which context path the proxy servlet is mapped.
> 
> Is this by design, or did I miss some configuration setting or did I do something wrong in my setup?
> 
> The behaviour I was expecting was that when registering the servlet like this:
> 
> `httpService.registerServlet(“/demo”, theServlet, null, null);`
> 
> a call, through Tomcat, to `http://host:port/context/bundles/demo` <http://host:port/context/bundles/demo%60> would be dispatched to the `theServlet`.
> 
> If the component registering the Servlet needs to know the servlet-path of the proxy-servlet it’s really hard to make the servlet portable across different HttpService implementations :/
> 
> Best regards //Anders
> 


 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

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