RPC Call Works in Hosted Mode But Not in Web Mode

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

RPC Call Works in Hosted Mode But Not in Web Mode

Postby jcmorris-mts » Wed Feb 20, 2008 9:35 am

Hi All,

I have a very simple test app consisting of one remote service that simply returns a String when called. Everything works as I expect it to in hosted mode. However, when I actually deploy the GWT module to Apache Tomcat 6.0 and try to run it from the browser, the app's web page loads fine but nothing happens when I click the app's only control with an event handler (just a button). Again, it works fine in hosted mode.

* I put in Window.alert(msg) calls in the onFailure() method of the AsycCallback class to see if/where it was blowing up -- nothing.
* I made sure that JavaScript and script debugging was enabled on my browsers (IE 7 and Firefox) and I looked for script errors -- nothing.
* BTW -- Yes, my client code is compiled to the 1.4 standard.

It's acting like the RPC call is never being made to the ServiceServlet implementation.

A possible clue:

An RPC file is generated in www\myApp\ called:

A54E696C43E49725CD8446E4171EA2C4.gwt.rpc

that contains the cryptic:

com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException, true
java.lang.String, true

I'm investigating the conditions under which IncompatibleRemoteServiceException is tossed, but so far I'm coming up blank for clues.

Apparently we cannot upload WAR files. If anyone is willing to take a look at it, I'll gladly send it along on a separate personal email.
Please contact me at jason.c.morris@gmail.com -- I'd sure appreciate it.
Meanwhile, I'll keep trying to debug it myself.

Cheers,
Jason
jcmorris-mts
 
Posts: 25
Joined: Wed Feb 06, 2008 12:16 pm

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby peterblazejewicz » Wed Feb 20, 2008 12:16 pm

hi Jason,
try regular GWT group,
e.g.
http://groups.google.com/group/Google-W ... 90b1246ab/

gwt.rpc class is security sealing solution for your service for cross-site attacks, it is required only if your service uses DTO/VO object which implements Serializable interface,
At runtime GWT generated servlet (RPC) checks for that path existance and reads allowed datatypes. If it cannot find that file or does not match type declaration it refuses to trade with request and throws exception,

I think there is something with your server or war structure, see linked thread or just search for war on group,

regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby jcmorris-mts » Wed Feb 20, 2008 1:07 pm

Thanks, Peter.

However, you may have misunderstood... I'm not having any difficulty generating the WAR file. I was referring to the fact that the Instantiations phpBB will not allow us to upload a WAR to the forum.
As for it being a general GWT problem -- I don't think so since GWT Designer is automatically generating all the configuration and build files for this app. I expect it to work or at least give me the options and/or instructions to manually correct it.

I'm not passing a data object (a bean) per se with the RPC to the service. As for the object that is being passed back -- it's a String -- what can be simpler? Would I have better luck if I actually built a bean and tried the RequestBuilder mechanism or something? Any other ideas?

I will try the general GWT forums, too :-)

FWIW: Here is the entry point java file

Code: Select all
package com.mts.myapp.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MyApp implements EntryPoint {
   private Label labelMessage;
   private Button clickMeButton;
   private SampleServiceAsync serviceProxy;

   public Label getLabelMessage() {
      return labelMessage;
   }

   public void onModuleLoad() {

      GWT.log("Starting MyApp test app...", null);
      RootPanel rootPanel = RootPanel.get();

      final AbsolutePanel absolutePanel = new AbsolutePanel();
      rootPanel.add(absolutePanel, 5, 5);
      absolutePanel.setSize("335px", "205px");
               
      clickMeButton = new Button();
      absolutePanel.add(clickMeButton, 0, 42);
      clickMeButton.setText("Click me!");
      clickMeButton.addClickListener(new ClickListener() {
         public void onClick(Widget sender) {

            GWT.log("OnClick event on button", null);

            serviceProxy = (SampleServiceAsync) GWT
                  .create(SampleService.class);

            String serviceUrl = GWT.getModuleBaseURL() + "SampleService";
            if (GWT.isScript()) {
               serviceUrl = "/SampleService";
            }
            ((ServiceDefTarget) serviceProxy)
                  .setServiceEntryPoint(serviceUrl);

            callSendMessage();

         }

      });

      labelMessage = new Label("No message yet...");
      absolutePanel.add(labelMessage);
   }

   private void callSendMessage() {
      AsyncCallback callback = new AsyncCallback() {

         public void onFailure(Throwable caught) {

            Window.alert("This call failed on the client!");
         }

         public void onSuccess(Object result) {

            GWT.log("RPC success", null);
            Window.alert("This call should be succeeding!");
            Label message = getLabelMessage();
            message.setText(result.toString());

         }
      };

      GWT.log("Service called on proxy...", null);
      serviceProxy.echo("I hope this work!", callback);
   }
}


The RemoteServiceServlet code:

Code: Select all
package com.mts.myapp.server;

import org.apache.log4j.Logger;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.mts.myapp.client.MyApp;
import com.mts.myapp.client.SampleService;
import com.google.gwt.core.client.GWT;
public class SampleServiceImpl extends RemoteServiceServlet implements SampleService {
   
   static Logger logger = Logger.getLogger(MyApp.class);

   private static final long serialVersionUID = 1L;

   public String echo(String message) {
      
      logger.debug("Sending a response...");
      GWT.log("Sending response...", null);
      return "It sure did!!!!";
   }

}


... and the interfaces....

Code: Select all
package com.mts.myapp.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public interface SampleService extends RemoteService {
   /**
    * Utility class for simplifying access to the instance of async service.
    */
   public static class Util {
      private static SampleServiceAsync instance;
      public static SampleServiceAsync getInstance(){
         if (instance == null) {
            instance = (SampleServiceAsync) GWT.create(SampleService.class);
            ServiceDefTarget target = (ServiceDefTarget) instance;
            target.setServiceEntryPoint(GWT.getModuleBaseURL() + "SampleServiceImpl");
         }
         return instance;
      }
   }
   
   public String echo(String message);
}


Code: Select all
package com.mts.myapp.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface SampleServiceAsync {
   public void echo(String message, AsyncCallback callback);
}


... and last but not least, the myApp.gwt.xml file
Code: Select all
<module>
   <inherits name="com.google.gwt.user.User"/>
   <entry-point class="com.mts.myapp.client.MyApp"/>
   <servlet path="/SampleService" class="com.mts.myapp.server.SampleServiceImpl"/>
</module>


Cheers,
Jason
jcmorris-mts
 
Posts: 25
Joined: Wed Feb 06, 2008 12:16 pm

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby peterblazejewicz » Wed Feb 20, 2008 1:52 pm

hi Jason,

there are some solution in your code which looks bizarre,
GWT Plugin wizard creates Util class whcih already set service proxy gateway for your,
You don't have to call set proxy methyod again and then yet once again,

I usually don't modify part generated by Util class (ncluding servlet name/class in config) but if required modify some code within getInstance method (usually I put block code to not invoke rpc code when in design view there),

regards,
Peter1
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby peterblazejewicz » Wed Feb 20, 2008 1:54 pm

hi,
totally forgot:
I don't remember if GWT Designer generates web.xml config file,
that is something we need to write,
so how your web.xml config part looks like?

regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby jcmorris-mts » Wed Feb 20, 2008 2:48 pm

Hi Peter,

Yes, I realized that I wasn't using the Util class just now. However, I also discovered something unexpected. By default, Designer is packaging all the compiled classes as one JAR and deploying it in the WEB-INF\lib folder of my web application. For some reason, this is not working. So, I manually created a WEB-INF\classes folder (which the Designer build.xml file did not do), I moved the myApp.jar to the class folder, and I unpacked it. Now, the RPC calls work!!!

My web.xml file for the app is 100% correct as far as I can see. I also thought that web apps needed a context snippet so that the web app server could intialize them.
For example, under Tomcat 6.0 running in stand-alone mode, they go in the

%CATALINA_HOME%\conf\Catalina\localhost

folder.

It would be nice if one of the Designer folks would explain what I'm missing here. :-)

How can one manually override the way that Designer automatically creates the build.xml file when one deploys a module?
For example, what if I don't want the application classes packed as a JAR and deployed to the WEB-INF\lib folder? How do I keep Designer from overwriting the changes that I make to the build.xml file?

Cheers,
Jason
jcmorris-mts
 
Posts: 25
Joined: Wed Feb 06, 2008 12:16 pm

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby jcmorris-mts » Wed Feb 20, 2008 3:14 pm

Hey Peter... thanks for your suggestions... I think I finally figured it out. I had a typo in the interface that extended RemoteService -- I was calling the wrong class in the setServiceEntryPoint() method :-P

BTW I re-implemented the event handler with the Util class, and you're right.. that is the correct way of doing it. Now, the standard deployment works without any fiddling.

Code: Select all
private SampleServiceAsync serviceProxy = SampleService.Util.getInstance();


Thanks again!

Cheers,
Jason
jcmorris-mts
 
Posts: 25
Joined: Wed Feb 06, 2008 12:16 pm

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Eric Clayberg » Wed Feb 20, 2008 5:21 pm

jcmorris-mts wrote:How can one manually override the way that Designer automatically creates the build.xml file when one deploys a module?

GWT Designer does not care how you deploy your application. It offers several options as a convenience, but you are under no obligation to use any of them.

You can:

1) Use the simple Deploy Module command as-is (this creates a reusable build.xml file).

2) Use the Deploy Module command to create an initial build.xml file and then customize it to do anything that you want. We generate an Ant script (rather than doing all the wrok internally) for exactly this purpose.

3) For complete control, use a Web project to deploy your module. You can then do pretty much anything you want.

In general, questions about how to deploy GWT apps are best posted to Google's GWT forum. We won't pretend to be experts in using any of the major web servers. That isn't our business.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Patrick » Thu Jan 01, 2009 8:45 am

Hi all,
I encountered the same problem with Jason.
- works fine in hosted mode,
- works fine in FireFox after being deployed in Tomcat6,
- doesn't work in IE6, the Window.alerts output nothing in onFailure method or onSuccess, while the servlet ***Impl does do the process!

My experimental application is to reverse a string, e.g. "123" received by the html, and use rpc to send it to backend servlet ***Impl, backend servlet reverse "123" to "321"(and it really works) and send it back through the async callback object, but the client side html's onFailure or onSuccess does nothing when I use IE6. :(

From GWT1.53 and GWT Designer 5.1, I know they definitely support IE6+ and other browsers, but I do not have any clue to the phenomenon I encountered. Please help!

Thanks in advance!

Patrick

pathuang68@163.com
Patrick
 
Posts: 3
Joined: Thu Jan 01, 2009 8:18 am

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Eric Clayberg » Thu Jan 01, 2009 11:19 am

No idea.

In general, questions about GWT itself are better directed to Google's GWT forum.

This forum is for support of GWT Designer features & functions, not for GWT itself.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Patrick » Thu Jan 01, 2009 9:16 pm

Thanks for Eric's quick response.
You are right, I might as well try google's GWT forum.

Patrick
Patrick
 
Posts: 3
Joined: Thu Jan 01, 2009 8:18 am

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Patrick » Sat Jan 03, 2009 2:47 am

Hi Eric,
After tried by any means I could think of, I decided to downgrade GWT 1.5.3 to GWT 1.4.62. Still togehter with GWT Designer 5.1/Eclipse3.4/Tomcat6.0/JDK1.6u10, and this time the simplest RPC ajax application finally simultaneously works in:
- Hosted Mode
- FireFox3.0.5
- IE6.

I am not sure if this is a bug of GWT 1.5.3. Anyway, hope this will help others!

Patrick
Patrick
 
Posts: 3
Joined: Thu Jan 01, 2009 8:18 am

Re: RPC Call Works in Hosted Mode But Not in Web Mode

Postby Eric Clayberg » Sat Jan 03, 2009 7:16 am

Interesting. Thanks for the info.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests