Skip to main content

Where does Glassfish put RESTful URLs?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
dwschulze
Offline
Joined: 2008-11-25

I've got a .ear file that contains a .war with a RESTful web service. If I go to localhost:8080/appname the index.jsp page is displayed so the .war file was deployed correctly. If I try to send a GET to the RESTful web service using its URL localhost:8080/appname/rest/sendMessageWithReplyTo I get a 404 error.

Is there some way to make Glassfish tell me where it put my RESTful web service?

Here are my web.xml and Rest class implementation:

<web-app>

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;display-name&gt;rest.resource&lt;/display-name&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;servlet&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;init-param&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;param-value&gt;rest.resource&lt;/param-value&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;/init-param&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;/servlet&gt;
<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;servlet-mapping&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;

<span class="Apple-tab-span" style="white-space:pre"> </span>&lt;/servlet-mapping&gt;

&lt;/web-app&gt;
@Path(&quot;/sendMessageWithReplyTo&quot;)

public class SendMessageWithReplyToResource {


    @GET

    @Produces(MediaType.TEXT_HTML)

    public String callSendMessageWithReplyTo() {


        return &quot;&lt;html&gt; &quot; +

                    &quot;&lt;title&gt;&quot; + &quot;callSendMessageWithReplyTo()&quot; + &quot;&lt;/title&gt;&quot; +

                    &quot;&lt;body&gt;&lt;h1&gt;&quot; + &quot;Called sendMessageWithReplyTo()&quot; + &quot;&lt;/body&gt;&lt;/h1&gt;&quot; +

                &quot;&lt;/html&gt; &quot;;

    }

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dwschulze
Offline
Joined: 2008-11-25

The problem turned out to be that Maven built the .war without including the .class file for the RESTful web service. The WEB-INF/classes dir was created, and the .class file had been compiled but for some reason it didn't get included when Maven built the .war. Pretty strange. Maybe a spurrious error in packaging.

bhaktimehta
Offline
Joined: 2004-03-18

I had run into a similar issue and the problem was resolved by fixing
the right package for the restful webservice in my web.xml for
com.sun.jersey.config.property.packages init-param. Can you confirm if
the package name of your SendMessageWithReplyToResource class is
rest.resource?

Regards,
Bhakti

On 10/24/11 3:09 PM, forums@java.net wrote:
> I've got a .ear file that contains a .war with a RESTful web service.
> If I
> go to localhost:8080/appname [1] the index.jsp page is displayed so
> the .war
> file was deployed correctly. If I try to send a GET to the RESTful web
> service using its URL
> localhost:8080/appname/rest/sendMessageWithReplyTo [2]
> I get a 404 error.
>
> Is there some way to make Glassfish tell me where it put my RESTful web
> service?
>
> Here are my web.xml and Rest class implementation:
>
> rest.resource
> Jersey REST Service
> com.sun.jersey.spi.container.servlet.ServletContainer
>
>
> com.sun.jersey.config.property.packages
> rest.resource
> 1
> Jersey REST Service
> /rest/*
>
>
> @Path("/sendMessageWithReplyTo") public class
> SendMessageWithReplyToResource
> { @GET @Produces(MediaType.TEXT_HTML) public String
> callSendMessageWithReplyTo() { return " " + "" +
> "callSendMessageWithReplyTo()" + "" + "" + "Called
> sendMessageWithReplyTo()" + "" + " "; } }
>
> [1] http://localhost:8080/appname
> [2] http://localhost:8080/appname/rest/sendMessageWithReplyTo
>
> --
>
> [Message sent by forum member 'dwschulze']
>
> View Post: http://forums.java.net/node/856647
>
>

dwschulze
Offline
Joined: 2008-11-25

Yes, it is rest.resource.