2014-01-20 73 views
2

我在嵌入式jetty服務器(第8版)中運行帶有多個組件(JSP,resteasy,CDI,REST,Struts,maven)的應用程序,並且我的REST資源未被發現。當應用程序啓動時,我可以看到正在發現REST資源,並且在我點擊網頁時應用程序找不到的資源也在那裏。我錯過了什麼? 謝謝!在Jetty應用程序中找不到的Restasy資源

「[org.jboss.resteasy.cdi.ResteasyCdiExtension]發現的CDI bean,它是JAX-RS資源com.mycompany.rs.SiteResource。」

我在我的pom.xml以下RestEasy的依存關係:

<dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>jaxrs-api</artifactId> 
     <version>2.3.2.Final</version>    
    </dependency> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxrs</artifactId> 
     <version>2.3.2.Final</version> 
    </dependecy> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-servlet-initializer</artifactId> 
     <version>2.3.2.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-cdi</artifactId> 
     <version>2.3.2.Final</version> 
    </dependency> 

我已經在我的web.xml如下:

<context-param> 
    <param-name>resteasy.scan</param-name> 
    <param-value>true</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.servlet.mapping.prefix</param-name> 
    <param-value>/api</param-value> 
</context-param> 

<listener> 
    <listener-class> 
     org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap 
    </listener-class> 
</listener> 

<servlet> 
    <servlet-name>resteasy-servlet</servlet-name> 
    <servlet-class> 
     org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher 
    </servlet-class> 
</servlet> 

<servlet-mapping> 
    <servlet-name>resteasy-servlet</servlet-name> 
    <url-pattern>/api/*</url-pattern> 
</servlet-mapping> 

Java的其他資源具有以下路徑註釋:

@Path("/site") 

和URL我訪問的樣子:

http://localhost:9797/mycompany/api/site 

這是我收到的錯誤:

2014-01-19 23:18:20,989 ERROR 755 [com.mycompany.rs.RestError] Unknown exception or error: org.jboss.resteasy.spi.NotFoundException: Could not find resource for relative : /site of full path: http://localhost:9797/mycompany/api/site?_=1390202300961 

回答

1

我意識到了什麼問題 - 我運行通過Eclipse和RestEasy的這個應用程序一直在尋找的src/web應用/ WEB資源類-INF /類,但我的構建輸出文件夾是目標/類的eclipse默認值。

+0

您是否更改了輸出文件夾或是否可以重新配置resteasy? – koppor

相關問題