Java 嵌入式运行时环境中的 com.sun.net.httpserver.HttpHandler ClassNotFound 异常
我正在尝试在 ejre 上运行 restlet.在具有普通 jre 的 eclipse 中,代码工作得非常好,但在 ejre 中我得到以下异常:
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
我正在使用 restlet v. 2.2.1.适用于 jee 和 Java SE Embedded Runtime Environment(build 1.7.0_21-b11,headless)Java HotSpot Embedded Client VM(build 23.21-b01,混合模式)
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)
我尝试了 restlet v. 2.1.如 here 中所述,但它不起作用.
有人遇到过类似的问题吗?
I tried restlet v. 2.1. as mentioned in here but it did not work.
Had someone a similar problem?
推荐答案
在(部分)回答你的问题之前,我必须解释一些事情.Restlet Framework 提供了一个 API 和一个实现,我们尝试在多个环境(经典 JVM、servlet 容器、android、gwt、gae)中提供它们.由于这些环境仅支持部分 JDK(例如 GWT 讨厌服务器代码),我们通过提供我们称之为框架的版本"来解决这个限制(参见 http://restlet.com/learn/guide/2.2/editions/).
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/).
在ejre的上下文中,我了解不支持基于JDK轻量级服务器的内部服务器连接器.为了帮助您,我们可以推出一个新版本(参见这张票 https://github.com/restlet/restlet-framework-java/issues/939).
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).
由于我不确定能否很快提供它,我想知道您是否打算在 JVM 中运行 HTTP 服务器,或者您是否只想发出客户端请求.在这种情况下,您可以尝试在之前运行这些指令(未测试):
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));
相关文章