我该如何解决 XMLStreamException
我正在使用 REST Web 服务,并且需要解析使用 jaxb 构建的 XML。我得到以下异常。请帮我解决这个问题,提前致谢
java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException
com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:686)
com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:116)
com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:167)
com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:140)
com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:138)
com.sun.jersey.api.client.TerminatingClientHandler.writeRequestEntity(TerminatingClientHandler.java:317)
com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:179)
com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
com.sun.jersey.api.client.Client.handle(Client.java:435)
com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:475)
np.com.ntech.dto.EtopupClient.purchasePin(EtopupClient.java:54)
np.com.ntech.dto.App.pinRequest(App.java:264)
org.apache.jsp.fundtransfer.card_jsp._jspService(card_jsp.java:371)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am using REST web service and i need to parse the XML that is build using the jaxb. I get the following exception. Please help me solve this issue thank in advance
java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException
com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:686)
com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:116)
com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:167)
com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:140)
com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:138)
com.sun.jersey.api.client.TerminatingClientHandler.writeRequestEntity(TerminatingClientHandler.java:317)
com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:179)
com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
com.sun.jersey.api.client.Client.handle(Client.java:435)
com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:475)
np.com.ntech.dto.EtopupClient.purchasePin(EtopupClient.java:54)
np.com.ntech.dto.App.pinRequest(App.java:264)
org.apache.jsp.fundtransfer.card_jsp._jspService(card_jsp.java:371)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该类是在 Java 1.6 中引入的,因此您可能不小心在 Java 1.5 或类似的东西上运行应用程序服务器。
That class was introduced in Java 1.6 so you're probably accidentally running your application server on Java 1.5 or something like that.
您可以下载这个也支持 java 1.5 的 jar,并且代码将不再给出此异常。
http://www.java2s.com/Code/Jar/j/Downloadjavaxxmlstream101jar。 htm
希望有帮助
You can download this jar it supported for java 1.5 as well and the code will not give this exception anymore.
http://www.java2s.com/Code/Jar/j/Downloadjavaxxmlstream101jar.htm
Hope it helps