0

我是开发Web服务的新手。我正在使用axis2创建Web服务并在tomcat中部署。我通过从博客中获取一些知识并将其部署在tomcat7中没有问题。当我在SOAP UI中检查该Web服务时。我有错误。

我所做的是。我创建一个具有我的方法的java类。该方法用于将记录插入到solr。所以我使用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 应用程序中的 jars 并在 tomcat lib 文件夹中过去的 jars 来解决这个问题。然后那个错误消失了。并成功部署。如果是问题的意思是,如何纠正这个问题。请帮助我。谢谢

4

1 回答 1

1

您的类路径中不应有不同版本的相同 jar 文件。请选择您需要的 httpcore 和 httpclient 版本。

你把轴罐放在哪里,你真的需要另一个 http-clent.jar 吗?

在axis2中已经有一个:

./axis2-1.6.2/lib/commons-httpclient-3.1.jar

org/apache/commons/httpclient/params/HttpParams.class

我猜是有冲突....

于 2013-06-21T09:58:00.810 回答