简体   繁体   English

在Tomcat中使用axis2的Web服务

[英]Webservice using axis2 in tomcat

I am new to develop web services.i am using axis2 to create web service and deploy in tomcat.I do it by getting some knowledge from the blogs and deploy it in tomcat7 no problem.when i check that web service in SOAP UI.I got error. 我是开发Web服务的新手。我正在使用axis2创建Web服务并在tomcat中进行部署。我是通过从博客中获取一些知识并将其部署在tomcat7中来实现的,当我在SOAP UI中检查该Web服务时,我没有问题。出错了。

What i do is.I create one java class having my methods.That method is for inserting records to solr.so i am using http client,basic name value pair etc.and i make aar file for that class and deploy it in tomcat with out any problem.but when i call that method through soapUi i got error in console.Kindly help me. 我所做的是,我创建了一个具有我的方法的Java类。该方法用于将记录插入solr.so我正在使用http客户端,基本名称值对等,然后为该类创建一个aar文件并将其部署在tomcat中出任何问题。但是当我通过soapUi调用该方法时,控制台出现错误。请帮助我。

My Error console is: 我的错误控制台是:

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

And my java code imports are given below. 我的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;

And my lib folder contains 我的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

when i deploy the axis aplication with my aar file got some issue.i fix that issue by copy the jars which i having in my java application and past that in tomcat lib folder.then that error is gone.and deployed succesfully.If it is the problem means,How to rectify this issue. 当我用aar文件部署轴应用时遇到了一些问题。我通过复制我在Java应用程序中存在的jar并将其放到tomcat lib文件夹中来解决该问题,然后该错误消失了,并成功部署了。问题意味着,如何纠正此问题。 Kindly help me.Thanks 请帮助我。谢谢

You should not have same jar files in different Version in your classpath. 您的类路径中的不同版本中不应具有相同的jar文件。 Please choose your needed version of httpcore and httpclient. 请选择所需的httpcore和httpclient版本。

Where do you put the axis jars, and do you realy need an other http-clent.jar? 您将轴罐放在哪里,真的需要其他http-clent.jar吗?

There is already one in axis2: axis2已经存在一个:

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

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

I would guess that there is the conflict .... 我猜那里有冲突....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM