6

I am trying to create Jersey normally with the aid of maven but I am always getting this structure as in the scrennshoot and without error as normally?! It does not look as Jersey commonly layout.

I am using this one:

org.glassfish.jersey.archetypes
jersey-quickstart-webapp
2.16

enter image description here

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.test</groupId>
  <artifactId>serverSide</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>serverSide</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
2
  • 1
    You have an almost empty pom.xml with only junit added as test dependency. Can you please explain, what other things did you expect to see in eclipse?
    – npe
    Commented May 3, 2015 at 20:12
  • @npe: As I said I created it with the aid of the eclipse IDE- Maven - Maven project. Usually I can start without adding any other resource to it I have done it before?! In the screenshoot, this project instance has been created by maven! also this behaviour is strange?
    – Mr Asker
    Commented May 3, 2015 at 20:31

3 Answers 3

26

I highly doubt you are creating the archetype project correctly. What you are showing is a product of the org.apache.maven.archetypes : maven-archetype-quickstart

Here's a quick walk-through of how to create the Jersey archetype in Eclipse

  1. Go to FileNewOther

  2. In the dialog, select the Maven file the Maven Project, then Next

    enter image description here

  3. In the next dialog keep all the defaults, and hit Next

    enter image description here

  4. In this next dialog we will select the Maven archetype. In the search box, type jersey-quickstart-webapp. All the archetypes takes a few moments to load. You can see the progress at the bottom right of the IDE is they are still loading. This shouldn't take more than maybe 5 seconds. If you are not seeing any results come up from the search, then it's likely you don't have the archetypes installed. See this Stackoverflow answer for how you can get the archetypes.

    Once the archetypes load, and you see the jersey-quickstart-webapp in the results list, uncheck "Show the last version of Archetype only". So once you have unchecked that, you should see more version available. Scroll down to the org.glassfish.jersey.archetypes and select the version 2.16 (or whatever the latest version is, if you choose). Then hit Next

    enter image description here

  5. In the next dialog, enter the groupId, artifactId, and package, then hit Finish

    enter image description here

  6. You should now see a project with the following structure. There will be an error in the project because of you jsp page. We have no use for it here, so you can delete it if you want. This should get rid of the error.

    enter image description here


See Also:

7
  • 1
    I have already did the same but what helped me is tte fourth point with the stackoverflow answer link :) Thanks.
    – Mr Asker
    Commented May 4, 2015 at 8:28
  • Anyone knows how to achieve the equivalence of this with Gradle?
    – PabloQ
    Commented Feb 1, 2016 at 14:04
  • @PabloQ this is pretty much all you need Commented Feb 1, 2016 at 14:25
  • @peeskillet I did the above steps mentioned by you, but I was unable to run this on the sever (tomcat 7). When I tried to add the resource, I get a message no resources found. Kindly suggest me what should be done to run this type of project on server. Commented Mar 7, 2016 at 14:43
  • To add to my previous comment - I had downloaded jersey-quickstart-grizzly2 v 2.22.2 Commented Mar 7, 2016 at 14:52
9

One point I want to add, If you are getting following error while installing the archetype showed in image 1

Can't resolve Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21 org.eclipse.core.runtime.CoreException: Could not resolve artifact org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.21

Image 1: enter image description here

Then before procedding with the solution specified in this stackoverflow answer, try to complete the following steps in eclipse:

Steps:

  1. Go to Eclipse Help -> Install New Software...
  2. Enter "http://download.eclipse.org/technology/m2e/releases" inside Work with field and click on Add button.
  3. Give any name. For example "remote archetypes" and click on OK button. enter image description here
  4. Then click on Select All button. enter image description here
  5. click Next button two times.
  6. Accept the licence and install the updated maven.
0

Can't resolve Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21 org.eclipse.core.runtime.CoreException: Could not resolve artifact org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.21

To resolve the issues with respect to archetypes while creating a new maven project ,please follow the same.

Navigate as follows in your Eclipse IDE,

Hover to windows-->Click on Preferences

Search for maven and select Archetype(first option under the hood as in screen shot) enter image description here

This above URL could be changed in future;in that case please refer the below link under location of catalog files for latest URL http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html

  • Under Description,enter your own description of choice & click ok & apply the main menu.

Give eclipse sometime to load your archetypes.(Check progress menu for the download status)

And this worked out for me. Thanks

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.