16

I am trying to create a small project concerning RESTful services. So I fire up IntelliJ IDEA and do:

New Project -> (select Java) -> (select RESTful WebService 2.2) -> check "Generate client and server code", select to download needed libraries.

Afterwards when going to the created HelloWorld class I get the following error: cannot resolve symbol "HttpServerFactory" as well as cannot resolve symbol "jersey" for this import: import com.sun.jersey.api.container.httpserver.HttpServerFactory;.

Any ideas how to solve this problem?

insumity
  • 5,311
  • 8
  • 36
  • 64
user3542880
  • 195
  • 1
  • 1
  • 8

2 Answers2

24

Alternatively, change the version of the Jersey library on your Module settings page. Apparently they removed the HttpServerFactory on later versions...

To change the version, right click on your module and select 'Open Module Settings (F4)'. From there on click Libraries on the left, select jersey from the library list, then click "Change Version". v1.12 worked for me.

enter image description here

Arca Artem
  • 1,063
  • 1
  • 10
  • 20
12

Download jersey library via maven solved the problem for me.

To create a RESTFul service:

  1. Select "New Project"
  2. Select "Java"
  3. Check "Application Server" and "RESTFul Web Service"
  4. Select "Set up library later"
  5. Click "Next"
  6. Click "Finish"
  7. Right-click on the project name
  8. Select "Add Framework support..."
  9. Check "Maven" in the list and "Ok"
  10. Add the following lines to the file pom.xml:

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

user3246654
  • 117
  • 4
  • I guess for an existing project with the error message, one would do the steps 7-10? Please clarify. – Artjom B. Jun 01 '14 at 18:53
  • The steps 1-6 are for creating the project, the steps 7-9 to be able to use maven in the project and the step 10 for downloading the jersey plugin. – user3246654 Jun 07 '14 at 18:33
  • Thanks, this helped me out in regards to an unrelated question i had :) – Base Sep 27 '15 at 11:00