com.sun.net.httpserver.HttpHandler ClassNotFound Exception on Java Embedded Runtime Environment

牧云@^-^@ 提交于 2019-12-24 12:32:10

问题


i am trying to run restlet on an ejre. In eclipse with normal jre the code works absolutely fine, but in the ejre i get the following exception:

java.lang.ClassNotFoundException: com.sun.net.httpserver.HttpHandler cannot be found

I am using restlet v. 2.2.1. for jee and Java SE Embedded Runtime Environment (build 1.7.0_21-b11, headless) Java HotSpot Embedded Client VM (build 23.21-b01, mixed mode)

I tried restlet v. 2.1. as mentioned in here but it did not work.

Had someone a similar problem?


回答1:


I have to explain a few things before (partly) answering your question. Restlet Framework provides an API and an implementation, and we try to provide them in multiple environments (classical JVM, servlet container, android, gwt, gae). As these environments supports only parts of the JDKs (GWT hates server code for example), we address this constraint by providing what we call "editions" of the framework (cf http://restlet.com/learn/guide/2.2/editions/).

In the context of the ejre, I understand that the internal server connector based on the JDK lightweight server is not supported. In order to help you we can introduce a new edition (cf this ticket https://github.com/restlet/restlet-framework-java/issues/939).

As I'm not sure to be able to provide it shortly, I would like to know if you intend to run an HTTP server inside the JVM, or if you just want to issue client requests. In this case, you may try to run these instructions before (not tested):

org.restlet.engine.Engine.register(false);
Engine.getInstance().getRegisteredClients().add(new org.restlet.engine.connector.HttpClientHelper(null));



回答2:


Hey had this problem Upgrading org.restlet.jee from 2.0.15 to 2.2.0

Had to add the class to the maven dependencies

    <dependency>
        <groupId>com.sun.net.httpserver</groupId>
        <artifactId>http</artifactId>
        <version>20070405</version>
    </dependency>


来源:https://stackoverflow.com/questions/25179243/com-sun-net-httpserver-httphandler-classnotfound-exception-on-java-embedded-runt

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