JavaEE FirstCup dukesAge Sample Issues

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

I am using Netbeans 7.2 with GlassFish Server 3.1.2.2, and I am sure that each step by step followed each instruction. But I have two problems:

  • I have not seen the REST Resource Configuration dialog box, as the document says.
  • I ended up getting error 404. 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 Click DUkesAgeResource [dukesAge] -> Test Resource Uri

I want to know:

  • where can I find this configuration of REST resources in 1.

  • if 2 is a printing error in the Oracle documentation. He says the relative url should be /resources/dukesAge

  • Why should the URL end with /webresources/dukesAge , can I change it?

+6
source share
1 answer

As pointed out in the comments, NetBeans 7.2 implements the default configuration for RESTFul web services, which is different from previous versions. This standard configuration may be overridden when creating the web service. After creating with the default settings, you will no longer be able to use the wizard (the configuration selection from the context menu is inactive).

Therefore, to view / edit RESTFul paths, you need to directly edit the automatically generated Java classes:

  • The ApplicationConfig.java class contains the main RESTFul path in the annotation @javax.ws.rs.ApplicationPath("webresources")
  • Each autogenerated XYZFacadeREST class contains a path relative to each entity class in the @Path("entity.XYZ") 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 at point 2 with dukesAge .

+5
source

Source: https://habr.com/ru/post/924146/


All Articles