You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by "marius.giepz@t-online.de" <ma...@t-online.de> on 2012/05/11 16:06:42 UTC

JAX-RS/SLING-RS Sample with Sling/Karaf

Hi! 

	I am trying to bring some legacy jax-rs classes into my sling
installation. 
 I deployed org.apache.sling.extensions.jaxrs into Sling and
everything seems to be working nicely.
 When Sling is running in Karaf only the sling-rs resources are
workin, the jax-rs are not.
 To narrow down the problem I deployed the  "JAX-RS/SLING-RS Sample"
into a clean standalone Sling
 and into one running within Karaf. 
 The installation looks the same in both cases

 Sling:
 *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
BundleEvent INSTALLED
 *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
BundleEvent RESOLVED
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.wink.server.internal.application.ApplicationProcessor The 
following JAX-RS application has been processed: 
org.apache.wink.server.utils.RegistrationUtils$InnerApplication
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.sling.jaxrs.wink.WinkRequestProcessor registered component 
org.apache.sling.jaxrs.sample.GreetingWriter@723bfc52
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.sling.extensions.jaxrs.sample Service 
[org.apache.sling.jaxrs.sample.GreetingWriter,161] ServiceEvent 
REGISTERED
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.wink.server.internal.application.ApplicationProcessor The 
following JAX-RS application has been processed: 
org.apache.wink.server.utils.RegistrationUtils$InnerApplication
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.sling.jaxrs.wink.WinkRequestProcessor registered component 
org.apache.sling.jaxrs.sample.SimpleRootResource@15ec68e9
 *INFO* [Background Install 
C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp] 
org.apache.sling.extensions.jaxrs.sample Service 
[org.apache.sling.jaxrs.sample.SimpleRootResource,162] ServiceEvent 
REGISTERED
 *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
BundleEvent STARTED

 Sling in Karaf:
 | INFO  | lixDispatchQueue | sample                           | 119 -
 org.apache.sling.commons.log - 2.1.2 | BundleEvent INSTALLED
 | INFO  | lixDispatchQueue | sample                           | 119 -
 org.apache.sling.commons.log - 2.1.2 | BundleEvent RESOLVED
 | INFO  | 423708686658.tmp | ApplicationProcessor             | 145 -
 org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | The following 
JAX-RS application has been processed: 
org.apache.wink.server.utils.RegistrationUtils$InnerApplication
 | INFO  | 423708686658.tmp | WinkRequestProcessor             | 145 -
 org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | registered 
component org.apache.sling.jaxrs.sample.GreetingWriter@25f71a09
 | INFO  | 423708686658.tmp | sample                           | 119 -
 org.apache.sling.commons.log - 2.1.2 | Service 
[org.apache.sling.jaxrs.sample.GreetingWriter,348] ServiceEvent 
REGISTERED
 | INFO  | 423708686658.tmp | ApplicationProcessor             | 145 -
 org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | The following 
JAX-RS application has been processed: 
org.apache.wink.server.utils.RegistrationUtils$InnerApplication
 | INFO  | 423708686658.tmp | WinkRequestProcessor             | 145 -
 org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | registered 
component org.apache.sling.jaxrs.sample.SimpleRootResource@5d6227a2
 | INFO  | 423708686658.tmp | sample                           | 119 -
 org.apache.sling.commons.log - 2.1.2 | Service 
[org.apache.sling.jaxrs.sample.SimpleRootResource,349] ServiceEvent 
REGISTERED
 | INFO  | lixDispatchQueue | sample                           | 119 -
org.apache.sling.commons.log - 2.1.2 | BundleEvent STARTED

 Result in Sling standalone: 

 http://localhost:8080/testing/jaxrs/SimpleRootResource -> works 

 Result in Sling/Karaf: 

 http://localhost:8181/testing/jaxrs/SimpleRootResource -> does not
work and logs
 | INFO  | esource HTTP/1.1 | SlingRequestProcessorImpl        | 93 - 
org.apache.sling.engine - 2.2.2 | service: Resource 
/testing/jaxrs/SimpleRootResource not found

 Any idea what would need to be configured differently to get it
running with Sling/Karaf?

 regards,

 Marius

Re: JAX-RS/SLING-RS Sample with Sling/Karaf

Posted by Reto Bachmann-Gmür <me...@farewellutopia.com>.
On Tue, May 22, 2012 at 12:40 AM, Marius Giepz <ma...@t-online.de>wrote:

> Thanks for your suggestions, Reto!
>
> Am 16.05.2012 16:15, schrieb Reto Bachmann-Gmür:
>
>
>  As far as I know the mechanism by which the servlet filter is registered
>> is
>> supported only by the felix http service. The servlet filter is just
>> registered as a service and annotated with some properties. So I guess
>> that
>> a different http-service being used is the reason things don't work in
>> your
>> karaf setting.
>>
> You are right in so far as sling-standalone uses
> org.apache.felix.http.jetty to provide
> org.osgi.service.http.**HttpService whereas karaf uses
> org.ops4j.pax.web.pax-web-**runtime.
> I would support you assumption if i didnt have the case where it works
> with sling 2.0.6 and
> Karaf 2.2.7 (which has the pax-web httpservice)
>
I'm wondering what works with the pax-web httpservice. Sling-rs resources
should work independently of the the servlet-filter registration mechanism.
Jax-rs resources will only work if the filter is registered with the
http-service.

Cheers,
Reto

Re: JAX-RS/SLING-RS Sample with Sling/Karaf

Posted by Marius Giepz <ma...@t-online.de>.
Thanks for your suggestions, Reto!

Am 16.05.2012 16:15, schrieb Reto Bachmann-Gmür:

