Restlet版本2.2 java.lang.NoSuchMethodError:javax / xml / stream / XMLInputFactory.newFactory()

时间:2017-05-24 08:19:58

标签: java restlet

我正在使用带有IBM jdk 1.6.0_26的Restlet版本2.2.0,我正在尝试实现REST服务。执行我的测试项目时,我收到以下错误:

Starting the internal [HTTP/1.1] server on port 8080
Server started ...
An exception occured writing the response entity

java.lang.NoSuchMethodError: javax/xml/stream/XMLInputFactory.newFactory()Ljavax/xml/stream/XMLInputFactory;
    at org.restlet.ext.jackson.JacksonRepresentation.createObjectMapper(JacksonRepresentation.java:215)
    at org.restlet.ext.jackson.JacksonRepresentation.getObjectMapper(JacksonRepresentation.java:333)
    at org.restlet.ext.jackson.JacksonRepresentation.createObjectWriter(JacksonRepresentation.java:277)
    at org.restlet.ext.jackson.JacksonRepresentation.getObjectWriter(JacksonRepresentation.java:361)
    at org.restlet.ext.jackson.JacksonRepresentation.write(JacksonRepresentation.java:474)
    at org.restlet.engine.adapter.ServerCall.writeResponseBody(ServerCall.java:519)
    at org.restlet.engine.adapter.ServerCall.sendResponse(ServerCall.java:463)
    at org.restlet.engine.adapter.ServerAdapter.commit(ServerAdapter.java:196)
    at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:153)
    at org.restlet.engine.connector.HttpServerHelper$1.handle(HttpServerHelper.java:73)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
    at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:77)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:80)
    at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:567)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
    at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:539)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:737)
Unable to send error response

java.io.IOException: headers already sent
    at sun.net.httpserver.ExchangeImpl.sendResponseHeaders(ExchangeImpl.java:180)
    at sun.net.httpserver.HttpExchangeImpl.sendResponseHeaders(HttpExchangeImpl.java:80)
    at org.restlet.engine.connector.HttpExchangeCall.writeResponseHead(HttpExchangeCall.java:157)
    at org.restlet.engine.adapter.ServerCall.sendResponse(ServerCall.java:459)
    at org.restlet.engine.adapter.ServerAdapter.commit(ServerAdapter.java:214)
    at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:153)
    at org.restlet.engine.connector.HttpServerHelper$1.handle(HttpServerHelper.java:73)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
    at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:77)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:80)
    at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:567)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
    at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:539)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:737)

使用Sun / Oracle 1.6 JDK时问题不存在,但我需要留在 IBM jdk 1.6.0_26。

任何帮助将不胜感激。

谢谢, EHA

1 个答案:

答案 0 :(得分:0)

两个JDK之间的后备JAXP选择可能存在问题。使用-Djaxp.debug=1运行java并查看您的日志。我目前遇到同样的问题,我的日志显示

JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using ClassLoader: null

我非常确定我的问题与OSGi有关。这是指向另一个问题的链接,其结果可能类似:Unable to find a factory for http://www.w3.org/2001/XMLSchema