gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 11:27:52 38 4
gpt4 key购买 nike

我正在使用 ReSTLet 版本 2.2.0 和 IBM jdk 1.6.0_26,并且我正在尝试实现 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。

如有任何帮助,我们将不胜感激。

谢谢,埃哈

最佳答案

这可能是两个 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

关于java - ReSTLet 版本 2.2 java.lang.NoSuchMethodError : javax/xml/stream/XMLInputFactory. newFactory(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44152830/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com