0

I'm following a tutorial on Vogella on how to work with JAX-RS to create RESTful web applications.

The trouble for me is that I am not able to import the dependencies through Maven. Is it possible?

When I try finding jsr311 or javax.ws.rs as suggested here, Maven doesn't seem to know it exists.

Maven Dependency JSR

Community
  • 1
  • 1
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363

4 Answers4

2

If you are satrting your project from scratch, it would be better to let maven generate your project for your using one of the Maven Archetypes that Jersey provides (More in the Jersey getting-started page) then you can easilly add the eclipse nature to the generated project using below command:

mvn eclipse:eclipse -Dwtpversion=2.0

Choose your suitable Web Tool version, then import that project into your Eclipse IDE. This method, will leave you out of poviding any dependencies related to Jersey as those are already mentioned in the archetype descriptor.

Otherwise, if you are already working on a project and you want to add the RESTful features (which assume is not true since you mentioned that you are following a tutorial), you will have to provide dependencies to Jersey yourself. All dependencies can be found in Maven Central Repo but you would only need the jersey-server one:

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.18.1</version>
</dependency>

As @Gimby stated, there is absolutely no sense in declareing the jsr311-api alone, only if you are intending to provide a JSR implementation :)

tmarwen
  • 15,750
  • 5
  • 43
  • 62
0

Ended up finding a similar question here.

Solved the problem by manually adding the dependency under pom.xml:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>
Community
  • 1
  • 1
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
  • You need a proper JAX-RS implementation such as Jersey or RestEASY in your Maven dependencies; that will transitively also provide the API dependency. Now you can compile, but you still can't actually run or deploy anything. This thread has more details: http://stackoverflow.com/questions/8476820/jax-rs-in-relation-to-jersey-and-jsrs – Gimby Sep 01 '14 at 21:28
  • Can Jersey be added through Maven somehow? – CodyBugstein Sep 01 '14 at 21:34
  • Hello, if you google "jersey maven" the first hit is a link to the very complete online Jersey manual. – Gimby Sep 01 '14 at 21:35
0

please try as following:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
    <scope>compile</scope>
</dependency>
Saeed Alizadeh
  • 1,417
  • 13
  • 23
0

foun it on : (http://mvnrepository.com/artifact/org.glassfish.jersey.archetypes/project/2.22.1) it will work inchalahh ;D

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.19</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.19</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.22.1</version>
    </dependency>
eGhoul
  • 2,490
  • 1
  • 13
  • 17