2012-06-30 11 views
7

Korzystanie z zapasów TomEE +, nie mogę uzyskać prostego zasobu JAX-RS do pracy. Ciągle pojawia się błąd:"Brak metod zasobów" podczas używania JAX-RS na TomEE +

Jun 30, 2012 5:09:59 PM org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher 
WARNING: No resource methods have been found for resource class com.tensorwrench.test.BaseResource 
Jun 30, 2012 5:09:59 PM org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher 
WARNING: No resource methods have been found for resource class com.tensorwrench.test.BaseResource 
Jun 30, 2012 5:09:59 PM org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher 
WARNING: No resource methods have been found for resource class com.tensorwrench.test.BaseResource 
Jun 30, 2012 5:09:59 PM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean checkResources 
SEVERE: No resource classes found 
Jun 30, 2012 5:09:59 PM org.apache.catalina.startup.HostConfig deployWAR 
SEVERE: Error deploying web application archive D:\workspace\api\src\main\catalina_base\webapps\testapi-1.0.war 
org.apache.cxf.service.factory.ServiceConstructionException 
       at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:194) 
       at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deploy(CxfRsHttpListener.java:126) 
       at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployPojo(CxfRsHttpListener.java:97) 
       at org.apache.openejb.server.rest.RESTService.deployPojo(RESTService.java:270) 
       at org.apache.openejb.server.rest.RESTService.afterApplicationCreated(RESTService.java:173) 
       at org.apache.tomee.webservices.TomeeJaxRsService.afterApplicationCreated(TomeeJaxRsService.java:55) 
       at org.apache.tomee.catalina.WebDeploymentListeners.afterApplicationCreated(WebDeploymentListeners.java:38) 
       at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:818) 
       at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:103) 
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
       at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
       at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401) 
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168) 
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) 
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) 
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) 
       at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:962) 
       at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1603) 
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
       at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
       at java.lang.Thread.run(Thread.java:662) 
Caused by: javax.ws.rs.WebApplicationException 
       at org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:312) 
       at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:144) 
       ... 23 more 
klasa

zasobów: pakietu com.tensorwrench.test;

import javax.ws.rs.*; 
import javax.ws.rs.core.Response; 
@Path("/test") 
public class BaseResource { 
    @GET @Produces("text/plain") @Path("test") Response helloWorld() { 
    return Response.ok("Hello world","plain/text").build(); 
    } 
    @GET @Produces("text/plain") String helloWorld2() { 
    return "Hello world without path!"; 
    } 
} 

web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app id="api" version="3.0" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"> 
<display-name>Service</display-name> 

build.gradle:

apply plugin: 'java' 
apply plugin: 'war' 

repositories { mavenCentral() } 

dependencies { 
    providedCompile 'org.apache.openejb:javaee-api:6.0-4' 
} 

version = '1.0' 
jar { 
     manifest { 
       attributes 'Title': 'Services', 
            'Version': version 
     } 
} 

</web-app> 

Próbowałem liczbę permutacji, dodając beans.xml, usuwanie kolejność adnotacji zmianę , przy użyciu różnych zależności kompilacji dla klas Java EE. Konsekwentnie dostaję ten błąd.

Odpowiedz

6

Wygląda na to, że twoje metody zasobów nie są objęte zakresem public. Wypróbuj to:

import javax.ws.rs.*; 
import javax.ws.rs.core.Response; 
@Path("/test") 
public class BaseResource { 
    @GET @Produces("text/plain") @Path("test") public Response helloWorld() { 
    return Response.ok("Hello world","plain/text").build(); 
    } 
    @GET @Produces("text/plain") public String helloWorld2() { 
    return "Hello world without path!"; 
    } 
} 
+1

Dzięki, to było to. Zawsze najłatwiejsza rzecz, która jest najtrudniejsza do zobaczenia. :/ – Nialscorva

+1

Bez obaw, lubimy próbować złapać [takie rzeczy] (https://issues.apache.org/jira/browse/OPENEJB-453), ale obecnie ten kod dotyczy głównie EJB. Dodano JIRA dla tego https://issues.apache.org/jira/browse/TOMEE-260 –

Powiązane problemy