Question

I have been following this tutorial video which shows how to run a jersey server(EDIT: A JAX-RS server via Apache Wink, see accepted answer) in OSGI. It is a short video and the process seems mostly very clear. What I'm not clear on is how exactly the HelloWorldResource is loaded into Jersey. The HelloWorldResource is registered into OSGI container as a service using Apache Felix DependencyActivatorBase (which works great). From what I gather Apache Felix Whiteboard is supposed to somehow magically map that as a Jersey Resource, but when I go to run it I get 404.

I know the service is mapped correctly as it shows up in the console when I issue the 'services' command. I know the server is running or I wouldn't get a 404 not found. I've double checked the bundles and believe all are installed correctly.

Any hints appreciated.

Was it helpful?

Solution

First of all, Amdatu is not based on Jersey. Jersey is one of the many JAX-RS implementations available. Amdatu is based on Apache Wink. This shouldn't really matter to you however, since you should be programming to the standard anyway.

Amdatu looks for services registered as Object.class in the service registry, and checks if the registered service is annotated with the @Path annotation. If this is the case, the service is registered as a JAX-RS resource. This way the development model is very similar to using JAX-RS in a Java EE environment.

You can install the Apache Felix Dependency Manager Shell bundle to debug services registered using DM. Type the following command in the shell: dm <bundleid>. This will list all registered services by that bundle. You should see the service registered as java.lang.Object. Do the same for the bundle id of the org.amdatu.web.rest.wink bundle. You should see something like this for your service: javax.servlet.Servlet(init.applicationConfigLocation=/conf/application.properties,alias=/somepath,init.requestProcessorAttribute=/somepath) registered.

Also check if you are looking at the correct URL. By default, RESTful resources in Amdatu are registered to the root path (e.g. 'localhost:8080/myresource').

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top