0
votes

After upgrading from JBoss AS 7.1.1-Final to Wildfly 9.0.1-Final, I get this exception when I try to access my servlet. Actually we're using Resteasy for web services and, a servlet to handle a GWT web page, with JBoss AS 7.1.1-Final everything worked just fine, however after the upgrade nothing work as expected, bellow you'll find a snippet of my web.xml file and jboss-web.xml.

web.xml

<servlet>
    <servlet-name>admin</servlet-name>
    <servlet-class>com.afp.iris.sr.sco.scom.servlet.ScomIHMServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>admin</servlet-name>
    <url-pattern>/admin/*</url-pattern>
</servlet-mapping>

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

    <init-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
<servlet-mapping>
            <servlet-name>Resteasy</servlet-name>
            <url-pattern>/*</url-pattern>
</servlet-mapping>

jboss-web.xml

<jboss-web>
    <context-root>/components</context-root>
</jboss-web>

When I try the following URL : http://mymachine:8080/components/admin I get the following exception

failed to execute: javax.ws.rs.NotFoundException: Could not find resource for full path: http://mymachine:8080/components/admin

#EDIT#

And this is the way I implement my rest services

@Stateless(name = "myServices")
@Path("/")
public class myServices {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_XML)
    public Response myFuntion(@Context final HttpServletRequest request) {
        return secondFunction(request, null);
    }
}

and the same goes for resteasy resources, what could be the source of this issue, all suggestions are welcome !

1
How are you implementing your REST services? Could you please update your question with the code? - aribeiro
@aribeiro, I edited my post so that it contains the rest implementation . - Youssef NAIT
Thank you @OndraŽižka, I didn't know such a tool exists. - Youssef NAIT

1 Answers

0
votes

Your web.xml file is missing WildFly's RESTeasy bootstrap class.

Also, move your resteasy.scan property from your servlet as init-param and place it as a context-param.

Below are the changes needed to be made:

<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>

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

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

<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Perhaps you could try to use the Servlet 3.0 Annotations instead of using servlet mappings.

As an invocation example, you could do the following:

public class Main {

    public static void main(String[] args) throws Exception {
        try {
            HttpClient client = HttpClientBuilder.create().build();

            HttpPost request = new HttpPost("http://localhost:8080/components");

            request.setHeader("Accept", MediaType.APPLICATION_XML);
            request.setHeader("Content-type", MediaType.MULTIPART_FORM_DATA);

            HttpResponse response = client.execute(request);

            if (response.getStatusLine().getStatusCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}