我正在使用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)
答案 0 :(得分:3)
该类是在Java 1.6中引入的,因此您可能会意外地在Java 1.5上运行您的应用程序服务器或类似的东西。
答案 1 :(得分:0)
您也可以下载java 1.5支持的jar,代码不再提供此异常。
http://www.java2s.com/Code/Jar/j/Downloadjavaxxmlstream101jar.htm
希望有所帮助