This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 213271 - "Test Restful Web Services" action generates bad test client
Summary: "Test Restful Web Services" action generates bad test client
Status: RESOLVED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-31 06:27 UTC by toben
Modified: 2013-08-20 08:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
<no description> (71.21 KB, application/x-java-archive)
2012-05-31 06:31 UTC, toben
Details

Note You need to log in before you can comment on or make changes to this bug.
Description toben 2012-05-31 06:27:12 UTC
Product Version = NetBeans IDE 7.2 Beta (Build 201205031832)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_04
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.0-b21

I made a simple maven web project. In there I created a small rest root service class. All works fine, but if I introduce a path parameter at class level the test website presents this url encoded (e.g. test/%7Bparam%7D instead of test/{param}) and now this path is not useable anymore. The service itself works as expected. If I use path parameters at method level, all works fine.

However, how do I activate POST within the test website?
Comment 1 toben 2012-05-31 06:31:42 UTC
Created attachment 120099 [details]
<no description>
Comment 2 Denis Anisimov 2012-05-31 06:46:54 UTC
How the IDE is involved in  your description ?
It seems you did some manual correction and get some problem with 
working REST URL. So your problem relates to your actions, REST specification
understanding and REST at the runtime .
I don't see any issues on the IDE side.
Comment 3 toben 2012-05-31 07:55:38 UTC
The IDE creates this test website. This is done by clicking at RESTFul Web Services Node of my project and choosing Test RESTFul Web Services. 

As I said, the rest service itself works perfectly, so what do you mean by " So your problem relates to your actions, REST specification
understanding and REST at the runtime."  ???
Comment 4 Denis Anisimov 2012-05-31 08:27:19 UTC
(In reply to comment #3)
> The IDE creates this test website. This is done by clicking at RESTFul Web
> Services Node of my project and choosing Test RESTFul Web Services. 
> 
> As I said, the rest service itself works perfectly, so what do you mean by " So
> your problem relates to your actions, REST specification
> understanding and REST at the runtime."  ???

That's from your description :
>All works fine, but if I introduce a path parameter at class level the
>test website presents this url encoded (e.g. test/%7Bparam%7D instead of
>test/{param}) and now this path is not useable anymore.

I've interpreted it as : 
IDE has been used for REST web service creation. The resulting RESTful WS 
works fine. You did a MANUAL change in the source file and the resulting RESTful
WS is not working.
Sorry if I misunderstand you.

In the latter case please provide exact UI steps to reproduce. 
This is always helpful and actually required to identify the issue because it 
helps to avoid the misunderstanding.

In case my understanding is correct then this is not a bug because the problem 
is introduced by you via editing originally working RESTful WS. 
There could be a problem in the runtime but it is definitely not a bug in the IDE.
Comment 5 toben 2012-05-31 09:10:07 UTC
Aha. ;). I see. My explanation could led to your interpretation. So sorry for this.

I did already attach a resulting project.

If you look at the class TestResource there you see the class level path annotation @Path("test/{param}"). This is the problematic one that the restful test web site is not able to work with. If you change the class level annotation to @Path("test") and introduce a method level anntoation @Path("{param}") the test website is working as expected.

Both versions have valid Path annotations, if my understanding of it is correct.

Here are the steps to create this test project:

1. create new maven java web application project
2. create a simple root resource using the "RESTful web services from patterns" file type using the path "test"
3. create this simple hello method:

@GET
@Path("{param}")
@Produces("text/plain")
public String getHello(@PathParam("param") String param) {
	return "Hallo " + param;
}

4. create test website using "Test Restful Web Services" and choose "web test client in project" 
5. Starting this project (deploying in server) and open in your browser test-services.html

You should now have a working version of this test web client.

The problem starts here when I want to introduce the parameter "param" in my class level annotation. This is done by deleting @Path("{param}") at getHello and modifying the class annotation to @Path("test/{param}"). This is a valid modification to my service. The service works as expexted using plain WebBrowser requests like http://localhost:8080/webresources/test/toni resulting in "Hallo toni" . But if you reload the test web client this version is behaving as described in my error report.

So there seems to be a problem with the test web client.
Comment 6 Denis Anisimov 2012-05-31 09:25:42 UTC
Thanks.
The bug title should be : "Test Restful Web Services" action generates bad
test client.
It happens when @Path annotation contains parameter on the class  level.
Verb "test" doesn't point directly to "Test Restful Web Services" UI action.
Comment 7 chase 2013-01-29 07:41:50 UTC
I'm also having problems with the Test RESTfult Web Services client that is generated by NetBeans. I'm using NB 7.2 with a EE 6 JAX-RS service (WLS 12c which uses Jersey 1.9).

There seems to be several things wrong with the generated JavaScript which causes the client to not show any services and not function in any way. The first thing I noticed is that the code fails to process the WADL file. It looks like the generated code doesn't understand the WADL elements being in a namespace. See http://java.net/projects/jersey/lists/users/archive/2011-06/message/223

Here is an example of my generated WADL:

<ns0:application xmlns:ns0="http://wadl.dev.java.net/2009/02">
<ns0:doc xmlns:ns1="http://jersey.java.net/" ns1:generatedBy="Jersey: 1.9 09/02/2011 11:17 AM"/>
<ns0:grammars/>
<ns0:resources base="http://10.0.0.16:7001/HelloWorld/resources/">
<ns0:resource path="/helloWorld">
<ns0:method id="getXml" name="GET">
<ns0:response>
<ns0:representation mediaType="text/html"/>
</ns0:response>
</ns0:method>
<ns0:method id="getPlainText" name="GET">
<ns0:response>
<ns0:representation mediaType="text/plain"/>
</ns0:response>
</ns0:method>
<ns0:method id="putString" name="PUT">
<ns0:request>
<ns0:representation mediaType="text/plain"/>
</ns0:request>
</ns0:method>
</ns0:resource>
</ns0:resources>
</ns0:application>
Comment 8 Milan Kuchtiak 2013-08-19 08:42:28 UTC
Problem with Maven project types, and non web.xml configuration is than Netbeans is incorrectly calculating resources path.
Comment 9 Milan Kuchtiak 2013-08-19 14:55:50 UTC
Fixed issue with incorrect calculation of BASE URL for REST Tester application:
http://hg.netbeans.org/web-main/rev/9df5c11ec762

However, the original problem with (class level) Path annotation containing parameter is still valid.
Comment 10 Quality Engineering 2013-08-20 02:43:55 UTC
Integrated into 'main-silver', will be available in build *201308192300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9df5c11ec762
User: Milan Kuchtiak <mkuchtiak@netbeans.org>
Log: #213271 fixed incorrectly calculated BASE URL for REST tester application in Maven projects
Comment 11 Milan Kuchtiak 2013-08-20 08:35:40 UTC
Fixed.

Test client sends an OPTIONS XmlHttpRequest request for wadl file, that escapes the path parameter (containing brackets) in wadl file. The fix is based on unescaping path parameters back.

See:

http://hg.netbeans.org/web-main/rev/a63a176833b3
http://hg.netbeans.org/web-main/rev/042388afce52