pnkflydgr
pnkflydgr

Reputation: 715

Getting null error when running a simple JAX-RS app on Websphere Application Server 7

I have no compilation errors and my app launches fine on my testing server. However, I get an error when trying a GET request:

[1/2/14 10:23:13:248 EST] 00000022 RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (404 - Not Found) with message 'null' while processing GET request sent to http://localhost:9081/IDMWorkflowServices/resources/workflow

Here is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>IDMWorkflowServices</display-name>
<servlet>
    <description>
    JAX-RS Tools Generated - Do not modify</description>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.core.Application</param-name>
        <param-value>com.psg.itim.workflow.WorkflowResourceApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <url-pattern>
    /resources/*</url-pattern>
</servlet-mapping>
</web-app>

Here is WorkflowResource:

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;

// The Java class will be hosted at the URI path "/workflow"
@Path("/workflow")
public class WorkflowResource {
    @GET
    @Produces("text/plain")
    public String getClichedMessage() {
        // Return some cliched textual content
        return "Hello World";
    }
}

Here is WorflowResourceApplication:

import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

public class WorkflowResourceApplication extends Application{
    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> classes = new HashSet<Class<?>>();
        classes.add(WorkflowResource.class);
        return classes;
    }
}

If it's not painfully obvious, this is my first attempt using JAX-RS. I'm not exactly sure what I do or do not need from the above code to get this to work. It seems simple, but when I go to this url

http://localhost:9081/IDMWorkflowServices/resources/workflow

the 404 happens. Any ideas of what I am doing wrong?

Upvotes: 2

Views: 9286

Answers (2)

pnkflydgr
pnkflydgr

Reputation: 715

Resolved! The only thing that was wrong was this line:

<param-name>javax.ws.rs.core.Application</param-name>

I changed it to:

<param-name>javax.ws.rs.Application</param-name>

I assumed it should have been the same Class I was calling from WorflowResourceApplication.java, but this was not the case. Everything works fine now. Apparently the application recognized the class error as a client side issue and registered a 404.

Upvotes: 3

Dinesh Arora
Dinesh Arora

Reputation: 2255

The first step to debug this would be to see if you have the correct port. So do this - Try accessing just - http: //localhost:9081 . see if you get to default page or blank page or hello page if there is default index.jsp. If you get 404 then that means that you serever is running but your port number is incorrect.

If you are unsure what your port settings are(If I am correct then default port should be 9080) then follow this documentation - http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.migration.nd.doc%2Finfo%2Fae%2Fae%2Frmig_portnumber.html

Upvotes: 0

Related Questions