RESTful Web Service eclipse - java

I followed a very nice tutorial and it works smoothly for the GET http method, but for some reason when I try to access the POST or PUT methods the server returns:
HTTP Status 405 - Method Not Allowed
So this is what I did in the tutorial,
I created a new dynamic web project
I imported the jersey RESTful implementation
I created a new java class and set some jersey annotations
I edited the web.xml file for it to create a servlet on start up with some Jersey set up and point it to my Java class mapping it.
That's it, I ran the app on a tomcat 6 app server.
So when I follow the path of my class and I hence a #GET method it works smoothly but when i try to replace the #GET annotation with #POST it return the error above.
The 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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>RESTfulTest</display-name>
<servlet>
<servlet-name>NAME</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.RESTful.Test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>NAME</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
My Java class with the jersey annotations:
package com.RESTful.Test;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("/resttest")
public class Test {
//this WORKS!
#GET
#Produces(MediaType.TEXT_PLAIN)
public String getTestString()
{
return "Hello this is a test post";
}
//this returns the error
#POST
#Produces(MediaType.TEXT_PLAIN)
public String getTestString2()
{
return "Hello this is a test post";
}
//this returns the error
#PUT
#Path("{param1}")
#Produces(MediaType.TEXT_PLAIN)
public String getTstWithInput(#PathParam("/param1")
String param)
{
return "hello "+param;
}
//this returns the error
#PUT
#Path(value="/putTest")
#Produces(MediaType.TEXT_PLAIN)
public String getTstWithInput2(#PathParam("/param1")
String param)
{
return "hello "+param;
}
}
Please note that I have tried documenting all but the method I'm testing with the same results. I know I can't run some of them at the same time, they are all just tests.
I'm calling the REST resources from URL:
"http://localhost/RESTfulTest/rest/resttest/"
"http://localhost/RESTfulTest/rest/resttest/myname"
"http://localhost/RESTfulTest/rest/resttest/putTest"

Make sure the rest resources are called properly. Curl can be a hepful tool for testing
curl -XPUT http://localhost/RESTfulTest/rest/resttest/putTest

Try like this
return Response.status(200).entity("Sample Response").type(MediaType.TEXT_PLAIN).build();
More Details :
http://jersey.java.net/nonav/documentation/latest/user-guide.html

Related

Deploying a REST API to AWS

I am making a distributed system as a school project and I need to have a REST service. This will be a simple service with a login/register function and some information transfer.
I have made the REST API in Java in NetBeans. It works fine locally, but I am having difficulties to put it on my AWS server. I have no experience with servers, so I don't really know how it works. I thought that it should easy to get the service up and running on a server.
So far I have used this guide for the REST and tried to deploy the war-file with Elastic Beanstalk.
My Java code:
ApplicationConfig.java
package dk.dtu.ds.login;
import java.util.Set;
import javax.ws.rs.core.Application;
#javax.ws.rs.ApplicationPath("CoL")
public class ApplicationConfig extends Application {
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new java.util.HashSet<>();
addRestResourceClasses(resources);
return resources;
}
/**
* Do not modify addRestResourceClasses() method.
* It is automatically populated with
* all resources defined in the project.
* If required, comment out calling this method in getClasses().
*/
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(dk.dtu.ds.login.Login.class);
}
}
Login.java
package dk.dtu.ds.login;
import cleanoutloudserver.ICleanOutLoud;
import java.net.MalformedURLException;
import java.net.URL;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
#Path("login")
public class Login {
// HTTP Get Method
#GET
#Path("dologin")
// Produces JSON as response
#Produces(MediaType.APPLICATION_JSON)
// Query parameters are parameters: http://localhost/colrest/CoL/login/dologin?username=s150157&password=1234
public String doLogin(#QueryParam("username") String uname, #QueryParam("password") String pwd) throws MalformedURLException, Exception {
URL url = new URL("http://ec2-52-43-233-138.us-west-2.compute.amazonaws.com:3769/col?wsdl");
QName qname = new QName("http://cleanoutloudserver/", "CleanOutLoudImplService");
Service service = Service.create(url, qname);
ICleanOutLoud col = service.getPort(ICleanOutLoud.class);
String token = col.login(uname, pwd);
token = Utility.constructJSON(token);
System.out.println("\nChecking credentials = true\n");
return token;
}
}
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>RESTWebApp</display-name>
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>dk.dtu.ds.login</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
When I then try to open the path for the service, I get a blank page. My Chrome console says "GET (link) 404 (Not Found)"
Since I am not that familiar with HTTP and servers, I don't know what to do.
Isn't there an easy way to deploy a simple REST service with AWS or have I done something wrong?
I have really tried to search google to find help, but there has been no success so far.
It seems like i got too confused by all the guides out there.
I found an easy solution and installed Tomcat on the EC2 instance, so I didn't even need to use Beanstalk.
All I did was following this guide and uploaded the war-file in the Web Application Manager and now it works fine.
Thanks for the comments they helped me on the way to find a solution.

