jax-rsosgidmamdatu

Amdatu rest example doesn't work?


I have created a bnd-workspace with amdatu-bootstrap jar file. Then created a testing rest project and a bnd run descriptor file to test it. When I run the the run descriptor file and navigated to http://localhost:8080/test, I faced 404 page :(.

HTTP ERROR: 404

Problem accessing /test. Reason:

    Not Found

Here are the in-detail steps I took to do so:

  1. Downloaded and used bootstrap-bin-r9.zip
  2. In Amdatu Bootstrap UI, to initialize the workspace I issued "workspace-init" with "amdatu" template
  3. Then I created a project "osgi.test" with "project-create" command
  4. Then I created a test component "tmp.Test" with "/test" as url using "rest-createcomponent" command
  5. Then I added rest required dependencies using "rest-install" command
  6. Then I created launcher.bndrun with org.apache.felix.framework;version='[5.2.0,5.2.0]' and Java-1.8 as OSGI framework.
  7. Then I added rest required libraries to launcher.bndrun with "rest-run" command
  8. Then I added gogo and dm shell with "shell-run" command

Test component:

package tmp;

import java.util.List;

import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import java.util.Arrays;
import org.apache.felix.dm.annotation.api.Component;

@Component(provides = Object.class)
@Path("/test")
public class Test {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<String> list() {
        return Arrays.asList("test");
    }
}

Here is list of bundles:

lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.2.0)
    1|Active     |    1|Apache Felix Http Jetty (3.2.0)
    2|Active     |    1|Apache Felix Http API (3.0.0)
    3|Active     |    1|Apache Felix Servlet API (1.1.2)
    4|Active     |    1|Apache Felix Http Whiteboard (3.0.0)
    5|Active     |    1|org.amdatu.web.rest.jaxrs (1.1.1)
    6|Active     |    1|org.amdatu.web.rest.wink (3.0.1)
    7|Active     |    1|org.amdatu.web.rest.doc (1.2.3)
    8|Active     |    1|Jackson-annotations (2.6.3)
    9|Active     |    1|Jackson-core (2.6.3)
   10|Active     |    1|jackson-databind (2.6.3)
   11|Active     |    1|Jackson-JAXRS-base (2.6.3)
   12|Active     |    1|Jackson-JAXRS-JSON (2.6.3)
   13|Active     |    1|Apache Felix Dependency Manager (4.3.0)
   14|Active     |    1|Apache Felix Dependency Manager Runtime (4.0.3)
   15|Active     |    1|Apache Felix Metatype Service (1.0.12)
   16|Active     |    1|Apache Felix EventAdmin (1.3.2)
   17|Active     |    1|Apache Felix Configuration Admin Service (1.8.6)
   18|Active     |    1|OPS4J Pax Logging - API (1.7.0)
   19|Active     |    1|OPS4J Pax Logging - Service (1.7.0)
   20|Active     |    1|osgi.test (0.0.0)
   21|Active     |    1|Apache Felix Gogo Command (0.12.0)
   22|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
   23|Active     |    1|Apache Felix Gogo Shell (0.10.0)
   24|Active     |    1|Apache Felix Dependency Manager Shell (4.0.4)

And here is the result of "dm" command

dm
[6] org.amdatu.web.rest.wink
 [0] org.amdatu.web.rest.jaxrs.JaxRsSpi registered
 [1] org.slf4j.impl.StaticLoggerBinder(OSGi) registered
    org.osgi.service.log.LogService service optional available
 [2] org.amdatu.web.rest.whiteboard.JaxRsWhiteboard registered
    active{bundle.id=6} bundle required available
    org.osgi.service.log.LogService service optional available
    javax.ws.rs.core.Application (osgi.jaxrs.application.base=*) service optional unavailable
    java.lang.Object (osgi.jaxrs.resource.base=*) service optional unavailable
 [3] Adapter for interface org.amdatu.web.rest.jaxrs.ApplicationService registered
    org.amdatu.web.rest.jaxrs.ApplicationService service optional unavailable
[14] org.apache.felix.dependencymanager.runtime
 [4] org.apache.felix.dm.runtime.DependencyManagerRuntime registered
    active (DependencyManager-Component=*) bundle optional unavailable
    org.osgi.service.packageadmin.PackageAdmin service required available
    org.osgi.service.log.LogService service optional available

When I navigate to http://localhost:8080/test following errors is shown

HTTP ERROR: 404

Problem accessing /test. Reason:

    Not Found

Any helps appreciated.


Solution

  • changing the version of org.amdatu.web.rest.wink to 2.0.3 will solve the problem.

    I don't know what is wrong with version 3+ and why it only works with 2.0.3 ?!!!