Restlet in OSGI cannot find com / sun / net / httpserver / HttpHandler

I am trying to use Restlet in OSGi embedded environment. I added the org.restlet.jar version 2.3.0 to the classpath of my test suite. But he kept giving me the following error.

java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler

      

The documentation says that this jar should be enough, but it doesn't work at this time. The package runs with the Equinox Framework, which is run by a standalone launcher that will later be used outside of the Eclipse environment.

Is there another jar I have to add in order to get the appropriate server connector? I won't be using servlets, so the only options are Restlet connectors.

When I manually run the package, I get the following warning:

WARNING: No available server connector supports the required protocols: 'HTTP' . Please add the JAR of a matching connector to your classpath.

      

I've already spent a lot of time getting it to work with no luck. Thanks in advance!

+2


source to share


1 answer


I found a solution in the answer here .

So the com.sun.net.httpserver package (which is part of the JDK) needs to be exposed to the OSGi environment. The best solution that worked for me was to expose it through the system package during rocket launch by adding it to the following property:



org.osgi.framework.system.packages.extra = com.sun.net.httpserver

      

If you are using Restlet in an OSGi environment using a dedicated launcher, adding the above solution will make this package available for import. I think they should have added this information to their documentation. This issue does not occur if Restlet is installed in Eclipse and used directly in the Eclipse environment using Eclipse launch, as I think the setting will be automatically configured.

+3


source







All Articles