Jersey rest api com.sun.jersey.api.container.ContainerExceptionServlet

I am new to creating API's. I found what I thought was a simple example online but was unable to get it to work. Any help or advice would be great.
This is my web.xml file
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Hello, World Application</display-name>
<description>
This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.
</description>
<servlet>
<servlet-name>GetEDPInfo</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>mypackage</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>GetEDPInfo</servlet-name>
<url-pattern>/GetEDPInfo</url-pattern>
</servlet-mapping>
This is my java example GetEDPInfo.java
package mypackage;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
#Path("/GetEDPInfo")
public class GetEDPInfo {
#GET
#Path("/{param}")
public Response getMsg(#PathParam("param") String msg) {
String output = "Welcome"+ msg;
return Response.status(200).entity(output).build();
}
}
I downloaded these jar files and placed them in my WEB-INF/lib directory
asm-3.1.jar, jersey-core-1.8.jar, jersey-server-1.8.jar
not sure if I need more than that, but those were all the ones used on the example i looked at.
I compiled my java file with the following command:
javac -source 1.7 -target 1.7 -bootclasspath /usr/java/jdk1.7.0_80/jre/lib/rt.jar cp .:/var/lib/tomcat6/webapps/sample/WEB-INF/lib/jersey-core-1.8:/var/lib/tomcat6/webapps/sample/WEB-INF/lib/jersey-server-1.8:/var/lib/tomcat6/webapps/sample/WEB-INF/lib/asm-3.1 GetEDPInfo.java
That created my class file with no errors.
When i navigate to http://grv4:8080/sample/GetEDPInfo
i get this message...
HTTP Status 405 - Method Not Allowed
type Status report
message Method Not Allowed
description The specified HTTP method is not allowed for the requested resource (Method Not Allowed).
When I navigate to http://grv4:8080/sample/GetEDPInfo/Jeeves
i get this message...
HTTP Status 404 - /sample/GetEDPInfo/Jeeves
type Status report
message /sample/GetEDPInfo/Jeeves
description The requested resource (/sample/GetEDPInfo/Jeeves) is not available.
This is my modified code...
package mypackage;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
#Path("/GetEDPInfo")
public class GetEDPInfo {
#GET
#Path("/{param}")
#Produces(MediaType.TEXT_PLAIN) #Consumes(MediaType.TEXT_PLAIN)
public String getMsg(#PathParam("param") String msg) {
String output = "Welcome"+ msg;
return output;
}
}
Change the <param-value>mypackage.GetEDPInfo</param-value> to following and it should work <param-value>mypackage</param-value>
I was able to get it working, for some reason I needed to change my web.xml file to use /* as my url pattern...
<servlet-mapping>
<servlet-name>GetEDPInfo</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Issue with un marshaling JSON into POJO from POST ajax request with Jersey servlet [duplicate]

I have been trying since hours to correct http error 415 Unsupported Media Type but it is still showing media unsupported page.
I am adding headers application/json in Postman.
Here is my Java Code
package lostLove;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.json.JSONObject;
#Path("/Story")
public class Story {
#POST
#Consumes({"application/json"})
#Produces(MediaType.APPLICATION_JSON)
// #Consumes(MediaType.APPLICATION_JSON)
// #Path("/Story")
public JSONObject sayJsonTextHello(JSONObject inputJsonObj) throws Exception {
String input = (String) inputJsonObj.get("input");
String output = "The input you sent is :" + input;
JSONObject outputJsonObj = new JSONObject();
outputJsonObj.put("output", output);
return outputJsonObj;
}
#GET
#Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "hello";
}
}
here is my web.xml file
<?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" 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>LostLove</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>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>lostLove</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
How our objects are serialized and deserialized to and from the response stream and request stream, is through MessageBodyWriters and MessageBodyReaders.
What will happens is that a search will be done from the registry of providers, for one that can handle JSONObject and media type application/json. If one can't be found, then Jersey can't handle the request and will send out a 415 Unsupported Media Type. You should normally get an exception logged also on the server side. Not sure if you gotten a chance to view the log yet.
Jersey doesn't have any standard reader/writer for the org.json objects. You would have to search the web for an implementation or write one up yourself, then register it. You can read more about how to implement it here.
Alternatively, you could accept a String and return a String. Just construct the JSONObject with the string parameter, and call JSONObject.toString() when returning.
#POST
#Consumes("application/json")
#Produces("application/json")
public String post(String jsonRequest) {
JSONObject jsonObject = new JSONObject(jsonRequest);
return jsonObject.toString();
}
My suggestion instead would be to use a Data binding framework like Jackson, which can handle serializing and deserializing to and from out model objects (simple POJOs). For instance you can have a class like
public class Model {
private String input;
public String getInput() { return input; }
public void setInput(String input) { this.input = input; }
}
You could have the Model as a method parameter
public ReturnType sayJsonTextHello(Model model)
Same for the ReturnType. Just create a POJO for the type you wan to return. The JSON properties are based on the JavaBean property names (getters/setters following the naming convention shown above).
To get this support, you can add this Maven dependency:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.17</version> <!-- make sure the jersey version
matches the one you are using -->
</dependency>
Or if you are not using Maven, you can see this post, for the jars you can download independently.
Some resources:
Jersey JSON support
Jackson documentation
Its because of following issue:
JAX-RS does not support default Jackson mapping conversion. So if you have the ajax request as below(Post):
jQuery.ajax({
url: "http://localhost:8081/EmailAutomated/rest/service/save",
type: "POST",
dataType: "JSON",
contentType: "application/JSON",
data: JSON.stringify(data),
cache: false,
context: this,
success: function(resp){
// we have the response
alert("Server said123:\n '" + resp.name + "'");
},
error: function(e){
alert('Error121212: ' + e);
}
});
and in JAX-RS controller side you need to do like below:
#Path("/save")
#POST
#Consumes(MediaType.APPLICATION_JSON)
#Produces(MediaType.TEXT_PLAIN)
public String saveDetailsUser(String userStr) {
Gson gson = new Gson();
UserDetailDTO userDetailDTO = gson.fromJson(userStr, UserDetailDTO.class);
String vemail = userDetailDTO.getEMAIL();
return "userDetailDTO";
}
Here please make sure on parameter. service is accepting json as String not the POJO.
Surely It will work. Thanks!
I have seen the same problem when using Jersey with HTTP/2, if the client send HTTP/1.1 request,e.g. using Jersey client, then it works fine.
If I switch to Jetty HTTP2 Client to send the same content, I get 415.
The temp solution I use is the alternative described by Paul Samsotha, i.e. "accept a String and return a String", then manually deserialize the String to POJO.

Jersey2 Client throwing javax.ws.rs.NotFoundException

I have written a sample REST service using Jersey2.
Here is my web.xml:
<web-app>
<display-name>jerseysample</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.adaequare.rest.config.JerseyResourceInitializer</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Here is my sample class:
package com.adaequare.resource;
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.MediaType;
#Path("/hello")
public class Hello {
#GET
#Produces(MediaType.TEXT_HTML)
public String sayHtmlHello(){
return "<html><title>Hello Jersey</title><body><h1>Hello Jersey</h1></body></html>";
}
#GET
#Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "Hello Jersey";
}
// This method is called if XML is request
#GET
#Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
}
}
I have deployed it to Tomcat and am able to access the following URL:
http://localhost:8080/jerseysample/rest/hello
I tried writing a unit test this way:
package com.adaequare.client;
public class MyResourceTest {
public static final URI BASE_URI = UriBuilder.fromUri("http://localhost").port(8080).build();
private HttpServer server;
private WebTarget target;
#Before
public void setUp() throws Exception {
ResourceConfig rc = new ResourceConfig(Hello.class);
server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, rc);
server.start();
Client c = ClientBuilder.newClient();
target = c.target(BASE_URI);
}
#After
public void tearDown() throws Exception {
server.shutdownNow();
}
#Test
public void testGetIt() {
String responseMsg = target.path("jerseysample").path("rest").path("hello").request().get(String.class);
System.out.println("I am here");
assertEquals("Got it!", responseMsg);
}
}
This class also throws the exception.
On executing this class, I am getting the following exception:
Exception in thread "main" javax.ws.rs.NotFoundException: HTTP 404 Not Found
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:917)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:770)
at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:90)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:671)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:423)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:667)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:396)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:296)
at com.adaequare.client.TestClient.main(TestClient.java:14)
I am sure I am missing some configuration stuff. I have browsed to see the root cause of the issue but to no avail. Can someone please let me know if I am missing something?
Your service is mapped to (and you are saying you can access it): http://localhost:8080/jerseysample/rest/hello but using your client you are calling http://localhost:8080/restserver/rest/hello which is different URL. What is the surprise?
Try
WebTarget target = ClientBuilder.newClient().target("http://localhost:8080/jerseysample/rest/").path("hello");
As for the second test, try calling getUri() on your WebTarget to see what URL you are actually calling, it should help you see where is the problem.
After your update:
Well first thing is, you haven't specified (in terms of content negotiation) what content your client accepts (you did this in your previous example, which you deleted). But that should not be a problem since in that case server should send you any of implemented ones since by not specifying it you are stating you are supporting all kind of responses. But the problem probably is putting String.class into get() method. There should go an entity you want Jersey to transform the response into. If you want to get String I would do something like this:
Response response = target.path("jerseysample").path("rest").path("hello").
request().get();
StringWriter responseCopy = new StringWriter();
IOUtils.copy((InputStream) response.getEntity(), responseCopy);
But you can't tell for sure which one of your three method is going to be called since it is on the same PATH, so you should also specify the content by passing it to request method.
Hope this helps anyone who can be facing the same problem. In my case, I created my web service RESTful project with the Netbeans Wizard. By any reason, I didn't know why, it missed the ApplicationConfig.java class which contains the annotation #javax.ws.rs.ApplicationPath("webresources"). I don't know why when I generated the client it showed me the correct path that I was expecting.
So, the solution for me was to copy another ApplicationConfig.java from other project and add my facade to the resources.
if you don't config web.xml to lookup the rest classes you need use #ApplicationPath to indicate the classes that keep the Rest resources.
#ApplicationPath("/rest")
public class AplicationRest extends Application
{
#Override
public Set<Class<?>> getClasses()
{
Set<Class<?>> resources = new java.util.HashSet<>();
resources.add(com.acme.SomeRestService.class);
return resources;
}
}
There is an error in web.xml
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>
com.adaequare.rest.config.JerseyResourceInitializer
</param-value>
</init-param>
please try below
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>
com.adaequare.resource.config.JerseyResourceInitializer
</param-value>
</init-param>

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?
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.
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

Categories

Resources