Mariano L
Mariano L

Reputation: 1879

GWT + Glassfish 4 : Error 404 for RPC servlet

I created a servlet for my GWT app made with eclipse. When I deploy it in TOMCAT works perfectly, but in Glassfish I have an 404 Error.

I have no deploy errors, the main html page loads well. But anything that use the RPC servlet gives me this error:

com.google.gwt.user.client.rpc.StatusCodeException: 404 Not Found
HTTP Status 404 - Not Found

type Status report

messageNot Found

descriptionThe requested resource is not available.

GlassFish Server Open Source Edition 4.1

My web.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_2_5.xsd"
    version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">

    <!-- Servlets -->
    <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>com.test.server.testServiceImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/webclient/test</url-pattern>
    </servlet-mapping>

    <!-- Default page to serve -->
    <welcome-file-list>
        <welcome-file>Webclient.html</welcome-file>
    </welcome-file-list>

</web-app>

In the stub for the RPC I have this com.test.client.testService :

@RemoteServiceRelativePath("test")
public interface testService extends RemoteService {

And the servlet:

public class testServiceImpl extends RemoteServiceServlet implements testService 

Notes:

When the app runs in tomcat, if I write the servlet name in the URL it shows me this error:

localhost:8080/webclient/webclient/test

Status HTTP 405 - Method HTTP GET is not supported in this URL

It seems that in fact is loaded well. But when is in Glassfish:

HTTP Status 404 - Not Found

What i'm missing? Thanks!

Upvotes: 2

Views: 1104

Answers (3)

Mariano L
Mariano L

Reputation: 1879

Solved! I didn't check the server.log of glassfish. There was an error of casting of the RPC servlet:

rpc servlet cannot be cast to javax.servlet.Servlet

The problem was I messed up the libs and added javax* in the classpath, and Glassfish don't need this. I deleted all additional libs I left in domain/lib/ext, and worked perfectly.

Thanks for your support!

Upvotes: 0

alexey
alexey

Reputation: 622

Try to change @RemoteServiceRelativePath("test") to @RemoteServiceRelativePath("/webclient/test")

In generall, <servlet-mapping> element should be in the form of an absolute directory path your app. You can read this useful article http://www.gwtproject.org/doc/latest/tutorial/RPC.html

And please, classes should name with upper case. I understand that maybe it is a test project, but to quickly get used to bad.

Upvotes: 2

Azimuts
Azimuts

Reputation: 1302

The behaviour with the GET in TOMCAT is correct (405)..but the 404 is strange. Have u got more information in your Glassfish log?? . Check this items...

0). Check the pattern of the URL . The URL should be http://hostname/nameOfWAR/{urlPatter_into_web.xml}

1).Make a test just to deploy a HelloWord jsp on the root of the web apps..and check the app is well-deployed showing some result..

2). Assuming that "webclient" is your WAR application have u exported or included the gwt-user jar in your app on deploying to Glassfish: gwt-user-xxx.jar ? If you use Eclipse you can use the Deployment Assembly or just locate the jar into the lib location of the war.

3.) Check there is no problem with the serialization policy file on the compiled gwt classes . Its a .gwt.rpc file... This must be on classpath . If this is the problems it should be more info throug exceptions, , etc... [ Also is possible to overwrite the location of this file overwriting SerializationPolicy ]

Upvotes: 2

Related Questions