You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by mah <ms...@3dfacto.com> on 2011/06/16 15:23:30 UTC

CXF DOSGi is ignoring JAX-RS annotations?

I am using an CXF DOSGi JAX-RS example
(http://svn.apache.org/repos/asf/cxf/dosgi/trunk/samples/greeter_rest/).
This example contains two RESTful webservices, one with annotations and
another without.

I build it with maven and deploy it into Felix, together with CXF DOSGi
single bundle distribution. The one without annotations works fine, however
the other with annotations seems to be ignored at all. I get the following
message in the log:



WARNING: No resource methods have been found for resource class
org.apache.cxf.dosgi.samples.greeter.rest.GreeterService
Jun 15, 2011 10:34:17 PM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
checkResources
SEVERE: No resource classes found
Exception in thread "pool-1-thread-1"
org.apache.cxf.service.factory.ServiceConstructionException
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:122)
        at
org.apache.cxf.dosgi.dsw.handlers.JaxRSPojoConfigurationTypeHandler.createServer(JaxRSPojoConfigurationTypeHandler.java:135)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore.exportService(RemoteServiceAdminCore.java:244)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:78)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:71)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:71)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:40)
        at
org.apache.cxf.dosgi.topologymanager.TopologyManager$2.run(TopologyManager.java:254)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.ws.rs.WebApplicationException
        at
org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:238)
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:85)
        ... 11 more



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4495048.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAXRS OSGI

Posted by Sergey Beryozkin <sb...@gmail.com>.
np, there's a bit of confusion.

In this thread a user asked why JAX-RS service classes were not
visible (were not possible to load) inside a webapp bundle context.
Nothing to do with DOSGi.
In you similarly named thread you asked why JAX-RS annotated resources
were not recognized (as opposed to the case where an external user
model was used). I believe such issues are always caused by missing
imports and suggested to check the way DOSGi greeter_rest demo does
it, because it also has interface and impl bundles...Have a look at
that demo and see if you can make your own application work

Cheers, Sergey

On Thu, Jun 23, 2011 at 8:20 AM, mah <ms...@3dfacto.com> wrote:
>
> Sergey Beryozkin-5 wrote:
>>
>> Can you please reply in the relevant thread :-) There should be
>> another one related to CXF JAX-RS in DOSGi...
>>
>
> No, it is precisely the one =)
> Initial problem is that JAX-RS annotations were not processed. Yesterday you
> wrote, about 'webapp' bundle deployment and that it worked fine. Therefore I
> was confused, whereas I am correctly launching Felix with CXF DOSGi.
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4516571.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: CXF JAXRS OSGI

Posted by mah <ms...@3dfacto.com>.
Sergey Beryozkin-5 wrote:
> 
> Can you please reply in the relevant thread :-) There should be
> another one related to CXF JAX-RS in DOSGi...
> 

No, it is precisely the one =)
Initial problem is that JAX-RS annotations were not processed. Yesterday you
wrote, about 'webapp' bundle deployment and that it worked fine. Therefore I
was confused, whereas I am correctly launching Felix with CXF DOSGi.


--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4516571.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAXRS OSGI

Posted by Sergey Beryozkin <sb...@gmail.com>.
Can you please reply in the relevant thread :-) There should be
another one related to CXF JAX-RS in DOSGi...

thanks, Sergey

On Wed, Jun 22, 2011 at 9:58 PM, mah <ms...@3dfacto.com> wrote:
>
> Sergey Beryozkin-5 wrote:
>>
>> Did you get this issue resolved ?
>>
>
> No, not yet.
>
>
> Sergey Beryozkin-5 wrote:
>>
>> I actually did a 'webapp' bundle deployment a few days ago, and it
>> worked fine in the end, the webapp bundle had only web.xml & beans.xml
>> (which you don't need for non-Spring case), CXF bundle and application
>> service bundle were loaded before...
>>
>
> I am a bit confused here. The way I do deployment is directly through
> felix.jar. That is, I launch Felix with cxf dosgi bundles:
>>> java -jar bin\felix.jar
>
> And load interface and implementation packages (or just specify in
> felix.auto.start):
>>> start file:cxf-dosgi-ri-samples-greeter-rest-interface-1.3-SNAPSHOT.jar
>>> start file:cxf-dosgi-ri-samples-greeter-rest-impl-1.3-SNAPSHOT.jar
>
> Is that incorrect?
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4515462.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Re: CXF JAXRS OSGI

Posted by mah <ms...@3dfacto.com>.
Sergey Beryozkin-5 wrote:
> 
> Did you get this issue resolved ?
> 

No, not yet.


Sergey Beryozkin-5 wrote:
> 
> I actually did a 'webapp' bundle deployment a few days ago, and it
> worked fine in the end, the webapp bundle had only web.xml & beans.xml
> (which you don't need for non-Spring case), CXF bundle and application
> service bundle were loaded before...
> 

I am a bit confused here. The way I do deployment is directly through
felix.jar. That is, I launch Felix with cxf dosgi bundles:
>> java -jar bin\felix.jar

And load interface and implementation packages (or just specify in
felix.auto.start):
>> start file:cxf-dosgi-ri-samples-greeter-rest-interface-1.3-SNAPSHOT.jar
>> start file:cxf-dosgi-ri-samples-greeter-rest-impl-1.3-SNAPSHOT.jar

Is that incorrect?

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4515462.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAXRS OSGI

Posted by Sergey Beryozkin <sb...@gmail.com>.
Did you get this issue resolved ?

I actually did a 'webapp' bundle deployment a few days ago, and it
worked fine in the end, the webapp bundle had only web.xml & beans.xml
(which you don't need for non-Spring case), CXF bundle and application
service bundle were loaded before...I used Require-Bundle instruction
to effectively import application service bundle a more preferred
Import-Package should do well too

Cheers, Sergey



On Fri, Jun 17, 2011 at 6:02 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> On Fri, Jun 17, 2011 at 2:30 PM, Muller, Anthony <an...@sap.com> wrote:
>> Hello,
>>
>> I put CXF 2.3.3 in an osgi bundle and I'm trying to use it from other "webapp" bundles.
>>
>> I'm using JAXRS to expose a REST webservice. It is configured thanks to CXFNonSpringJaxrsServlet. I define "jaxrs.serviceClasses" servlet param in the web.xml.
>>
>> My problem: at startup, CXF tries to load the service class and it failed (due to classloader isolation).
>>
>> How can I proceed to fix that? Is DOSGI the only alternative if I wish to share CXF between several "webapp" bundles?
>>
> Does your webabb bundle have Import-Package with a service class package ?
>
>
> Cheers, Sergey
>
>> Cheers,
>> Anthony
>>
>

Re: CXF JAXRS OSGI

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Fri, Jun 17, 2011 at 2:30 PM, Muller, Anthony <an...@sap.com> wrote:
> Hello,
>
> I put CXF 2.3.3 in an osgi bundle and I'm trying to use it from other "webapp" bundles.
>
> I'm using JAXRS to expose a REST webservice. It is configured thanks to CXFNonSpringJaxrsServlet. I define "jaxrs.serviceClasses" servlet param in the web.xml.
>
> My problem: at startup, CXF tries to load the service class and it failed (due to classloader isolation).
>
> How can I proceed to fix that? Is DOSGI the only alternative if I wish to share CXF between several "webapp" bundles?
>
Does your webabb bundle have Import-Package with a service class package ?


Cheers, Sergey

> Cheers,
> Anthony
>

CXF JAXRS OSGI

Posted by "Muller, Anthony" <an...@sap.com>.
Hello,

I put CXF 2.3.3 in an osgi bundle and I'm trying to use it from other "webapp" bundles.

I'm using JAXRS to expose a REST webservice. It is configured thanks to CXFNonSpringJaxrsServlet. I define "jaxrs.serviceClasses" servlet param in the web.xml.

My problem: at startup, CXF tries to load the service class and it failed (due to classloader isolation).

How can I proceed to fix that? Is DOSGI the only alternative if I wish to share CXF between several "webapp" bundles?

Cheers,
Anthony

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Sorry - DOSGi 1.2 depends on CXF 2.2.x thus obviously JAX-RS 1.1 spec
bundle  affects it, we have a good patch submitted, will deal with it
shortly, CXF 2.4.1 dep will be introduced as well as JAX-RS 1.1.1 spec
bundle

Sergey

On Fri, Jun 24, 2011 at 9:10 AM, mah <ms...@3dfacto.com> wrote:
>
> Sergey Beryozkin-5 wrote:
>>
>> I'm wondering if adding Dynamic-Import [1] broke it ?
>>
>> Well, actually, how does it work without the service mix spec bundle ?
>> Unless you are using Jersey ? That may work with the multibundle
>> distribution, though really not sure
>>
>
> I see some Dynamic-Imports in impl bundle.
>
> I think I cannot answer/elaborate on your other questions. But if you want,
> I can provide some details about my setup.
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4520258.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by mah <ms...@3dfacto.com>.
Sergey Beryozkin-5 wrote:
> 
> I'm wondering if adding Dynamic-Import [1] broke it ?
> 
> Well, actually, how does it work without the service mix spec bundle ?
> Unless you are using Jersey ? That may work with the multibundle
> distribution, though really not sure
> 

I see some Dynamic-Imports in impl bundle.

I think I cannot answer/elaborate on your other questions. But if you want,
I can provide some details about my setup.

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4520258.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hmm...
I'm wondering if adding Dynamic-Import [1] broke it ?

Well, actually, how does it work without the service mix spec bundle ?
Unless you are using Jersey ? That may work with the multibundle
distribution, though really not sure

thanks, Sergey

[1] https://issues.apache.org/jira/browse/SMX4-358



On Thu, Jun 23, 2011 at 8:24 PM, mah <ms...@3dfacto.com> wrote:
> I found the problem. I had "org.apache.servicemix.specs.jsr311-api-1.1" in my
> bundles. When I removed it, annotations were processed.
>
> Sorry for disturbance.
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4518735.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by mah <ms...@3dfacto.com>.
I found the problem. I had "org.apache.servicemix.specs.jsr311-api-1.1" in my
bundles. When I removed it, annotations were processed.

Sorry for disturbance.

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4518735.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by mah <ms...@3dfacto.com>.
Sergey Beryozkin-5 wrote:
> 
> It is exactly the same way greeter_rest demo is done, can you please
> check the way interface and impl bundle export and import packages ?
> 

Sorry Sergey, maybe I was not very explicit. But that actually was
greeter_rest demo.

I checked it out (from
http://svn.apache.org/repos/asf/cxf/dosgi/trunk/samples/greeter_rest/),
built with maven.

I have started Felix with CFX DOSGi distribution and started interface and
impl bundles. For webservice with annotations I see the following error in
the log:
<code>
INFO: Creating a org.apache.cxf.dosgi.samples.greeter.rest.GreeterService
endpoint via JaxRSPojoConfigurationTypeHa
ndler, address is http://localhost:9090/greeter
Jun 23, 2011 8:01:26 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
WARNING: No resource methods have been found for resource class
org.apache.cxf.dosgi.samples.greeter.rest.GreeterSe
rvice
Jun 23, 2011 8:01:26 PM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
checkResources
SEVERE: No resource classes found
Exception in thread "pool-1-thread-1"
org.apache.cxf.service.factory.ServiceConstructionException
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:122)
        at
org.apache.cxf.dosgi.dsw.handlers.JaxRSPojoConfigurationTypeHandler.createServer(JaxRSPojoConfigurationT
ypeHandler.java:135)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore.exportService(RemoteServiceAdminCore.java:244)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:78)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:71)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.jav
a:71)
        at
org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.jav
a:40)
        at
org.apache.cxf.dosgi.topologymanager.TopologyManager$2.run(TopologyManager.java:254)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.ws.rs.WebApplicationException
        at
org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:238)
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:85)
        ... 11 more
Jun 23, 2011 8:01:27 PM
org.apache.cxf.dosgi.topologymanager.TopologyManager$2 run
</code>

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4518386.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by Sergey Beryozkin <sb...@gmail.com>.
It is exactly the same way greeter_rest demo is done, can you please
check the way interface and impl bundle export and import packages ?

Cheers, Sergey

On Sun, Jun 19, 2011 at 10:48 AM, mah <ms...@3dfacto.com> wrote:
>
> Sergey Beryozkin-5 wrote:
>>
>> I think it's a matter of explicitly importing javax.ws.rs package with
>> ImportPackage for the case where annotations are expected to be
>> recognized
>>
>
> javax.ws.rs package is imported into bundle, where annotations are expected
> to be processed.
>
> The setup consists of two bundles. One defines the interface and supposed to
> expose REST webservice using annotations. Here is the interface itself
> (other classes used are plain Java classes):
>
> package org.apache.cxf.dosgi.samples.greeter.rest;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
>
> @Path("greeter")
> public interface GreeterService {
>
>        @GET
>        @Path("greeting/{name}")
>    GreeterInfo greetMe(@PathParam("name") String name) throws
> GreeterException;
>
> }
>
>
> The generated MANIFEST.MF for interface bundle looks like this:
>
> Manifest-Version: 1.0
> Export-Package: org.apache.cxf.dosgi.samples.greeter.rest;uses:="javax
>  .ws.rs"
> Built-By: mah
> Tool: Bnd-0.0.238
> Bundle-Name: CXF Distributed OSGi Greeter Rest Demo Interface Bundle
> Created-By: Apache Maven Bundle Plugin
> Bundle-Vendor: The Apache Software Foundation
> Build-Jdk: 1.6.0_21
> Bundle-Version: 1.3.0.SNAPSHOT
> Bnd-LastModified: 1308169970661
> Bundle-ManifestVersion: 2
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
> Bundle-Description: This bundle contains the implementation of the CXF
>  Distributed OSGi Greeter Rest Demo Interfaces
> Bundle-DocURL: http://www.apache.org/
> Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-interface
> Import-Package: javax.ws.rs;version="1.0",org.apache.cxf.dosgi.samples
>  .greeter.rest
>
>
> The interface implementation is in a separate bundle. Interface
> implementation class is plain Java class. The activator for implementation
> bundle looks like this:
>
> package org.apache.cxf.dosgi.samples.greeter.impl.rest;
>
> import java.util.Dictionary;
> import java.util.Hashtable;
>
> import org.apache.cxf.dosgi.samples.greeter.rest.GreeterService;
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.ServiceRegistration;
>
> public class Activator implements BundleActivator {
>    private ServiceRegistration registration;
>
>    public void start(BundleContext bc) throws Exception {
>        Dictionary props = getProperties("http://localhost:9090/greeter");
>        registration = bc.registerService(GreeterService.class.getName(),
>                                          new GreeterServiceImpl(), props);
>    }
>
>    @SuppressWarnings("unchecked")
>        private Dictionary getProperties(String address) {
>        Dictionary props = new Hashtable();
>
>        props.put("service.exported.interfaces", "*");
>        props.put("service.exported.configs", "org.apache.cxf.rs");
>        props.put("service.exported.intents", "HTTP");
>        props.put("org.apache.cxf.rs.address", address);
>        props.put("org.apache.cxf.rs.databinding", "aegis");
>        return props;
>    }
>
>    public void stop(BundleContext bc) throws Exception {
>        registration.unregister();
>    }
> }
>
>
> And MANIFEST.MF for implentation bundle:
>
> Manifest-Version: 1.0
> Private-Package: org.apache.cxf.dosgi.samples.greeter.impl.rest
> Built-By: mah
> Tool: Bnd-0.0.238
> Bundle-Name: CXF Distributed OSGi Greeter Demo Service Rest Implementa
>  tion Bundle
> Created-By: Apache Maven Bundle Plugin
> Bundle-Vendor: The Apache Software Foundation
> DynamicImport-Package: org.apache.cxf.dosgi.dsw.qos,org.apache.cxf
> Build-Jdk: 1.6.0_21
> Bundle-Version: 1.3.0.SNAPSHOT
> Bnd-LastModified: 1308476484718
> Bundle-Activator: org.apache.cxf.dosgi.samples.greeter.impl.rest.Activ
>  ator
> Bundle-ManifestVersion: 2
> Bundle-Description: This bundle contains the implementation of the CXF
>  Distributed OSGi Greeter Rest Demo Implementation Bundle
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
> Bundle-DocURL: http://www.apache.org/
> Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-impl
> Import-Package: org.apache.cxf.dosgi.samples.greeter.rest,org.osgi.fra
>  mework;version="1.4"
>
>
> Could that be a problem of CXF single distribution? I am using 1.3-SNAPSHOT.
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4503099.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by mah <ms...@3dfacto.com>.
Sergey Beryozkin-5 wrote:
> 
> I think it's a matter of explicitly importing javax.ws.rs package with
> ImportPackage for the case where annotations are expected to be
> recognized
> 

javax.ws.rs package is imported into bundle, where annotations are expected
to be processed.

The setup consists of two bundles. One defines the interface and supposed to
expose REST webservice using annotations. Here is the interface itself
(other classes used are plain Java classes):

package org.apache.cxf.dosgi.samples.greeter.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

@Path("greeter")
public interface GreeterService {

	@GET
	@Path("greeting/{name}")
    GreeterInfo greetMe(@PathParam("name") String name) throws
GreeterException;

}


The generated MANIFEST.MF for interface bundle looks like this:

Manifest-Version: 1.0
Export-Package: org.apache.cxf.dosgi.samples.greeter.rest;uses:="javax
 .ws.rs"
Built-By: mah
Tool: Bnd-0.0.238
Bundle-Name: CXF Distributed OSGi Greeter Rest Demo Interface Bundle
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: The Apache Software Foundation
Build-Jdk: 1.6.0_21
Bundle-Version: 1.3.0.SNAPSHOT
Bnd-LastModified: 1308169970661
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: This bundle contains the implementation of the CXF
  Distributed OSGi Greeter Rest Demo Interfaces
Bundle-DocURL: http://www.apache.org/
Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-interface
Import-Package: javax.ws.rs;version="1.0",org.apache.cxf.dosgi.samples
 .greeter.rest


