我是开发Web服务的新手。我正在使用axis2创建Web服务并在tomcat中部署。我通过从博客中获取一些知识并将其部署在tomcat7中来做到这一点没问题。当我在SOAP中检查Web服务时UI。我收到了错误。
我做的是。我用我的方法创建了一个java类。这个方法用于将记录插入solr.so我使用http客户端,基本名称值对等我为该类制作aar文件并部署它在tomcat中没有任何问题。但是当我通过soapUi调用该方法时,我在控制台中出错。请帮助我。
我的错误控制台是:
Exception In Source Create Service java.lang.ClassCastException: org.apache.http.message.BasicNameValuePair cannot be cast to org.apache.http.NameValuePair
[ERROR] loader constraint violation: when resolving method "org.apache.http.client.methods.HttpPost.setParams(Lorg/apache/http/params/HttpParams;)V" the class loader (instance of org/apache/axis2/deployment/DeploymentClassLoader) of the current class, com/mf/dmsolr/SolrUtil, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/apache/http/client/methods/HttpPost, have different Class objects for the type client.methods.HttpPost.setParams(Lorg/apache/http/params/HttpParams;)V used in the signature
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.client.methods.HttpPost.setParams(Lorg/apache/http/params/HttpParams;)V" the class loader (instance of org/apache/axis2/deployment/DeploymentClassLoader) of the current class, com/mf/dmsolr/SolrUtil, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/apache/http/client/methods/HttpPost, have different Class objects for the type client.methods.HttpPost.setParams(Lorg/apache/http/params/HttpParams;)V used in the signature
at com.mf.dmsolr.SolrUtil.insertRecords(SolrUtil.java:34)
at com.mf.dmsolr.Dmwebservices.insertXMLData(Dmwebservices.java:172)
at com.mf.dmsolr.Dmwebservices.createSource(Dmwebservices.java:102)
... 29 more
我的java代码导入如下所示。
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;
import java.util.zip.InflaterInputStream;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.mf.dmsolr.server.DataSet;
import com.mf.dmsolr.server.Datastreamtype;
import com.mf.dmsolr.server.Recordtype;
我的lib文件夹包含
httpclient-4.2.1.jar
httpclient-4.2.3.jar
httpcore-4.2.1.jar
httpcore-4.2.2.jar
httpmime-4.2.3.jar
当我用我的aar文件部署轴应用程序时遇到了一些问题。我通过复制我在我的java应用程序中的jar并在tomcat lib文件夹中的那个来修复该问题。然后该错误消失并成功部署。如果是问题意味着,如何纠正这个问题。 请帮助我。谢谢
答案 0 :(得分:1)
您的类路径中的不同版本中不应该有相同的jar文件。请选择所需的httpcore版本和httpclient。
你把轴罐放在哪里,你真的需要另一个http-clent.jar吗?
在axis2中已有一个:
./ axis2-1.6.2 / LIB /公地HttpClient的-3.1.jar
组织/阿帕奇/公地/ HttpClient的/ PARAMS / HttpParams.class
我猜是存在冲突......