The jars as distributed are not "legal" to deploy into tomcat, as they contain the javax.servlet packages. These can't end up in WEB-INF/lib, since that violates the servlet spec (tomcat refuses to load the jars). I have built my own custom version of the user jar that is deployable into tomcat, but it seems like it would be good to a) document this issue and b) distribute a version of the jar which doesn't include the servlet classes in it.
I just suffered from the same issue and this solved it.
I agree that there should at least be a paragraph written in the documentation on how to deploy a simple GWT app on at least a Tomcat server (for testing).
Only thing to solve in my case now is that client side does not make server-calls yet, but I'm not sure what may be causing this.
This is probably due to the server path issue. First the Entry point must be set to a valid url. For example, calendar example SchoolCalendarWidget may be modified to say
ServiceDefTarget target = (ServiceDefTarget) calService; String staticResponseURL = GWT.getModuleBaseURL(); staticResponseURL += "/calendar"; target.setServiceEntryPoint(staticResponseURL); and the servlet must be mapped to URL /calendar (or whatever you specified in entry point) in web.xml.
Remember that the XXXServiceImpl class (e.g SchoolCalendarServiceImpl) actually extends a Servlet class. So somthing like this will go in web.xml
Well looking closely calendar service example gives you an option to turn off static behaviour change private final static boolean USE_STATIC_RPC_ANSWERS = true; to private final static boolean USE_STATIC_RPC_ANSWERS = false; in SchoolCalendarWidget recompile the SchoolCalendarWidget into java class (not same as GWT Compile which emits the javascript etc) Deploy the servlet as I mentioned in previous post and test
1. Strip the javax.* packages from gwt-user.jar . You can do it with winzip/winrar etc. Open the jar in such tools and delete all files in javax folder including the folder
2. Copy the stripped jar in your webapps/YourApp/WEB-INF/lib. Copy the compiled classes (e.g copy the folder "com" in samples/dynatable/bin ) to webapps/YourApp/WEB-INF/classes
3. Modify your Service Entry point code (if required). Note the text you put in place /calendar line. You will use this text in web.xml later ServiceDefTarget target = (ServiceDefTarget) calService; String staticResponseURL = GWT.getModuleBaseURL(); staticResponseURL += "/YourApp/calendar"; target.setServiceEntryPoint(staticResponseURL); 4. Run DynaTable-compile.cmd (replace dynatable with app name). File will be generated in www\com.google.gwt.sample.dynatable.DynaTable\ . Copy all files within this folder to webapps/YourApp/
5. Create modify web.xml and place it in WEB-INF <?xml version="1.0" encoding="UTF-8"?> <web-app>
HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Wrapper cannot find servlet class com.google.gwt.dev.shell.GWTShellServlet or a class it depends on org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10 5) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.process Connection(Http11BaseProtocol.java:664) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.ja va:527) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerW orkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja va:684) java.lang.Thread.run(Unknown Source)
= Create and copy gwt-dev-windows-minus-javax-servlet.jar to {tomcat}\webapps\DynaTable\WEB-INF\lib
Browser: "Unable to find/load module 'DynaTable.html' (see server log for details)"
Tomcat console: - #0 The server received a request to generate a host page for module 'DynaTable.html' - #0.0 Loading module 'DynaTable.html' - #0.0.0 Unable to find 'DynaTable/html.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
--- FYI, here's console output from a typical startup of Tomcat: - The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java .library.path: D:\dev\Tomcat5.5\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\system32;C :\WINDOWS;C:\WINDOWS\System32\ Wbem;D:\dev\jwsdp20\jwsdp-shared\bin;c:\mobius\Mobius-1.8.0\bin;C:\bin;D:\d ev\bin;D:\dev\cygwin\bin;D:\dev\jdk5\bin;C:\P rogram Files\SecureCRT;C:\Program Files\SecureFX;D:\dev\Subversion\bin;D:\dev\MinGW\bin - Initializing Coyote HTTP/1.1 on http-8080 - Initialization processed in 771 ms - Starting service Catalina - Starting Servlet Engine: Apache Tomcat/5.5.16 - XML validation disabled - org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webap p.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balance r.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.y ahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]] - Starting Coyote HTTP/1.1 on http-8080 - JK: ajp13 listening on /0.0.0.0:8009 - Jk running ID=0 time=0/30 config=null - Find registry server-registry.xml at classpath resource - Server startup in 3555 ms
D:\dev\gwt-windows-1.0.20\samples\DynaTable\tomcat\webapps\ROOT\WEB-INF\web .xml to {tomcat}\webapps\DynaTable\WEB-INF\
Try creating a new web.xml with contents i provided in my previous post. Following is also *not* needed = Create and copy gwt-dev-windows-minus-javax-servlet.jar to {tomcat}\webapps\DynaTable\WEB-INF\lib
Not sure what you mean by hot-deployable. What I (and other folks on this thread) wanted to do was: Let a GWT app make rpc calls to our servlets deployed on a tomcat instance.
Agreed that GWT uses Tomcat itself in shell mode, but for a different purpose IMO. It deploys a standard GWT shell servlet that serves you your pages generated from java source in Shell browser. You can get a better understanding of this by looking at the web.xml within tomcat folder inside of GWT app folder.
I will post back after I have completely figured out the process :).
On 5/19/06, Dave Patterson <davpa...@hotmail.com> wrote:
Are you trying to test your RPC calls in hosted mode (running the GWTShell)? If so, do you need really Tomcat to launch GWTShell?
If you are trying to test the compiled code in an ordinary browser then you should be able to run the compile outside tomcat and copy (or 'hot deploy') the generated files into your web-app's root directory.
Yes I would like to do that: test my RPC calls in hosted mode (running the GWTShell), but * I figure that I wont be able do that with a separate tomcat instance as there is no straight-forward way IF hosted mode browser honours the usual browser security pertaining to cross domain calls. I haven't tried that yet. * Another way is to tweak the generated web.xml. I hope it won't be rocket science but got no time at my hand at the moment to give it a try.
Currently doing the rpc test in separate browser. Yes the copy to tomcat works and we discussed in this thread what to copy where within the tomcat. But you still need to come up with servlet mappings in web.xml. We discussed that too.
Hope that helps Regards Tahir Akhtar
On 5/19/06, Dave Patterson <davpa...@hotmail.com> wrote:
> Are you trying to test your RPC calls in hosted mode (running the > GWTShell)? If so, do you need really Tomcat to launch GWTShell?
> If you are trying to test the compiled code in an ordinary browser then > you should be able to run the compile outside tomcat and copy (or 'hot > deploy') the generated files into your web-app's root directory.
Acutally the whole rpc mechanism provided by GWT depends on server.rpcpackage in the gwt-user.jar.
You *must* use it if you do not want to write custom method for rpc. If you want to use something else, JSON could be an option as it has support for most platforms/langs like ASP, PHP etc.
Well, finally found what I was missing from the beginning: Testing rpc services from withing the GWTShell
We can add servlet declarations (think of it as definition + url mapping in one line) in app.gwt.xml. And the embedded tomcat in shell will load and map the servlet at the specified url.
So we will only have to do all the tomcat deployment stuff just for final testing.
The servlet is already mapped for DynaTable example, see
--DynaTable.gwt.xml <module> <inherits name='com.google.gwt.user.User'/> <entry-point class='com.google.gwt.sample.dynatable.client.DynaTable'/> <servlet path='/calendar' class=' com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl'/> </module> All you have to do is to enable the calls in SchoolCalendarWidget private final static boolean USE_STATIC_RPC_ANSWERS = false; And ensure that entry point is set according to above mapping public CalendarProvider() ... target.setServiceEntryPoint("/calendar");
I did the same way you mention to invoke the RPC. I can't able to polulate the table in DynaTable.html.
Failed to access data: <html><head><title>Apache Tomcat/5.0.28 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;f ont-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;f ont-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;f ont-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size :12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /samples/DynaTable/samples/calendar</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/samples/DynaTable/samples/calendar</u></p><p><b>description</b> <u>The requested resource (/samples/DynaTable/samples/calendar) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.0.28</h3></body></html>
I think i am unable to get data from the server SchoolCalendarServiceImpl.java.
one more issue. When i tried to call "DynaTable-compile.cmd", it is not creating classes in bin folder. So i think i have to compile SchoolCalendarServiceImpl.java separately and copy to WEB-INF/classes
I have a suggestion to you. Can you do a HelloWorld sample RPC program with step by step. It will help all the developers to begin this GWT use. I will really appreciate if you can do that for all developers.
Tahir Akhtar wrote: > Well, finally found what I was missing from the beginning: Testing rpc > services from withing the GWTShell
> We can add servlet declarations (think of it as definition + url mapping in > one line) in app.gwt.xml. And the embedded tomcat in shell will load and map > the servlet at the specified url.
> So we will only have to do all the tomcat deployment stuff just for final > testing.
> The servlet is already mapped for DynaTable example, see
> --DynaTable.gwt.xml > <module> > <inherits name='com.google.gwt.user.User'/> > <entry-point class='com.google.gwt.sample.dynatable.client.DynaTable'/> > <servlet path='/calendar' class=' > com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl'/> > </module> > All you have to do is to enable the calls in SchoolCalendarWidget > private final static boolean USE_STATIC_RPC_ANSWERS = false; > And ensure that entry point is set according to above mapping > public CalendarProvider() > ... > target.setServiceEntryPoint("/calendar");
> Well, finally found what I was missing from the beginning: Testing rpc services from withing the GWTShell<br><br>We can add servlet declarations (think of it as definition + url mapping in one line) in app.gwt.xml. And the embedded tomcat in shell will load and map the servlet at the specified url. > <br><br>So we will only have to do all the tomcat deployment stuff just for final testing.<br><br><br>The servlet is already mapped for DynaTable example, see<br><br>--DynaTable.gwt.xml<br><module><br> <inherits name=' > com.google.gwt.user.User'/><br> <entry-point class='com.google.gwt.sample.dynatable.client.DynaTable'/><br> &nbs p; <servlet path='/calendar' class='com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl > '/><br></module><br>All you have to do is to enable the calls in SchoolCalendarWidget<br> private final static boolean USE_STATIC_RPC_ANSWERS = false;<br>And ensure that entry point is set according to above mapping > <br>public CalendarProvider()<br>...<br>target.setServiceEntryPoint("/calendar&qu ot;);<br><br>See docs for more details<br><br>
Hi Manu, You have hit the common confusion point :) Welcome to the club.
Actually the compile.cmd is *not* for compiling java to byte code. Instead it translates java *source code* to javascript.
Whenever you change a java file that is supposed to be translated to java script *and* you want to view it in normal browser you must use the compile.cmd and then open the generated html from www folder.
But if you have changed some server side stuff like service impl then you may have to recompile the to java .class using javac. (I suspect that GWT have some built in way to trigger javac compile when you launch shell mode, but I have to confirm that)
Now back to your original issue, the RPC call.
The error you are getting means that the servlet is not mapped to /samples/DynaTable/samples/calendar but your translated javascript is trying to find it at this location. You can fix either the servlet mapping or change the entry point like target.setServiceEntryPoint("whereever/the/servlet/is/mapped");
For the Hello World program you have suggested, I would try to do a write-up on running the Calendar example (If I get the weekend off :( ) . I think for learning purpose, it is better to stick with the App.gwt.xml method coupled with shell mode.
I really appreciate for your fast response. I changed the mapping for the servlet and able to resolve the issue happened last time. But still getting message failed to access data. Rest of the classes are same with no change.
I have copied DynaTable to C:\appl\Tomcat 5.0\webapps\samples\DynaTable\
My Web.xml have <servlet> <servlet-name>SchoolCalendarService</servlet-name>
ServiceDefTarget target = (ServiceDefTarget) calService; String staticResponseURL = GWT.getModuleBaseURL(); staticResponseURL += "/calendar"; target.setServiceEntryPoint(staticResponseURL); } *************************************************************************** ********************************************************* But still calService.getPeople(), goes to onFailure() and i am getting "Failed to access data" in Navbar. So i hope that i am able to get in the server class, but the issue is because of data. Any idea about this issue?
calService.getPeople(startRow, maxRows, new AsyncCallback() { public void onFailure(Throwable caught) { acceptor.failed(caught); }
I am able to solve the issue and able to launch the sample. I will try to do a sample HelloWorld Service tomorrow, with all the steps to follow. So others can use it to save time with for simple RPC.