3

Jersey Rest Servlet で奇妙な問題に直面しています。以下の構成で Jersey 1.17.1 を使用していますが、Rest サービスにアクセスしようとすると、404 - Not Foundエラーのみが表示されます。

奇妙なのはこのログです:ルート リソース クラスを受け入れます: "/" , but I am not requesting on "/" I am requesting on "/r/..."

com.sun.jersey.config.property.resourceConfigClass.

ログは、サービスが正しくロードされたことを示しています。

Root resource classes found:
  class com.xxx.restful.SearchRESTService

ここで、サービスが実行されていることがわかります。

2 < X-Jersey-Trace-001: match path "/" -> "/application\.wadl(/.*)?", "/request(/.*)?", "/search(/.*)?"

web.xml

<context-param>
    <param-name>context-root</param-name>
    <param-value>root</param-value>
</context-param>

<servlet>
        <servlet-name>JerseyREST</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
            <param-value>com.xxx.restful.ResourceConfig</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>

        <init-param>
            <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
            <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
            <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.config.feature.Trace</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.config.feature.Debug</param-name>
            <param-value>true</param-value>
        </init-param>

        <load-on-startup>3</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>JerseyREST</servlet-name>
        <url-pattern>/r/*</url-pattern>
    </servlet-mapping>

休憩サービス:

@Path("/search")
public class SearchRESTService {

    @GET
    @Path("/related")
    @Produces({ MediaType.APPLICATION_JSON })
    public Response getRelatedSearch(@QueryParam("query") String query) {
        List<String> result = ...;
        return Response.ok(result).build();
    }
}

起動ログ

INFO: Initiating Jersey application, version 'Jersey: 1.17.1 02/28/2013 12:47 PM' Oct 31, 2013 1:37:52 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  com.xxx.restful
Oct 31, 2013 1:37:52 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class com.xxx.restful.SearchRESTService
Oct 31, 2013 1:37:52 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Provider classes found:
  class com.xxx.restful.NucleusProducer
Oct 31, 2013 1:37:52 PM com.sun.jersey.server.impl.application.DeferredResourceConfig$ApplicationHolder <init>
INFO: Instantiated the Application class com.xxx.restful.NucleusResourceConfig

リクエストログ

Oct 31, 2013 1:38:08 PM com.sun.jersey.api.container.filter.LoggingFilter filter
INFO: 2 * Server in-bound request
2 > OPTIONS http://localhost:7103/root/r/search/related?query=arduino
2 > Host: localhost:7103
2 > Connection: keep-alive
2 > User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
2 > Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
2 > Content-Type: application/json
2 > Accept: */*
2 > DNT: 1
2 > Accept-Encoding: gzip,deflate,sdch
2 > Accept-Language: en-US,en;q=0.8,pt-BR;q=0.6,pt;q=0.4
2 >

Oct 31, 2013 1:38:08 PM com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
INFO: 2 * Server out-bound response
2 < 404
2 < X-Jersey-Trace-000: accept root resource classes: "/"
2 < X-Jersey-Trace-001: match path "/" -> "/application\.wadl(/.*)?", "/request(/.*)?", "/search(/.*)?"
2 < X-Jersey-Trace-002: mapped exception to response: com.sun.jersey.api.NotFoundException@7fae8378 -> 404 (Not Found)
2 <
4

1 に答える 1