0

Currently I'm facing an issue when I'm trying to run the RestEasy with Tomcat.

I added all the corresponding jars.

But I'm unable to understand what cause the problem.

Below i have given all the configuration details and the resource which I used.

Server: Tomcat version 7 i'm using it.

Could somebody help me how to solve the issue, please let me know if missing anything.

Error Log

9 Sep, 2015 10:30:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.30
9 Sep, 2015 10:30:05 PM org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap 
WARNING: resteasy.scan is no longer supported.  Use a servlet 3.0 container and the ResteasyServletInitializer
9 Sep, 2015 10:30:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
9 Sep, 2015 10:30:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
9 Sep, 2015 10:30:06 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1792 ms
9 Sep, 2015 10:31:15 PM org.jboss.resteasy.core.ExceptionHandler 
SEVERE: failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/web-layer/rest/vechicle
    at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
    at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
    at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:255)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:192)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)

LIB Configuration

WebContent\WEB-INF\lib\activation-1.1.1.jar
WebContent\WEB-INF\lib\commons-codec-1.6.jar
WebContent\WEB-INF\lib\commons-io-2.1.jar
WebContent\WEB-INF\lib\commons-logging-1.1.3.jar
WebContent\WEB-INF\lib\httpclient-4.3.6.jar
WebContent\WEB-INF\lib\httpcore-4.3.3.jar
WebContent\WEB-INF\lib\jaxrs-api-3.0.12.Final.jar
WebContent\WEB-INF\lib\jboss-annotations-api_1.1_spec-1.0.1.Final.jar
WebContent\WEB-INF\lib\jcip-annotations-1.0.jar
WebContent\WEB-INF\lib\resteasy-jaxrs-3.0.12.Final.jar

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>asf-lpa-web</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>

  <!-- Auto scan REST service -->
    <context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- this need same with resteasy servlet url-pattern -->
    <context-param>
        <param-name>resteasy.servlet.mapping.prefix</param-name>
        <param-value>/rest</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>/rest/*</url-pattern>
    </servlet-mapping>

</web-app>

Service Interface

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/")

    public interface ParkService {

        @GET
        @Path("/vechicle")
        @Produces(MediaType.APPLICATION_JSON)
        public  Response getViewPark();

    }

Service Impl Class

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import javax.ws.rs.core.Response;

public class ParkServiceImpl implements ParkService{

    public Response getViewPark(){

        ViewTo viewTo = new ViewTo();
        //
        ///
        ///

        return response("view",viewTo);

    }

    private Response response(String jsonName, Object object) {

        Map<String, Object> outputMap = new TreeMap<String, Object>();
        outputMap.put(jsonName, object);

        return Response.ok(outputMap).build();
    }

}
Arun
  • 1,010
  • 6
  • 18
  • 37
  • @peeskillet I have used the same code in JBOSS it is working fine since Jboss comes with predefined library i don't know if i something missing here – Arun Sep 10 '15 at 03:21
  • @techuser web-layer is the application name or could be taken as context-path – Arun Sep 10 '15 at 03:22

2 Answers2

0

You're probably facing the same problem as the user who created this question: javax.ws.rs.NotFoundException: Could not find resource for full path

First try to change your rest api version to 3.0.4.Final and if your app works with it, than it's for sure the same problem.

Community
  • 1
  • 1
temuchin
  • 31
  • 6
0

I believe the problem is due to the @Path annotation on the interface. Apparently, ResteastServletInitializer can't handle that.

I would love to find out how to allow interfaces to have the @Path annotation.

randymay
  • 403
  • 4
  • 12
  • According to the JAX-RS specification, `@Path` annotation must be on the actual implementation. The other annotations (`@GET`, `@POST`, etc.) are allowed in the interface. – randymay May 13 '16 at 15:38