The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

PayamFard (23) [Avatar] Offline
#1
Hi all,

I have developed a GWT application. It works fine in hosted mode. When
I deploy it as a war file under JBoss, it does not quite work!

The first panel under my app, namely AssociationView.html, makes some RPC calls to populate the widgets on the screens. When I am in hosted mode, everything works fine.

When I access http://localhost/myApp/www/IncidentAssociationView.html
url in a non-hosted mode, I get the panel up, but apparently the RPC
calls are not executed since my widgets do not get populated. What could I possibly be doing wrong?

Here is my file structure once war file is deployed. My RPC servlet is under gwtView.server package. For some reason, I do not get any exceptions.

Any help regarding this would be greatly appreciated.

adapter.war includes the following:

META-INF
WEB-INF
classes
gwtView
client
common
server
adapter
lib
gwt-user.jar
web.xml
www
AssociationView.html
....html
.....js
....
robert.hanson (173) [Avatar] Offline
#2
Re: How to start the GWT web application in non-hosted mode?
My first suggestion is to revisit the steps provided in section 16.2. You should also check your server logs to verify that the server is being hit, and also to verify that it is hitting the right URL. If you see a 200 HTTP message in the logs, then the problem is with the client app. If you see a 404 the problem is with your mappings. And if you see a 500 the problem is with your server code, and the server logs should have more info on the cause.
PayamFard (23) [Avatar] Offline
#3
Re: How to start the GWT web application in non-hosted mode?
Thanks for your reply. I have looked at section 16.2. I believe everything looks good, but I have looked at this problem for too long now. I could not spot anything related to this in the server log. I also do not get 200, 404, or 500. What happens is that everything works fine in the hosted mode. When I deploy, I get the html up with all the widgets, but the widgets that are supposed to be populated through the rpc mechanism are not. I strongly believe at this point that my servlet mapping is somehow incorrect, but I have tried lots of different things and nothing seems to be able to fix my problem. I was hoping if you could please take a look at the following and see whether I am doing anything wrong.

My web.xml has:

<servlet>
<servlet-name>AssociationServlet</servlet-name>
<servlet-class>gwtView.server.AssociationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AssociationServlet</servlet-name>
<url-pattern>/www/gwtView.test/AssociationServlet</url-pattern>
</servlet-mapping>

My test.gwt.xml has:

<servlet path="/AssociationServlet" >
class="gwtView.server.AssociationServlet" />


This is how I am setting the url for the service inside my Java file:

IncidentAssociationsServiceAsync getIncidentAssociationsService =
(IncidentAssociationsServiceAsync) GWT.create(IncidentAssociationsService.class);
ServiceDefTarget target = (ServiceDefTarget) getIncidentAssociationsService;
String relativeUrl = GWT.getModuleBaseURL() + "/AssociationServlet";
target.setServiceEntryPoint(relativeUrl);

And finally this is my directory structure:

WEB-INF
....src
........gwtView
............test.gwt.xml
............client
................IncidentAssociationsService.java
................IncidentAssociationsServiceAsync.java
................IncidentAssociationView.java
............server
.................AssociationServlet.java
............public
................IncidentAssociationView.html
www
.....gwtView.test
....cache.js
....css
....
robert.hanson (173) [Avatar] Offline
#4
Re: How to start the GWT web application in non-hosted mode?
You problem I think is here:

String relativeUrl = GWT.getModuleBaseURL() + "/AssociationServlet";

The getModuleBaseURL returns the URL to the directory where the cache.js file is stored, which in your case is "www/".

> <url-pattern>/www/gwtView.test/AssociationServlet</url-pattern>

So the URL pattern should be this:

<url-pattern>/www/AssociationServlet</url-pattern>

BTW - If your server isn't logging access information you can always fall back on the FireBug plug-in for Firefox. It is robably the most valuable web development tool that I know of. Among other things it will show you all of your XHR traffic, so you will be able to see the contents of RPC calls and the reply.
adam.tacy (269) [Avatar] Offline
#5
Re: How to start the GWT web application in non-hosted mode?
I wonder if you are also getting an extra / which JBoss isn't liking, i.e

String relativeUrl = GWT.getModuleBaseURL() + "/AssociationServlet";

will return:

www//AssociationServlet

which JBoss may be choking upon as it is not

www/AssociationServlet

Or, does your AssociationServlet have any dependent libraries that you have not placed on the classpath (and therefore it has not started?).

//Adam
PayamFard (23) [Avatar] Offline
#6
Re: How to start the GWT web application in non-hosted mode?
Thanks for your replies. I forgot to include my deployment directory structure. Here it is:

