0
私は長すぎるため、これで壁に頭を打つようになっています。私は単純なJAX-RSサーブレットのサンプルを手に入れようとしています。私はEclipse(火星)を使用しています。私はそれをTomcatに組み込み、表面的に展開することができます(Tomcatは楽しく始まりますが)、私は応答が期待できる404を取得します。シンプルなJAX-RSサーブレットの404はなぜですか?
のweb.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>radio16-webservice</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Testme</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.testme</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TestMe</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Testme.java:
package com.testme;
//import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
//import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
@Path("testRoot")
public class Tester {
@Context
private UriInfo context;
public Tester() {}
@GET
@Path("testme")
@Produces("text/html")
public String TestMe() {
return "<html lang=\"en\"><body><h1>Hello, World!!</h1></body></html>";
}
}
ここではTomcatの出力です:
May 02, 2016 3:22:52 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:radio16-webservice' did not find a matching property.
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.33
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Mar 18 2016 20:31:49 UTC
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.33.0
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Linux
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 3.19.0-30-generic
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: /opt/jdk/jdk1.8.0_65/jre
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_65-b17
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /fast/git/testme/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /fast/apache-tomcat-8.0.33
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/fast/git/testme/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/fast/apache-tomcat-8.0.33
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/fast/git/testme/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/fast/apache-tomcat-8.0.33/endorsed
May 02, 2016 3:22:52 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
May 02, 2016 3:22:52 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 02, 2016 3:22:53 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
May 02, 2016 3:22:53 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 02, 2016 3:22:53 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
May 02, 2016 3:22:53 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 02, 2016 3:22:53 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1778 ms
May 02, 2016 3:22:53 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 02, 2016 3:22:53 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.33
May 02, 2016 3:22:55 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 02, 2016 3:22:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
May 02, 2016 3:22:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
May 02, 2016 3:22:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3358 ms
は修正方法404にhttp://localhost/testRoot/testme/
結果に行きますか?
javax.ws.rs.core.Applicationにリソースクラス(Tester)を登録しましたか? – suenda
FWIW、これは決して解決しませんでした。私はこの問題が強調されていると思っています。それは、いくつかのコンテキストに展開されていることですが、そのコンテキストが何であるか分かりません。 私は基本的にTomcatの手動で手動でEclipseプロジェクト(Tomcat Web管理インターフェースを使用して)にビルドされた.warファイルをデプロイしました。 – rivenmyst137