REST Server only in Eclipse SmartHome possible?

I want to make my own REST Server for example like the in For example class I implemented the RESTResource and created the resource.xml. In the Eclipse SmartHome namespace the example works fine. When I copy the .java and .xml in the openHAB2 namespace and change the packagenames, it doesn’t work anymore. What am I doing wrong?

The following is my example which only works in the Eclipse SmartHome namespace:


public class MessageResource implements RESTResource {    
    public String getDiscoveryServices() {
        return "hi";

my xml File:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="" name="">
   <implementation class=""/>
      <provide interface=""/>
      <provide interface=""/>

Solved, I had to edit the MANIFEST.MF.

1 Like

Yes, you are on a good way. In general, there are two things important to know:

  1. The REST API uses JAX-RS 2.0 and as such one has to annotate the class accordingly.
  2. The Resource class must implement the interface RESTResource and must be registered with this interface as an OSGi service (what can be done through OSGi Declarative Services as in your example).



Hi ,

When I created multiple Resource classes say like Class A implements RESTResource again Class B implements RESTResource and so on and also created respective XML (service component as DS) and added to MANIFEST.MF.

Only one Resource class get RESTResource service. All other shows Not Found Exception (404).

MANIFEST.MF service component goes as below ,

Service-Component: OSGI-INF/A.xml, OSGI-INF/B.xml

Please help.No idea why my resource class not get registered.

Service component definition description has a field called ‘name’ which defines the name of the service component. Accidentally, I put the same name to both service component (A.xml and B.xml) which caused duplication. Resolve once when i put the different name.