Hot questions for Using GlassFish in gwt

Question:

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!


Answer:

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 ]

Question:

I have a gradle Material GWT Project setup. The projects builds just fine, and for some time now everything has been peachy. Not until I changed the dependencies for Material GWT from 1.6.0 to 2.0-rc3, and GWT itself from 2.7.0 to 2.8.0. I needed these because of the new widgets on Material GWT 2.0 and above. Upon deployment to Payara (glassfish 4) I get this exception, and deployment fails.

Severe:   Exception while deploying the app [myFunApp] : 
Exception [EclipseLink-23004] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.TransactionException
Exception Description: Error obtaining the Transaction Manager
Internal Exception: Exception [EclipseLink-23001] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.TransactionException
Exception Description: Error looking up external Transaction resource under JNDI name [java:appserver/TransactionManager]
Internal Exception: javax.naming.NameNotFoundException; remaining name 'appserver/TransactionManager'

I have seen Glassfish v4 Transaction Manager not found link where @Arun Gupta answers a similar question, but it makes no sense to me at all. Any ideas would really be helpful. I should point out that changing the dependencies work just fine.


Answer:

I never resolved this issue. But I have a nice workaround. The said project (Gradle, with Material GWT) was actually a single project. Separating the project into three projects, namely Client, API, and Commons projects, I was able to deploy the API separately to the same Glassfish Server as the Client. This separation somehow helped.

Question:

I have developed GWT application in Java 1.7, GAE 1.9.9, GWT 2.6.1 and Maven. Now I realized that we have Glassfish server with Java 1.6.0_43 on it. So I changed it, also change GWT to 2.1.1 to make app smaller, but Eclipse shows error: "App Engine requires Java 1.7 or later." Tried to change GAE to 1.7.5 and 1.6.6 and the error stays. I can't figure out what seems to be the problem.

What GAE should I use to compile my app with Java 1.6 and put it on Glassfish With Java 1.6? Or it's not a GAE problem, but something else?

Also is it possible to put my gwt-servler.jar in Glassfish lib to make my war smaller? Than I could go back to GWT 2.6.1 and add some functionality to my app.

I don't need GAE at all if I publish to glassfish, just gwt-servler.jar?


Answer:

Google app engine uses Java 7 which is now mandatory. On the GAE platform your webapps are running on Jetty servers.

Google App Engine Version 1.8.1 is the last which supports Java 6 (released in June 11, 2013). Since 1.8.2, the SDK only compiles with the Java 7 compiler and the only target runtime is Java 7.

Why do you need Glassfish + GAE + Java 6? If you develop for the GAE, you can't use Glassfish. The app engine sdk includes a bundled Jetty so you don't need it for developing, and certainly not for production.

If you don't develop for the App engine platform, then why do you need your project to be GAE project? Looks contradictory.

Either remove the GAE dependency (and libraries) from your project, or use Java 7 and not Glassfish (but the app engine SDK wich includes a bundled Jetty server).

Edit:

If you have Glassfish and you don't want to publish your webapp to Google App Engine, you don't need GAE at all. GWT also includes the Servlet apis which is useful for development, and Glassfish is an application server (servlet container) which contains the Servlet API implementation.

I think you got confused. The Google App Engine is a platform (platform as a service) and you ONLY have to make your project a GAE project and you ONLY have to add GAE libraries and dependencies IF you want to create and deploy your webapp specifically for the GAE platform.

Question:

I made a GWT App that use TCP/IP connections server side.

Now, I have harcoded the URL of the server that is used to connect:

private static final String URL = "https://localhost/ws";

I want to load this parameter from a config File like TOMCAT/conf/webService.conf or TOMCAT/conf/webService.xml but I can't find any propper way of doing this.

This app run in several servers and each server use a different WebService. I don't want to build a different app each time.


Answer:

You may want to put such configuration in an XML or properties file on the server side. Then you can get this path at runtime from within a servlet

String path = getServletContext().getRealPath("/WEB-INF/classes/config");
File file = new File(path);
// Read as XML or properties file