javax.ws.rs package
Asked Answered
H

2

9

I am learning RESTful Web Services and all the tutorials use javax.ws.rs.* package. But with JDK 6 and JDK 7, my Eclipse doesn't seem to recognize javax.ws package. What am I missing here?

Harness answered 4/4, 2012 at 3:19 Comment(3)
Do you have jsr311-api.jar in your classpath?Co
Adding jsr311-api.jar fixed the issue. But the java 6 API mentions these classes. Not sure why I need to add it separately.Harness
Similar: What Maven Artifact Contains javax.ws.rs.Path?Lenzi
P
2

javax.ws.rs is not a JDK package; it is a server-side API that forms part of the Java EE specification. You would need to include a Java EE runtime on your classpath or source an implementation from a 3rd party if you're going the self-assembly route (e.g. using Tomcat.)

Periwig answered 4/4, 2012 at 8:7 Comment(4)
Why is jax-ws (Soap based) shipped with JDK but not jax-rs (Rest based)?Whitley
@Whitley I guess it is because it is much easier to write a REST client than a SOAP client but I can't give a definitive answer.Periwig
Interesting, jax-rs does come with Metro stack and Metro is shipped with JDK6. This means not full stack of Metro is shipped with JDK. Confused!Whitley
@Whitley I do not think Metro is a JAX-RS implementation. I believe Jersey is the JAX-RS reference implementation.Periwig
C
2

You're may be missing Jersey installation, or something in your environment configuration. Try also installing Eclipse WPT. You can follow this tutorial, it covers prerequisites and basic installation procedures as well.

Co answered 4/4, 2012 at 3:44 Comment(1)
I added jersey installation to classpath. But Jersey does not have javax.ws.rs package. shouldn't javax.ws.rs package be in Java 6 SDK? But it doesn't seem to be.Harness
P
2

javax.ws.rs is not a JDK package; it is a server-side API that forms part of the Java EE specification. You would need to include a Java EE runtime on your classpath or source an implementation from a 3rd party if you're going the self-assembly route (e.g. using Tomcat.)

Periwig answered 4/4, 2012 at 8:7 Comment(4)
Why is jax-ws (Soap based) shipped with JDK but not jax-rs (Rest based)?Whitley
@Whitley I guess it is because it is much easier to write a REST client than a SOAP client but I can't give a definitive answer.Periwig
Interesting, jax-rs does come with Metro stack and Metro is shipped with JDK6. This means not full stack of Metro is shipped with JDK. Confused!Whitley
@Whitley I do not think Metro is a JAX-RS implementation. I believe Jersey is the JAX-RS reference implementation.Periwig

© 2022 - 2024 — McMap. All rights reserved.