gwtView
WEB-INF
....web.xml
....classes
.........gwtView
................client
.........................IncidentAssociationView.clas
.........................IncidentAssociationService.class
.........................IncidentAssociationServiceAsync.class
................common
................server
.........................AssociationServlet.class
.........webeocAdapter
....lib
www
....gwt.rpc
....cache.html
....cache.js
....cache.xml
....IncidentAssociationView.html
....js
....css

You are correct. My html (IncidentAssociationView.html) was not getting
copied to the correct location so I changed my web.xml to look like:

<servlet>
<servlet-name>AssociationServlet</servlet-name>
<servlet-class>gwtView.server.AssociationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AssociationServlet</servlet-name>
<url-pattern>/www/AssociationServlet</url-pattern>
</servlet-mapping>


I also removed the extra / from my:

String relativeUrl = GWT.getModuleBaseURL() + "AssociationServlet";

Everything else is the same. You are also correct about getting the
message GET not being supported when I access:

http://payam-pc/eoc-web-adapter/www/AssociationServlet

Now, with the above changes, when I still access my html using path:

http://payam-pc/eoc-web-adapter/www/IncidentAssociationView.html

I get the panel up but my widgets are still not populated! What else
am I doing wrong?

Thanks again.
PayamFard (23) [Avatar] Offline
#7
Re: How to start the GWT web application in non-hosted mode?
This is the error message I am getting back when using FireBug. Not sure how I can fix my mapping though to resolve this. Any thoughts?

HTTP Status 404 - /eoc-web-adapter/www/IncidentAssociationService

</h1>

type Status report

message /eoc-web-adapter

/www/IncidentAssociationService

description The requested resource (/eoc-web-adapter

/www/IncidentAssociationService) is not available.


<h3>JBossWeb

/2.0.1.GA</h3></body></html>
robert.hanson (173) [Avatar] Offline
#8
Re: How to start the GWT web application in non-hosted mode?
FireBug is showing you exactly what the problem is.

Your app is trying to get to this URL:
/eoc-web-adapter/www/IncidentAssociationService

But your mapping has this:
<url-pattern>/www/AssociationServlet</url-pattern>

You need to create a mapping to /www/IncidentAssociationService.
PayamFard (23) [Avatar] Offline
#9
Re: How to start the GWT web application in non-hosted mode?
Thank you very much Robert. I am still not sure why my code is trying to get to the following URL:

/eoc-web-adapter/www/IncidentAssociationService

But, with this knowledge and by changing my mapping to:

<servlet>
<servlet-name>IncidentAssociationService</servlet-name>
<servlet-class>gwtView.server.AssociationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>IncidentAssociationService</servlet-name>
<url-pattern>/www/IncidentAssociationService</url-pattern>
</servlet-mapping>

and by changing the relative url to:

String relativeUrl = GWT.getModuleBaseURL() + "IncidentAssociationService";

My code works fine now. I guess GWT internally causes the url /eoc-web-adapter/www/IncidentAssociationService to be called.

Thanks a million for all your help. Your suggestion greatly helped me.

Best,
Payam
PayamFard (23) [Avatar] Offline
#10
Re: How to start the GWT web application in non-hosted mode?
Well, now I have the opposite problem. Everything works fine in my deployment environment, but my development environment (hosted mode) does not work anymore!!!

This is the error message I am getting:

The development shell servlet received a request for 'IncidentAssociationService' in module 'gwtView.test'

I tried replacing the web.xml that is under comes with the embedded tomcat (tomcatwebappsROOTWEB-INFweb.xml) to my web.xml noted above for my production environment, but that did not fix anything. I got the same exact error!

What do I need to do now such that both environments work fine?

Thanks again,
Payam
robert.hanson (173) [Avatar] Offline
#11
Re: How to start the GWT web application in non-hosted mode?
My guess is that the <servlet> tag in your module config (*.gwt.xml) file doesn't have the right servlet name. You need to take a look at both the module config and your production deployment config to verify that the path names all matche.
PayamFard (23) [Avatar] Offline
#12
Re: How to start the GWT web application in non-hosted mode?
Thanks Robert for your reply. If my .gwt.xml file did not have the right servlet name, shouldn't my deployment environment should be broken as well since it is shared between the two environments. The only other thing I found different was the web.xml file. I completely replaced the web.xml file that tomcat generates with the one I am using in production, but that did not fix the problem.

Anything else is different with regards to the two environments (hosted vs production) that might be related to the problem I am experiencing?
robert.hanson (173) [Avatar] Offline
#13
Re: How to start the GWT web application in non-hosted mode?
The *.gwt.xml file is only used in development, it isn't even needed in the production environment.
PayamFard (23) [Avatar] Offline
#14
Re: How to start the GWT web application in non-hosted mode?
Thanks for all your help. Both environments are working fine now.

Thanks again,
Payam
sexci12 (1) [Avatar] Offline
#15
Re: How to start the GWT web application in non-hosted mode?
hi im new 2 dis