The interface implementation is in a separate bundle. Interface
implementation class is plain Java class. The activator for implementation
bundle looks like this:

package org.apache.cxf.dosgi.samples.greeter.impl.rest;

import java.util.Dictionary;
import java.util.Hashtable;

import org.apache.cxf.dosgi.samples.greeter.rest.GreeterService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

public class Activator implements BundleActivator {
    private ServiceRegistration registration;

    public void start(BundleContext bc) throws Exception {
        Dictionary props = getProperties("http://localhost:9090/greeter");
        registration = bc.registerService(GreeterService.class.getName(), 
                                          new GreeterServiceImpl(), props);
    }

    @SuppressWarnings("unchecked")
	private Dictionary getProperties(String address) { 
    	Dictionary props = new Hashtable();

        props.put("service.exported.interfaces", "*");
        props.put("service.exported.configs", "org.apache.cxf.rs");
        props.put("service.exported.intents", "HTTP");
        props.put("org.apache.cxf.rs.address", address);
        props.put("org.apache.cxf.rs.databinding", "aegis");
        return props;
    }
    
    public void stop(BundleContext bc) throws Exception {
        registration.unregister();
    }
}


And MANIFEST.MF for implentation bundle:

Manifest-Version: 1.0
Private-Package: org.apache.cxf.dosgi.samples.greeter.impl.rest
Built-By: mah
Tool: Bnd-0.0.238
Bundle-Name: CXF Distributed OSGi Greeter Demo Service Rest Implementa
 tion Bundle
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: The Apache Software Foundation
DynamicImport-Package: org.apache.cxf.dosgi.dsw.qos,org.apache.cxf
Build-Jdk: 1.6.0_21
Bundle-Version: 1.3.0.SNAPSHOT
Bnd-LastModified: 1308476484718
Bundle-Activator: org.apache.cxf.dosgi.samples.greeter.impl.rest.Activ
 ator
Bundle-ManifestVersion: 2
Bundle-Description: This bundle contains the implementation of the CXF
  Distributed OSGi Greeter Rest Demo Implementation Bundle
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-DocURL: http://www.apache.org/
Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-impl
Import-Package: org.apache.cxf.dosgi.samples.greeter.rest,org.osgi.fra
 mework;version="1.4"


Could that be a problem of CXF single distribution? I am using 1.3-SNAPSHOT.


--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4503099.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF DOSGi is ignoring JAX-RS annotations?

Posted by Sergey Beryozkin <sb...@gmail.com>.
I think it's a matter of explicitly importing javax.ws.rs package with
ImportPackage for the case where annotations are expected to be
recognized

Cheers, Sergey

On Thu, Jun 16, 2011 at 2:23 PM, mah <ms...@3dfacto.com> wrote:
> I am using an CXF DOSGi JAX-RS example
> (http://svn.apache.org/repos/asf/cxf/dosgi/trunk/samples/greeter_rest/).
> This example contains two RESTful webservices, one with annotations and
> another without.
>
> I build it with maven and deploy it into Felix, together with CXF DOSGi
> single bundle distribution. The one without annotations works fine, however
> the other with annotations seems to be ignored at all. I get the following
> message in the log:
>
>
>
> WARNING: No resource methods have been found for resource class
> org.apache.cxf.dosgi.samples.greeter.rest.GreeterService
> Jun 15, 2011 10:34:17 PM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
> checkResources
> SEVERE: No resource classes found
> Exception in thread "pool-1-thread-1"
> org.apache.cxf.service.factory.ServiceConstructionException
>        at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:122)
>        at
> org.apache.cxf.dosgi.dsw.handlers.JaxRSPojoConfigurationTypeHandler.createServer(JaxRSPojoConfigurationTypeHandler.java:135)
>        at
> org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore.exportService(RemoteServiceAdminCore.java:244)
>        at
> org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:78)
>        at
> org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:71)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at
> org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:71)
>        at
> org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:40)
>        at
> org.apache.cxf.dosgi.topologymanager.TopologyManager$2.run(TopologyManager.java:254)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
>        at java.lang.Thread.run(Unknown Source)
> Caused by: javax.ws.rs.WebApplicationException
>        at
> org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:238)
>        at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:85)
>        ... 11 more
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4495048.html
> Sent from the cxf-user mailing list archive at Nabble.com.



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com