2

I am trying to run a sample program from the book: "Google App Engine Java and GWT Application Development Code."

The program called connactr.

The program is using the imports: com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url com.google.appengine.api.labs.taskqueue.Queue

That do not exist anymore, so I changed them to: com.google.appengine.api.taskqueue.TaskOptions.Builder.withurl com.google.appengine.api.taskqueue.*

I also change the code:

Queue queue = QueueFactory.getDefaultQueue();
      queue.add(url("/updatefeedurls").payload(data,
        "application/x-java-serialized-object"));

to:

Queue queue = QueueFactory.getDefaultQueue();
      queue.add(withUrl("/updatefeedurls").payload(data,
        "application/x-java-serialized-object"));

I made these kind of changes everywhere I had the old methods. I was able to run the application, with no errors, but for every page I receive error 404, page not found.

I assume that the withurl() method has different logic that causes the error 404, but I wasn't able to find what I should do to fix it.

What should I change in order to make this work?

Here is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee       
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"   
id="WebApp_ID"
version="2.5">


<!-- ===================== friendsService ===================== -->
<servlet>
<servlet-name>friendsService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.FriendsServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>friendsService</servlet-name>
<url-pattern>/connectr/friendsService</url-pattern>
</servlet-mapping>

<!-- ===================== messagesService ===================== -->
<servlet>
<servlet-name>messagesService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.MessagesServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>messagesService</servlet-name>
<url-pattern>/connectr/messagesService</url-pattern>
</servlet-mapping>

<!-- ===================== Login Service ===================== -->
<servlet>
<servlet-name>loginService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.LoginServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>loginService</servlet-name>
<url-pattern>/connectr/loginService</url-pattern>
</servlet-mapping>


<!-- ===================== Login Google Servlet ===================== -->

<servlet>
<servlet-name>logingoogle</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginGoogleServlet</servlet-  
class>
 </servlet>

<servlet-mapping>
<servlet-name>logingoogle</servlet-name>
<url-pattern>/logingoogle</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>logingooglecallback</servlet-name>
<servlet-  
class>com.metadot.book.connectr.server.servlets.LoginGoogleCallbackServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>logingooglecallback</servlet-name>
<url-pattern>/logingooglecallback</url-pattern>
 </servlet-mapping>

<!-- ===================== Login Twitter Servlet ===================== -->

<servlet>
<servlet-name>logintwitter</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginTwitterServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>logintwitter</servlet-name>
<url-pattern>/logintwitter</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>logintwittercallback</servlet-name>
<servlet- 
class>com.metadot.book.connectr.server.servlets.LoginTwitterCallbackServlet</servlet-    
Class>
</servlet>

<servlet-mapping>
<servlet-name>logintwittercallback</servlet-name>
<url-pattern>/logintwittercallback</url-pattern>
</servlet-mapping>

 <!-- ===================== Login Facebook Servlet ===================== -->

<servlet>
<servlet-name>loginfacebook</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginFacebookServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>loginfacebook</servlet-name>
<url-pattern>/loginfacebook</url-pattern>
</servlet-mapping>






 </servlet>
 <servlet-mapping>
 <servlet-name>XMPPRequest</servlet-name>
 <url-pattern>/xmpprequest</url-pattern>
 </servlet-mapping>

 <security-constraint>
 <web-resource-collection>
  <url-pattern>/xmpprequest</url-pattern>
 </web-resource-collection>
 <auth-constraint>
  <role-name>admin</role-name>
  </auth-constraint>
 </security-constraint>



<filter-mapping> 
<filter-name>appstats</filter-name> 
 <url-pattern>/*</url-pattern> 
</filter-mapping> 

<servlet>
 <servlet-name>appstats</servlet-name>
  <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class> 
</servlet>
 <servlet-mapping> 
 <servlet-name>appstats</servlet-name>
 <url-pattern>/appstats/*</url-pattern> 
 </servlet-mapping>

 <security-constraint> 
  <web-resource-collection> 
  <url-pattern>/appstats/*</url-pattern> 
  </web-resource-collection> 
  <auth-constraint> 
  <role-name>admin</role-name> 
  </auth-constraint> 
</security-constraint> -->

<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>ConnectrApp.html</welcome-file>
</welcome-file-list>


</web-app>

Thank you in advance, Idan.

4

1 回答 1

0

I am thinking that withUrl requires the entrire Url to work as intended and not the relative location. Fortunately GWT provides with a way to make the entire url in a dynamic way.

Try the TaskOptions getUrl() method. Use Window.alert(url-derived-from-getUrl) and check what the url built with withUrl is.

You can use

GWT.getHostPageBaseUrl();

GWT.getModuleBaseUrl();

to build your url properly inside withUrl(Sting url).

于 2013-01-14T08:56:42.467 回答