チュートリアルの例をGAEで動作させるのに問題があります。AppEngineログによると:
"GET /contacts/123 HTTP/1.1" 404 598 - "Restlet-Framework/2.1snapshot,gzip(gfe)"
javax.servlet.ServletContext log: ContactRestlet: [Restlet] Attaching application: com.sem.server.rest.ContactApp@1bbc779 to URI: /contacts/123
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
アンドロイドクライアントからもブラウザからもアクセスできません。どんな助けでも大歓迎です!
次のようにweb.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<context-param>
<param-name>org.restlet.clients</param-name>
<param-value>CLAP FILE</param-value>
</context-param>
<servlet>
<servlet-name>PoiServiceImpl</servlet-name>
<servlet-class>com.sem.server.PoiServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>PoiRestlet</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.application</param-name>
<param-value>com.sem.server.rest.PoiApp</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>ContactRestlet</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.application</param-name>
<param-value>com.sem.server.rest.ContactApp</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>CatRestlet</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.application</param-name>
<param-value>com.sem.server.rest.CatApp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>PoiServiceImpl</servlet-name>
<url-pattern>/sem10/PoiService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PoiRestlet</servlet-name>
<url-pattern>/poi</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ContactRestlet</servlet-name>
<url-pattern>/contacts/123</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CatRestlet</servlet-name>
<url-pattern>/cat</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Sem10.html</welcome-file>
</welcome-file-list>
</web-app>
ContactApp
import java.io.File;
import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Restlet;
import org.restlet.data.LocalReference;
import org.restlet.data.Protocol;
import org.restlet.resource.Directory;
import org.restlet.routing.Router;
public class ContactApp extends Application {
/**
* When launched as a standalone application.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getClients().add(Protocol.FILE);
component.getServers().add(Protocol.HTTP, 8080);
component.getDefaultHost().attach(new ContactApp());
component.start();
}
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
getConnectorService().getClientProtocols().add(Protocol.FILE);
// Serve the files generated by the GWT compilation step.
File warDir = new File("");
if (!"war".equals(warDir.getName())) {
warDir = new File(warDir, "war/");
}
Directory dir = new Directory(getContext(), LocalReference
.createFileReference(warDir));
router.attachDefault(dir);
router.attach("/contacts/123", ContactServResource.class);
return router;
}
}