6

I started learning JavaEE yesterday and I chose an Oracle official guide FirstCup to get started

I'm using Netbeans 7.2 with GlassFish Server 3.1.2.2 and I'm sure I followed every instruction step by step. But I have two problems:

  1. I didn't see any REST Resources Configuration dialog as it says in the doc.
  2. I got an 404 error in the end. But if I change the url to

    http://localhost:8080/DukesAgeService/webresources/dukesAge  
    

    It works! I got this url by expanding RESTful Web Services->Right clicking DUkesAgeResource [dukesAge] ->Test Resource Uri

I want to know:

  1. where I can find this REST Resources Configuration dialong in 1.

  2. if 2 is a print mistake in Oracle the documentation. It says the relative url should be /resources/dukesAge

  3. Why the url must end with /webresources/dukesAge, can I change it?

perissf
  • 15,979
  • 14
  • 80
  • 117
ChandlerQ
  • 1,428
  • 2
  • 21
  • 29

1 Answers1

5

As pointed out in the comments, NetBeans 7.2 implements a default configuration for RESTFul Web Services that is different from the previous versions. This standard configuration can be overridden during the creation of the web service. Once created with the defaults, you can't use the wizard anymore (the Configuration choice from the right-click menu is grayed out).

Consequently, in order to view / edit the RESTFul paths, you need to edit the auto-generated Java classes directly:

  1. ApplicationConfig.java class contains the RESTFul main path in the annotation @javax.ws.rs.ApplicationPath("webresources")
  2. Each autogenerated XYZFacadeREST class contains the path relative to each entity class in the annotation @Path("entity.XYZ")

If you want to have the same paths as in the tutorial, you need to replace webresources with resources (point 1) and the path in point 2 with dukesAge.

perissf
  • 15,979
  • 14
  • 80
  • 117
  • Thanks for your reply and I see REST Resources Configuration now, but it is grey so I can't click it....I'm using nb7.2 – ChandlerQ Aug 30 '12 at 08:04
  • 1
    Weird thing. Probably the "Testing Resource" thing is causing this. Maybe restarting the IDE and/or rebuilding the project and/or recreating it from scratch can help. You can also edit the paths in web.xml and in the class code. – perissf Aug 30 '12 at 08:10
  • Having tried restarting,nothing changes...Besides, there is no web.xml but one glassfish-web.xml...But I found this http://netbeans.org/bugzilla/show_bug.cgi?id=211853, it seems Rest Resources Configuration has been disabled in JavaEE6 projects...And I did create an EE6 project... – ChandlerQ Aug 30 '12 at 08:24
  • 1
    I've found the reason, http://netbeans.org/bugzilla/show_bug.cgi?id=209713#c7, as it says, the Configuration dialog has been removed in NB7.2 with EE6 projects. We can change "webresources" in ApplicationConfig.java – ChandlerQ Aug 30 '12 at 08:55
  • 1
    I know this is old but not closed and I found this http://wiki.netbeans.org/STS_74_JavaEE – Douglas G. Allen Apr 01 '14 at 16:34