I want to host a simple rest server on an android phone to get remote access to some data. I followed the descriptions on the restlet website but I cant even get a simple example running.
I downloaded the android restlet package and added the org.restlet.jar as dependency.
In my onCreate
method of the activity I have added these lines to start a simple server component.
Component serverComponent = new Component();
serverComponent.getServers().add(Protocol.HTTP, 80);
final Router router = new Router(serverComponent.getContext().createChildContext());
router.attach("/gamedata", GameDataResourceServer.class);
serverComponent.getDefaultHost().attach(router);
serverComponent.start();
The last call throws an Exception:
05-20 11:06:14.040 29947-29947/com.example.restserver E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.restserver, PID: 29947 java.lang.NoClassDefFoundError: com.sun.net.httpserver.HttpServer at org.restlet.engine.connector.HttpServerHelper.start(HttpServerHelper.java:68) ...
Why does the restlet framework tries to use the httpserver from java. This in not part of the android framework as I think.
P.S.: I figured out, that this issue only appears since restlet 2.2. The 2.1 branch works for me.