Restlet in OSGI can not find com/sun/net/httpserver/HttpHandler

心不动则不痛 提交于 2020-01-05 02:12:07

问题


I am trying to use Restlet in embedded OSGi environment. I have added the org.restlet.jar version 2.3.0 in the class path of my restlet test bundled. But it 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 is currently not working. The bundle is started by an Equinox Framework which is started by a standalone launcher, later to be used outside of Eclipse environment.

Is there another jar fie that I should add to get the proper server connector? I will not be using servlets so the Restlet connectors are the only options.

When I manually start the bundle 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 had already spent a lot of time to get it working with no luck. Thanks in advance!


回答1:


I have found the solution in the Answer posted here.

So the package com.sun.net.httpserver (which is part of the JDK) needs to be exposed to the OSGi environment. The best solution that has worked for me is to expose it through the system bundle during framework 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 custom framework launcher, adding the above solution will make the package available for import. I think they should have added this information in their documentation. This problem does not occur when Restlet is installed in Eclipse and used directly in Eclipse environment using Eclipse launcher because I think the configuration will be automatically setup.



来源:https://stackoverflow.com/questions/28193334/restlet-in-osgi-can-not-find-com-sun-net-httpserver-httphandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!