> As far as I know the mechanism by which the servlet filter is registered is
> supported only by the felix http service. The servlet filter is just
> registered as a service and annotated with some properties. So I guess that
> a different http-service being used is the reason things don't work in your
> karaf setting.
You are right in so far as sling-standalone uses 
org.apache.felix.http.jetty to provide
org.osgi.service.http.HttpService whereas karaf uses 
org.ops4j.pax.web.pax-web-runtime.
I would support you assumption if i didnt have the case where it works 
with sling 2.0.6 and
Karaf 2.2.7 (which has the pax-web httpservice)

kind regards,

Marius

Re: JAX-RS/SLING-RS Sample with Sling/Karaf

Posted by Reto Bachmann-Gmür <re...@apache.org>.
Hi again,

processing my mail in inverse cronological order and realizing that the
previous post might not have been very helpfull as you already have the
example running in a non-karaf environment.

As far as I know the mechanism by which the servlet filter is registered is
supported only by the felix http service. The servlet filter is just
registered as a service and annotated with some properties. So I guess that
a different http-service being used is the reason things don't work in your
karaf setting.

You could try the wink-osgi bundle which supports jax-rs but no sling-rs
resources, presumably it doesn't work as the filter is registererd with the
same mechanism. A usage example is here:
http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/OSGi/

Cheers,
Reto

On Fri, May 11, 2012 at 4:06 PM, marius.giepz@t-online.de <
marius.giepz@t-online.de> wrote:

> Hi!
>
>        I am trying to bring some legacy jax-rs classes into my sling
> installation.
>  I deployed org.apache.sling.extensions.jaxrs into Sling and
> everything seems to be working nicely.
>  When Sling is running in Karaf only the sling-rs resources are
> workin, the jax-rs are not.
>  To narrow down the problem I deployed the  "JAX-RS/SLING-RS Sample"
> into a clean standalone Sling
>  and into one running within Karaf.
>  The installation looks the same in both cases
>
>  Sling:
>  *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
> BundleEvent INSTALLED
>  *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
> BundleEvent RESOLVED
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.wink.server.internal.application.ApplicationProcessor The
> following JAX-RS application has been processed:
> org.apache.wink.server.utils.RegistrationUtils$InnerApplication
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.sling.jaxrs.wink.WinkRequestProcessor registered component
> org.apache.sling.jaxrs.sample.GreetingWriter@723bfc52
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.sling.extensions.jaxrs.sample Service
> [org.apache.sling.jaxrs.sample.GreetingWriter,161] ServiceEvent
> REGISTERED
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.wink.server.internal.application.ApplicationProcessor The
> following JAX-RS application has been processed:
> org.apache.wink.server.utils.RegistrationUtils$InnerApplication
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.sling.jaxrs.wink.WinkRequestProcessor registered component
> org.apache.sling.jaxrs.sample.SimpleRootResource@15ec68e9
>  *INFO* [Background Install
> C:UsersmgAppDataLocalTempinstall3717890895037484530.tmp]
> org.apache.sling.extensions.jaxrs.sample Service
> [org.apache.sling.jaxrs.sample.SimpleRootResource,162] ServiceEvent
> REGISTERED
>  *INFO* [FelixDispatchQueue] org.apache.sling.extensions.jaxrs.sample
> BundleEvent STARTED
>
>  Sling in Karaf:
>  | INFO  | lixDispatchQueue | sample                           | 119 -
>  org.apache.sling.commons.log - 2.1.2 | BundleEvent INSTALLED
>  | INFO  | lixDispatchQueue | sample                           | 119 -
>  org.apache.sling.commons.log - 2.1.2 | BundleEvent RESOLVED
>  | INFO  | 423708686658.tmp | ApplicationProcessor             | 145 -
>  org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | The following
> JAX-RS application has been processed:
> org.apache.wink.server.utils.RegistrationUtils$InnerApplication
>  | INFO  | 423708686658.tmp | WinkRequestProcessor             | 145 -
>  org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | registered
> component org.apache.sling.jaxrs.sample.GreetingWriter@25f71a09
>  | INFO  | 423708686658.tmp | sample                           | 119 -
>  org.apache.sling.commons.log - 2.1.2 | Service
> [org.apache.sling.jaxrs.sample.GreetingWriter,348] ServiceEvent
> REGISTERED
>  | INFO  | 423708686658.tmp | ApplicationProcessor             | 145 -
>  org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | The following
> JAX-RS application has been processed:
> org.apache.wink.server.utils.RegistrationUtils$InnerApplication
>  | INFO  | 423708686658.tmp | WinkRequestProcessor             | 145 -
>  org.apache.sling.extensions.jaxrs - 0.9.9.SNAPSHOT | registered
> component org.apache.sling.jaxrs.sample.SimpleRootResource@5d6227a2
>  | INFO  | 423708686658.tmp | sample                           | 119 -
>  org.apache.sling.commons.log - 2.1.2 | Service
> [org.apache.sling.jaxrs.sample.SimpleRootResource,349] ServiceEvent
> REGISTERED
>  | INFO  | lixDispatchQueue | sample                           | 119 -
> org.apache.sling.commons.log - 2.1.2 | BundleEvent STARTED
>
>  Result in Sling standalone:
>
>  http://localhost:8080/testing/jaxrs/SimpleRootResource -> works
>
>  Result in Sling/Karaf:
>
>  http://localhost:8181/testing/jaxrs/SimpleRootResource -> does not
> work and logs
>  | INFO  | esource HTTP/1.1 | SlingRequestProcessorImpl        | 93 -
> org.apache.sling.engine - 2.2.2 | service: Resource
> /testing/jaxrs/SimpleRootResource not found
>
>  Any idea what would need to be configured differently to get it
> running with Sling/Karaf?
>
>  regards,
>
>  Marius