Привет, я новичок в рестлете. Я просто создаю свое первое приложение, но получаю сообщение об ошибке:
HTTP ОШИБКА 404
Проблема с доступом / hellofourthtrial / привет. Причина: NOT_FOUND
Мой код выглядит следующим образом:
HelloWorldResource.java
package hellofourthtrial;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class HelloWorldResource extends ServerResource{
@Get
public String represent() {
return "in the represent";
}
}
FirstStepsApplication.java
package hellofourthtrial;
import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.data.Protocol;
import org.restlet.routing.Router;
import org.restlet.Server;
public class FirstStepsApplication extends Application{
/**
* Creates a root Restlet that will receive all incoming calls.
*/
@Override
public synchronized Restlet createInboundRoot() {
// Create a router Restlet that routes each call to a
// new instance of HelloWorldResource.
Router router = new Router(getContext());
// Defines only one route
router.attach("/hello", HelloWorldResource.class);
return router;
}
public static void main(String[] args) {
try {
Server server = new Server(Protocol.HTTP, 8888);
server.setNext(new FirstStepsApplication());
server.start();
System.out.println("Press a key to stop");
System.in.read();
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
web.xml
<context-param>
<param-name>org.restlet.application</param-name>
<param-value>
hellofourthtrial.FirstStepsApplication
</param-value>
</context-param>
<servlet>
<servlet-name>RestletServlet</servlet-name>
<servlet-class>
org.restlet.ext.servlet.ServerServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RestletServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Я разработал этот проект в Eclipse и запускаю его как веб-приложение. Когда я запускаю его как веб-приложение, я получаю следующий вывод в консоли
May 12, 2011 11:22:23 AM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
May 12, 2011 11:22:23 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Users\Admin\workspace2\HelloFourthTrial\war\WEB-INF/appengine-web.xml
May 12, 2011 11:22:23 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Users\Admin\workspace2\HelloFourthTrial\war\WEB-INF/web.xml
May 12, 2011 4:52:24 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at http://localhost:8888/
Я действительно застрял, я не могу понять, где я иду не так. Любая помощь будет высоко ценится