trouble using osgi RESTEasy 3

94 Views Asked by At

Hello i'm trying to create a plugin with eclipse to use RESTEasy 3 in a opensource project (iDempiere ERP).

I created a plugin with eclipse, imported the RESTEsy libraries.. I writing the following class using some tutorials on web and registering this class as Activator.

public class Activator extends Application implements BundleActivator {

  private volatile ServiceTracker   serviceTrackerForResteasyService;
  private volatile ResteasyService  resteasyService;
  private Set<Object> singletons = new HashSet<Object>();

public Activator()
{

}

@Override
public void start( BundleContext bundleContext ) throws Exception
{

    try
    {
        serviceTrackerForResteasyService =  new ServiceTracker( bundleContext, ResteasyService.class.getName(), null );
        serviceTrackerForResteasyService.open();
        resteasyService = (ResteasyService)serviceTrackerForResteasyService.getService();

        if (resteasyService == null) {
            System.out.println("resteasyService == null");
        }

        resteasyService.addSingletonResource("/rest/*", new SampleResource2());


    }
    catch ( Exception e )
    {
        e.printStackTrace();
        throw e;
    }

but I have this error: resteasyService is null... I don't know how initialize correctly the class.

I have already used successfully RESTEasy with tomcat without OSGI and I used web.xml configuration files. In OSGI I think that the web.xml is not used anymore is it correct ?

0

There are 0 best solutions below