Just thought I'd mention it.
Thanks,
John
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.
Cheers,
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
<servlet>
<servlet-name>SchoolCalendarService</servlet-name>
<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SchoolCalendarService</servlet-name>
<url-pattern>/calendar</url-pattern>
</servlet-mapping>
Well, thats the theory but I have to get it to work before I can say
with surety.
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>
<servlet>
<servlet-name>SchoolCalendarService</servlet-name>
<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SchoolCalendarService</servlet-name>
<url-pattern>/calendar</url-pattern>
</servlet-mapping>
</web-app>
5. Launch tomcat. Open browser e.g.
localhost:8080/YourApp/DynaTable.html
6. Enjoy
I followed you step by step and successfully configured my web app.
This is great.
Thanks. :)
= Create folders:
{tomcat}\webapps\DynaTable
{tomcat}\webapps\DynaTable\WEB-INF
{tomcat}\webapps\DynaTable\WEB-INF\lib
{tomcat}\webapps\DynaTable\WEB-INF\classes
= Copy contents of
gwt-windows-1.0.20\samples\DynaTable\www\com.google.gwt.sample.dynatable.DynaTable
to
{tomcat}\webapps\DynaTable
= Copy
gwt-user-minus-javax.jar
to
{tomcat}\webapps\DynaTable\WEB-INF\lib
= Copy
gwt-windows-1.0.20\samples\DynaTable\bin\com
to
{tomcat}\webapps\DynaTable\WEB-INF\classes
(creating {tomcat}\webapps\DynaTable\WEB-INF\classes\com\google\{etc})
- Test #1: browse http://localhost:8080/DynaTable/
HTTP Status 404 - /DynaTable/
type Status report
message /DynaTable/
description The requested resource (/DynaTable/) is not available.
= Copy
D:\dev\gwt-windows-1.0.20\samples\DynaTable\tomcat\webapps\ROOT\WEB-INF\web.xml
to
{tomcat}\webapps\DynaTable\WEB-INF\
? Test #2: browse http://localhost:8080/DynaTable/
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:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Unknown Source)
= Create and copy
gwt-dev-windows-minus-javax-servlet.jar
to
{tomcat}\webapps\DynaTable\WEB-INF\lib
? Test #3: browse http://localhost:8080/DynaTable/
Browser:
"To launch an an application, specify a URL of the form
/module/file.html"
Tomcat console:
(nothing)
- Test #4: (browse http://localhost:8080/DynaTable/DynaTable.html)
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:\dev\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
Thanks for any help or ideas!
- rob
javax.servlet.ServletException: Wrapper cannot find servlet class
com.google.gwt.dev.shell.GWTShellServlet or a class it depends on
exception.
- rob
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
Thanks, now I'm off to try coding my own first app.... :)
- rob
Aren't all the generated products are hot-deployable?
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.
Dave P.
Sounds like the server-side RPC code is a candidate for a seperate
deployable JAR as per your stripped copy.
Sorry for being so slow :(
Dave P.
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;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-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.
> ------=_Part_36005_26966217.1148056931395
> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
> X-Google-AttachSize: 1204
>
> 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> <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");<br><br>See docs for more details<br><br>
>
> ------=_Part_36005_26966217.1148056931395--
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.
Regards
Tahir Akhtar
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>
<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SchoolCalendarService</servlet-name>
<url-pattern>/DynaTable/calendar</url-pattern>
</servlet-mapping>
I have copied the server and client classes to
C:\appl\Tomcat 5.0\webapps\samples\DynaTable\WEB-INF\classes\
I have changed SchoolCalendarWidget.java
if (USE_STATIC_RPC_ANSWERS) {
/* Org Implementation */
//ServiceDefTarget target = (ServiceDefTarget) calService;
//String staticResponseURL = GWT.getModuleBaseURL();
//staticResponseURL += "/calendar" + startRow + ".txt";
//target.setServiceEntryPoint(staticResponseURL);
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);
}
public void onSuccess(Object result) {
Person[] people = (Person[]) result;
lastStartRow = startRow;
lastMaxRows = maxRows;
lastPeople = people;
pushResults(acceptor, startRow, people);
}
});
1) I have copied DynaTable to
C:\appl\Tomcat 5.0\webapps\samples\DynaTable\
2) My Web.xml have
<servlet>
<servlet-name>SchoolCalendarService</servlet-name>
<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SchoolCalendarService</servlet-name>
<url-pattern>/DynaTable/calendar</url-pattern>
</servlet-mapping>
3) I have copied the server and client classes to
C:\appl\Tomcat 5.0\webapps\samples\DynaTable\WEB-INF\classes\
4) I have changed SchoolCalendarWidget.java to
ServiceDefTarget target = (ServiceDefTarget) calService;
String staticResponseURL = GWT.getModuleBaseURL();
staticResponseURL += "/calendar";
target.setServiceEntryPoint(staticResponseURL);
5) <Context path="/samples" docBase="samples" debug="0"
privileged="true"></Context>
I got the following error "HTTP Status 404 -
/samples/DynaTable/calendar"
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;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-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/DynaTable/calendar</h1><HR size="1"
noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
<u>/samples/DynaTable/DynaTable/calendar</u></p><p><b>description</b>
<u>The requested resource (/samples/DynaTable/DynaTable/calendar) is
not available.</u></p><HR size="1" noshade="noshade"><h3>Apache
Tomcat/5.0.28</h3></body></html>
Can you help me to figure out, what is wrong in the entire flow, why i
can't get the Server classes the web.xml
Thanks for help.
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.
-Binesh
I think when the app is tested, it always copies to ROOT.war, never to
a specific module directory, I think this is when the whole deployment
gets so terribly confusing for a real deploy.
I'm doing the following:
The "module.xml" needs to have the exact path as well, including the
app folder as it seems:
<module>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Specify the app entry point class. -->
<entry-point class='path.to.your.App'/>
<servlet path='/YourApp/customer'
class='path.to.your.CustomerServiceImpl'/>
</module>
Then the rest as has already been described in web.xml:
<servlet>
<servlet-name>CustomerService</servlet-name>
<servlet-class>path.to.your.CustomerServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CustomerService</servlet-name>
<url-pattern>/customer</url-pattern> <!-- <-- in web.xml there is no
YourApp -->
</servlet-mapping>
The code in the data provider that goes off to the servlet:
ServiceDefTarget target = (ServiceDefTarget) customerService;
String url = GWT.getModuleBaseURL();
url += "/customer";
target.setServiceEntryPoint(url);
in build.xml for the ant, I am copying the contents of the generated
folder "www/path.to.your.app" into the root of the war file, so that
you do not have to access as "path.to.your.app/Main.html".
Then I'm copying the necessary libs to the WEB-INF/lib folder.
Including the modified gwt-user.jar (removing javax folder). Finally
deploying this on Tomcat should more or less work.
Of course, you could also consider to just copy the contents of various
generated classes directly to the tomcat installation on your computer
in ROOT.war, but that doesn't make your web application really
distributable...
Cheers,
Chiraz
However that works when making the deployment on the tomcat server, but
it doesn't when executing the app into the eclipse-wtp plateform. In
that environment, the servlet don't answer back (the html page remains
empty, with only the title and no table).
Any idea about that bug ?
ServiceDefTarget target = (ServiceDefTarget) service;
String staticResponseURL = GWT.getModuleBaseURL();
if (GWT.isScript())
{
// I guess I'm running on my Tomcat server in web mode
staticResponseURL += "/myService";
} else {
// I have java bytecode, so I guess I'm running on
// Eclipse in Hosted (debug) mode
staticResponseURL = "/myApp/myService";
}
target.setServiceEntryPoint(staticResponseURL);
Anyway, the app name SHOULD be specified into the service
entry point URL into the servlet, just as Chiraz said above.
I still have a bug into Eclipse Web browser, no widgets are displayed,
while it is Ok in Firefox ...
I am sending the Html through the servlet.
This is the error I get
XML tag name mismatch
http://localhost:8080/foo/gwt.js
Here is what I have
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println( "<head>");
out.println( "<meta name='gwt:module'
content='com.foo.Foo'>");
out.println( "<link rel='stylesheet' href='/foo/Mail.css'>");
out.println( "<title>Mail App</title>");
out.println( "</head>");
out.println("<body style='background-color: #EEEEEE'>");
out.println("<script language='javascript'
src='/foo/gwt.js'></script>");
out.println("</body>");
out.println("</html>");
JDK 1.5, Tomcat 5.5.17.
Thanks Tahir,
r-a-v-i