简体   繁体   English

dosgi:找不到资源类的资源方法-忽略javax.ws.rs注释?

[英]dosgi: No resource methods have been found for resource class - javax.ws.rs annotation ignored?

i run in an exception showed below. 我在下面显示的异常中运行。 I tried to publish a webservie using annotation with dosgi. 我试图使用带dosgi的注释来发布Webservie。 But is looks like the annotations will be ignored. 但是看起来注释将被忽略。

When i use restProps.put("service.exported.configs", "org.apache.cxf. ws "); 当我使用restProps.put( “service.exported.configs”, “org.apache.cxf WS。”);

in my Activator.java Class without javax.ws.rs annotations, it works fine and i can request the wsdl (localhost:9090/provalet?wsdl). 在没有javax.ws.rs批注的Activator.java类中,它工作正常,我可以请求wsdl(localhost:9090 / provalet?wsdl)。

Here are some related threads, but non of these answers helped me: 以下是一些相关的主题,但是这些答案中的任何一个都没有帮助我:

"No resource methods" when using JAX-RS on TomEE+ -> in considered the "public" scope 在TomEE + -> 上使用JAX-RS时,“无资源方法”被认为是“公共”范围

CXF DOSGi is ignoring annotations http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-td4495048.html -> i have no bundle named "org.apache.servicemix.specs.jsr311-api-1.1" CXF DOSGi忽略了注释 http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-td4495048.html- >我没有名为“ org.apache.servicemix”的捆绑软件。 specs.jsr311-api-1.1“

i also developed this example http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/ -> but same exception 我也开发了这个示例http://maksim.sorokin.dk/it/2011/09/18/maven-apache-felix-cxf-dosgi-an-example-of-dosgi-service/- >但有相同的例外

I work with 我一起工作

  • List item 项目清单
  • apache felix 5.4.0 apache felix 5.4.0
  • Distributed OSGi Distribution Software Single-Bundle Distribution (1.2.0) 分布式OSGi分发软件单捆绑分发(1.2.0)
  • JAVA 1.8 JAVA 1.8

my bundles are: 我的捆绑包是:

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 my bundle provalet (1.0.0.SNAPSHOT)): Activator.java(我的包provalet(1.0.0.SNAPSHOT)中的OSGi Activator):

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: 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/remote-service/remote-service.xml: OSGI-INF / remote-service / 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>

Here is the part of my pom.xml responsable for generating the bundle 这是我pom.xml中负责生成捆绑包的部分

<plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>1.2.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>
                            de.fuBerlin.provalet,
                            de.fuBerlin.api
                        </Export-Package>
                        <Import-Package>
                            org.apache.cxf.dosgi.dsw.qos,
                            org.osgi.framework;version="1.5.0",
                            org.osgi.util.tracker;version="1.4.0",
                            ws.prova.api2;version="3.2.1",
                            ws.prova.exchange;version="3.2.1",
                            ws.prova.exchange.impl;version="3.2.1",
                            ws.prova.service;version="3.2.1",
                            javax.jws,
                            javax.ws.rs;version="[2.0,3)",
                            javax.ws.rs.core;version="[2.0,3)"
                        </Import-Package>
                        <Private-Package>

                        </Private-Package>
                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                        <Bundle-Activator>
                            de.fuBerlin.provalet.Activator
                        </Bundle-Activator>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>

Here is the exception: 这是例外:

application context:org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext@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: {addressing=org.apache.cxf.ws.policy.WSPolicyFeature@667a0762, logging=org.apache.cxf.feature.LoggingFeature@353563e5, SOAP=org.apache.cxf.binding.soap.SoapBindingConfiguration@171868d4, SOAP.1_1=org.apache.cxf.binding.soap.SoapBindingConfiguration@171868d4, SOAP.1_2=org.apache.cxf.binding.soap.SoapBindingConfiguration@59a950ae, 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.apache.cxf.dosgi.dsw.handlers.JaxRSPojoConfigurationTypeHandler@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

Assumption: I even think that is a problem with dependencies and it looks like the javax.ws.rs annotation will be ignored. 假设:我什至认为这是依赖关系的问题,看起来javax.ws.rs批注将被忽略。 Maybe i have a mistake with the bundle versions either. 也许我对捆绑软件版本有误。

Does someone know something more about this problem and how i can solve this? 有人对这个问题有更多的了解吗,我该如何解决呢? Please let me know, if you need more information. 如果您需要更多信息,请告诉我。

kind regards lars 亲切的问候

okay.. 好的..

a working targetplatform looks like this.. it was indeed a problem with dependencies. 正常工作的目标平台看起来像这样。确实是依赖关系的问题。

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)

kind regards and hope other user will work easier with that. 亲切的问候,并希望其他用户可以更轻松地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jax-rs apache-cxf:没有找到资源类的资源方法 - Jax-rs apache-cxf:No resource methods have been found for resource class JAVA-EE7 / javax.ws.rs:在REST资源中注入EJB - JAVA-EE7/javax.ws.rs: Injection of EJB in REST-Resource javax.ws.rs package - javax.ws.rs package NetBeans IDE 8.2 + Maven 3.0.5 + Java EE 8 +第一杯Java EE =未找到javax.ws.rs - NetBeans IDE 8.2 + Maven 3.0.5 + Java EE 8 + First Cup of Java EE = javax.ws.rs not found 使用javax.ws.rs表示法将扩展HttpServlet的类集成到项目中 - Integrate a class extending HttpServlet in a project using javax.ws.rs notations 如何使用javax.ws.rs执行输入验证? - How to perform input validation with javax.ws.rs? 找不到类:启动jboss时javax / ws / rs / container / AsyncResponse - Class not found: javax/ws/rs/container/AsyncResponse while starting jboss Apache CXF运行时JAX RS前端和&#39;javax.ws.rs&#39;(来自Oracle)之间的区别 - Difference between Apache CXF Runtime JAX RS Frontend and 'javax.ws.rs' (from Oracle) 如何使用javax.ws.rs将post端点放在请求体中数据传递的位置? - How make post endpoint where data pass in request body using javax.ws.rs? Maven - Restful web service - Jersey - 编译错误 - 包javax.ws.rs不存在 - Maven - Restful web service - Jersey - compilation error - package javax.ws.rs does not exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM