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 200724 - Testing RESTful WebService fails when clicking "Test Resource Uri" from witin NetBeans
Summary: Testing RESTful WebService fails when clicking "Test Resource Uri" from witin...
Status: RESOLVED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.0.1
Hardware: Macintosh (x86) Mac OS X
: P3 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords: USABILITY
Depends on:
Blocks:
 
Reported: 2011-08-06 19:01 UTC by Nabi
Modified: 2017-07-26 12:40 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 8080


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nabi 2011-08-06 19:01:58 UTC
Product Version = NetBeans IDE 7.0.1 (Build 201107282000)
Operating System = Mac OS X version 10.6.8 running on x86_64
Java; VM; Vendor = 1.6.0_26
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.1-b02-384
GlassFish Server Open Source Edition 3.1.1

I have a very simple web application created with Netbeans 7.0.1 which includes only a RESTful Webservice.

Here is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <!-- Jersey REST -->
    <servlet>
        <servlet-name>ServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ServletAdaptor</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>30</session-timeout>
        <cookie-config>
            <name>SESSIONID</name>
        </cookie-config>
    </session-config>
</web-app>


Here is the glassfish-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <context-root>/service</context-root>
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</glassfish-web-app>

As you can see the context-root is /service. From web.xml you can see that everything at /service/* will match the Jersey REST servlet. Now here is the REST service implemented:

package my.package;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/test/helloworld")
public class HelloWorld {
    
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getMessage() {

        return "Hello World";
    }
    
}

When I deploy the project to my locally installed Glassfish 3.1.1 and the hit http://localhost:8080/service/test/helloworld in my browser everything is executed as expected what means that I can see my "Hello World" message.

Now changing to NetBeans I open in my project the node "RESTful Web Services", make a right-click on "HelloWorld" and choose "Test Resource Uri" from the context menu. After that a warning dialog shows up with the following message:

Unable to open resource url:
http://localhost:8080/service//test/helloworld
Make sure the project has been deployed successfully, and the server is running.

If I choose @Path("test/helloworld") in my HelloWorld class I still get the same warning (even the resource url stays http://localhost:8080/service//test/helloworld).

Conclusion: Testing seems not to work if choosing "Test Resource Uri". Seems to be a bug.


Cheers, Nabi
Comment 1 Nabi 2011-08-06 19:18:30 UTC
It seems that the entry 

<url-pattern>/*</url-pattern>

in web.xml is causing the issue. The REST test feature cannot handle it correctly. If changiung it to something like 

<url-pattern>/rest/*</url-pattern>

everything seems to work. I hope this helps to solve the issue.
Comment 2 Denis Anisimov 2011-08-15 08:25:25 UTC
There is no steps to reproduce.
Please provide exact NB UI steps what do you use to get this issue.

All works fine for me if REST service has been created via NB wizards.

It seems you have created the REST service by hand ( avoiding NB wizards ).
Is it true ?

So the reason of the issue is the bad url which is used to REST WS access :
http://localhost:8080/service//test/helloworld
There should be no double "/" symbol.

It not happens if REST WS is created by NB wizards.
So this is not a big issue actually.

But I'm going to fix double slashes in the URL.
Comment 3 Nabi 2011-08-15 10:30:53 UTC
yes - you are right.
I did not use the wizard. instead i implemented ther REST service by hand. But from my point of view the behviour should be the same.

and yes - i also believe that the double slashes are the problem. and i agree that this is actually not a big issue, but it is still a small bug.

so i am glad to hear that you are going to fix it. i would re-test it once it is fixed...

thanks
Comment 4 Denis Anisimov 2011-08-15 11:11:28 UTC
OK, 
so the bug is : incorrect URL is used in "Test Resource Uri" action.
It could happen when RESTful WS is created without NB wizards .
I will fix it in 7.1.
Comment 5 Nabi 2011-08-15 11:45:02 UTC
exactly. as i said once 7.1 is out i will re-test.
Comment 6 Denis Anisimov 2011-09-06 16:48:13 UTC
web-main#a72d724cae3e
Comment 7 Quality Engineering 2011-09-07 14:32:14 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/a72d724cae3e
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#200724 - Testing RESTful WebService fails when clicking "Test Resource Uri" from witin NetBeans