问题
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)
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/9259901/how-do-i-solve-the-xmlstreamexception