Java Jersey Rest:找不到提供程序類。(訪問URL時出現(xiàn)404錯誤)
解決此問題的方法如下。我的本地主機已使用“ Apache” Web服務器設置,該服務器將所有請求重定向到Tomcat。由于“Jersey”正在使用新的servlet,因此我必須專門為此servlet創(chuàng)建一個單獨的重定向。
在Linux中
/etc/apache2/apache2.conf
加:
JkMount /rest/* ajp13_worker解決方法
編輯: 我還沒有意識到所有請求都首先進入“Apache”,然后被重定向到Tomcat。我在apache2.conf文件中添加了新的重定向。有關詳細信息,請參見接受的答案。
我有與此問題完全相同的問題。 澤西島RESTResourceConfig實例不包含任何根資源類,
我正在使用Tomcat,沒有maven。我遵循了本教程。http://www.ibm.com/developerworks/web/library/wa-aj-tomcat/index.html
我根據(jù)文章對web.xml進行了更改,即使用正確的包名稱創(chuàng)建了新的servlet和servlet映射。
<servlet> <servlet-name>Jersey REST Service</servlet-name><servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>sample.hello.resources</param-value> </init-param> <load-on-startup>1</load-on-startup></servlet><servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/rest/*</url-pattern></servlet-mapping>
我已將以下jar部署到tomcat
asm.jarjersey-server.jarjersey-core.jarjsr311.jar
Tomcat啟動日志具有以下例外。
com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for root resource and provider classes in the packages: sample.hello.resources com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class sample.hello.resources.HelloResource com.sun.jersey.api.core.ScanningResourceConfig init INFO: No provider classes found. com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application,version ’Jersey: 1.8 06/24/2011 12:17 PM’
當我訪問URL時,我得到一個404。http :// localhost:8080 / Jersey / rest /hello
編碼:
import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;@Path('/hello')public class HelloResource { @GET @Produces(MediaType.TEXT_PLAIN) public String sayHello() {return 'Hello Jersey'; }}
我在日志中看不到其他異常
相關文章:
1. 視頻文件不能播放,怎么辦?2. mysql - 把一個表中的數(shù)據(jù)count更新到另一個表里?3. 請教使用PDO連接MSSQL數(shù)據(jù)庫插入是亂碼問題?4. mysql 查詢身份證號字段值有效的數(shù)據(jù)5. visual-studio - Python OpenCV: 奇怪的自動補全問題6. mysql - 分庫分表、分區(qū)、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處7. node.js - nodejs開發(fā)中常用的連接mysql的庫8. linux - Ubuntu下編譯Vim8(+python)無數(shù)次編譯失敗9. python - 爬蟲模擬登錄后,爬取csdn后臺文章列表遇到的問題10. Python爬蟲如何爬取span和span中間的內(nèi)容并分別存入字典里?
