9

Multiple pages on IBM support seem to differ on whether JAX-RS is built in to WebSphere 8.5.

http://www.ibm.com/developerworks/websphere/techjournal/1305_gunderson/1305_gunderson.html

The most recent versions of IBM WebSphere Application Server provide support for JAX-RS. WebSphere Application Server V8.5 has support for JAX-RS built in; no extra installation is required.

http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.iseries.doc/ae/twbs_jaxrs_devenv.html?cp=SSAW57_8.5.5%2F2-13-2-38-1-1&lang=en

To develop JAX-RS applications, the JAX-RS libraries must be added to the class path definition. See the information for your assembly tools to understand how to include libraries on the class path for the JAX-RS application.

What needs to be done to run JAX-RS on WebSphere 8.5. Is the web.xml mapping required? Are additional library files required?

Pool
  • 11,999
  • 14
  • 68
  • 78

1 Answers1

10

WebSphere 8.5.5 implements JAX-RS 1.1 provider, so you dont need any additional libraries. You may create mapping or not, depending on your needs. The best description of your options is here Configuring JAX-RS applications using JAX-RS 1.1 methods.

You can either:

  • Configure the JAX-RS application with only one JAX-RS default application in the web.xml file, like this:
<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>
<servlet-mapping>
  <servlet-name>javax.ws.rs.core.Application</servlet-name>
  <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
  • Configure the JAX-RS application using the javax.ws.rs.core.Application subclass and the web.xml file:
<servlet>         
    <servlet-name>com.example.MyApplication</servlet-name> 
</servlet>
<servlet-mapping>
    <servlet-name>com.example.MyApplication</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
  • Configure the JAX-RS application without a web.xml file. You only use annotations like @ApplicationPath, @Path, etc
@ApplicationPath("rest")
public class MyApplication extends javax.ws.rs.core.Application {
}

@Path("/helloworld")
public class HelloWorldResource {

    @GET
    public String sayHelloWorld() {
        return "Hello World!";
    }
}
Gas
  • 17,601
  • 4
  • 46
  • 93
  • Thanks, I think I was having issues with resolving classes deployed via IntelliJ. In my case I just added the first web.xml, and the resource, but I left out subclassing the `java.ws.rs.core.Application `. The link you posted helps a lot too. – Pool Feb 10 '15 at 14:56
  • Hi @Gas, maybe do you know what should I do to add support to jax-rs 2.0 to WAS 8.5 full profile? – Anatoly Feb 24 '16 at 20:58
  • 3
    @Anatoly full profile (now called traditional WAS) in 8.5.5.x version doesn't support JAX-RS 2.0. So you either can move to WebSphere Liberty Profile, or include third party JAX-RS library. See here [JAX-RS Jersey 2.10 support in Websphere 8](http://stackoverflow.com/questions/24684958/jax-rs-jersey-2-10-support-in-websphere-8) for options how to do it. – Gas Feb 24 '16 at 21:09
  • I can't get JAX-RS 1.1 with WebSphere 8.5.5 to use *not* be able to use a `web.xml` file. I am very intrigued in using annotations only. Can you provide more information on this, as you did above? Is you example for Liberty Profile only? –  May 06 '16 at 02:33
  • @ShawnStrickland - as stated in the link provided (which is for full profile aka traditional WAS) - it is stated `The ApplicationPath annotation is supported with the JAX-RS 1.1 specification.` so it should work fine just with annotations. Try and if you will have issues post another question :-) – Gas May 06 '16 at 09:12