2016-04-26 14 views
0

Ich laufe in einer Ausnahme unten gezeigt. Ich habe versucht, einen Webservice mit Annotation mit Dosgi zu veröffentlichen. Aber es sieht so aus, als ob die Anmerkungen ignoriert werden.dosgi: Für die Ressourcenklasse wurden keine Ressourcenmethoden gefunden - javax.ws.rs Annotation ignoriert?

Wenn ich restProps.put ("service.exported.configs", "org.apache.cxf ws.");

in meiner Activator.java Klasse ohne javax.ws.rs Anmerkungen, es funktioniert gut und ich kann die WSDL (localhost: 9090/provalet? WSDL) anfordern.

Hier sind einige relevante Themen, aber nicht von dieser Antworten hat mir geholfen:

"No resource methods" when using JAX-RS on TomEE+ -> in die "Öffentlichkeit" scope betrachtet

CXF DOSGi is ignoring annotations http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-td4495048.html -> ich habe kein Bündel namens „org .apache.servicemix.specs.jsr311-api-1.1"

i entwickelte auch dieses Beispiel http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/ -> aber gleiche Ausnahme

Ich arbeite mit

  • Liste item
  • Apache felix 5.4.0
  • Distributed OSGi Verteilung Software Einzel-Bundle Verteilung (1.2.0)
  • JAVA 1,8

mein Bündel sind:

START LEVEL 1 
    ID|State  |Level|Name 
    0|Active  | 0|System Bundle (5.4.0) 
    1|Active  | 1|backport-util-concurrent (3.1.0) 
    2|Active  | 1|ANTLR Runtime (3.1.3) 
    3|Active  | 1|Apache Commons Bean Utilities (1.8.0) 
    4|Active  | 1|Apache Commons Collections (3.2.1) 
    5|Active  | 1|Apache Commons Logging (1.1.1) 
    6|Active  | 1|Apache Log4J (1.2.15) 
    7|Active  | 1|SLF4J API (1.5.10) 
    8|Resolved | 1|SLF4J Log4J Binding (1.5.10) 
    9|Active  | 1|Distributed OSGi Distribution Software Single-Bundle Distribution (1.2.0) 
    10|Active  | 1|javax.ws.rs-api (2.0.1) 
    11|Active  | 1|jaxb-api (2.2.7) 
    12|Active  | 1|Sesame 2.1.1 onejar. (2.1.1) 
    13|Active  | 1|Apache Felix Gogo Command (0.8.0) 
    14|Active  | 1|Apache Felix Gogo Runtime (0.8.0) 
    15|Active  | 1|Apache Felix Gogo Shell (0.8.0) 
    16|Active  | 1|osgi.cmpn (4.2.0.200908310645) 
    17|Active  | 1|provalet (1.0.0.SNAPSHOT) 
    18|Active  | 1|Metro Web Services API OSGi Bundle (2.1.0.b16) 
    19|Active  | 1|Prova compact (3.2.1) 

Activator.java (OSGi Activator in meinem Bündel provalet (1.0.0.SNAPSHOT)):

public void start(BundleContext arg0) throws Exception { 
    Activator.arg0 = arg0; 
    System.out.println("Start Provalet..."); 

    Dictionary<String, String> restProps = new Hashtable<String, String>(); 
    restProps.put("service.exported.interfaces", "*"); 
    restProps.put("service.exported.configs", "org.apache.cxf.rs"); 
    restProps.put("service.exported.intents", "HTTP"); 
    restProps.put("org.apache.cxf.rs.address", "http://localhost:9090/provalet"); 

    arg0.registerService(ProvaletService.class.getName(), 
             new ProvaletServiceImpl(), restProps); 
} 

ProvaletService.java:

import javax.jws.WebParam; 
import javax.jws.WebService; 
import javax.ws.rs.GET; 
import javax.ws.rs.Path; 
import javax.ws.rs.Produces; 
import javax.ws.rs.core.MediaType; 

@WebService 
public interface ProvaletService { 
    public String greetMe(@WebParam(name = "greeterName") String greeterName); 
    public String getMetaData(); 
    public String startTestProva(); 

    @GET 
    @Produces(MediaType.TEXT_PLAIN) 
    @Path("/sayhelo") 
    public String sayHello(); 
} 

OSGI-INF/Fernwartung/Remote-Service .xml:

<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> 
    <service-description> 
    <provide interface="de.fuBerlin.api.ProvaletService" /> 
    <property name="service.exported.interfaces">*</property> 
    <property name="service.exported.configs">org.apache.cxf.rs</property> 
    <property name="service.exported.intents">HTTP</property> 
    <property name="org.apache.cxf.rs.address">http://localhost:9090</property> 
    </service-description> 
</service-descriptions> 

Hier ist der Teil meiner pom.xml responsable zur Erzeugung des Bündels

Hier

ist die Ausnahme:

application context:org.sprin[email protected]4796c889: display name [OsgiBundleXmlApplicationContext(bundle=cxf-dosgi-ri-singlebundle-distribution, config=classpath:/OSGI-INF/cxf/intents/intent-map.xml)]; startup date [Tue Apr 26 10:18:40 CEST 2016]; root of context hierarchy 
    retrieved intent map: IntentMap: {[email protected], [email protected], [email protected]d4, [email protected]1868d4, [email protected]a950ae, HTTP=PROVIDED} 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore exportService 
    INFO: interfaces selected for export: [de.fuBerlin.api.ProvaletService] 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore exportService 
    INFO: configuration types selected for export: [org.apache.cxf.rs] 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore exportService 
    INFO: creating initial ExportDescription for interface de.fuBerlin.api.ProvaletService with configuration types [org.apache.cxf.rs] 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore exportService 
    INFO: creating server for interface de.fuBerlin.api.ProvaletService 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore exportService 
    INFO: found handler for de.fuBerlin.api.ProvaletService -> org.[email protected]4c6b2597 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.dosgi.dsw.handlers.JaxRSPojoConfigurationTypeHandler createServer 
    INFO: Creating a de.fuBerlin.api.ProvaletService endpoint via JaxRSPojoConfigurationTypeHandler, address is http://localhost:9090/provalet 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher 
    WARNING: No resource methods have been found for resource class de.fuBerlin.api.ProvaletService 
    Apr 26, 2016 10:18:40 AM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean checkResources 
    SEVERE: No resource classes found 
    Exception in thread "pool-6-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.runWorker(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
    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 

Annahme: Ich selbst denke, dass ein Problem mit Abhängigkeiten und es sieht aus wie die javax.ws.rs Anmerkung ignoriert wird. Vielleicht habe ich auch einen Fehler mit den Bundle-Versionen.

Weiß jemand etwas mehr über dieses Problem und wie ich das lösen kann? Bitte lassen Sie mich wissen, wenn Sie weitere Informationen benötigen.

freundlichen Grüßen lars

Antwort

2

okay ..

ein Arbeits targetplatform wie folgt aussieht .. es in der Tat ein Problem mit Abhängigkeiten war.

START LEVEL 1 
    ID|State  |Level|Name 
    0|Active  | 0|System Bundle (5.4.0) 
    1|Active  | 1|backport-util-concurrent (3.1.0) 
    2|Active  | 1|ANTLR Runtime (3.1.3) 
    3|Active  | 1|Apache Commons Bean Utilities (1.8.0) 
    4|Active  | 1|Apache Commons Collections (3.2.1) 
    5|Active  | 1|Apache Commons Logging (1.1.1) 
    6|Active  | 1|Apache Log4J (1.2.15) 
    7|Active  | 1|SLF4J API (1.5.10) 
    8|Resolved | 1|SLF4J Log4J Binding (1.5.10) 
    9|Active  | 1|Distributed OSGi Distribution Software Single-Bundle Distribution (1.2.0) 
    10|Active  | 1|jaxb-api (2.2.7) 
    11|Active  | 1|Sesame 2.1.1 onejar. (2.1.1) 
    12|Active  | 1|Apache Felix Gogo Command (0.8.0) 
    13|Active  | 1|Apache Felix Gogo Runtime (0.8.0) 
    14|Active  | 1|Apache Felix Gogo Shell (0.8.0) 
    15|Active  | 1|Apache ServiceMix :: Specs :: JSR-311 API 1.0 (2.7.0) 
    16|Active  | 1|osgi.cmpn (4.2.0.200908310645) 
    17|Active  | 1|provalet (1.0.0.SNAPSHOT) 
    18|Active  | 1|Metro Web Services API OSGi Bundle (2.1.0.b16) 
    19|Active  | 1|Prova compact (3.2.1) 

mit freundlichen Grüßen und hoffe, andere Benutzer werden damit leichter arbeiten.