Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with JavaEE sample FirstCup dukesAge

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?

like image 931
ChandlerQ Avatar asked Aug 30 '12 07:08

ChandlerQ


1 Answers

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.

like image 194
perissf Avatar answered Oct 03 '22 02:10

perissf