2013-06-21 55 views
0

我是新開發的web services.i使用axis2創建web服務並在tomcat中部署。我通過從博客獲取一些知識並在tomcat7中部署它沒有問題。當我檢查SOAP UI中的Web服務出錯。在tomcat中使用axis2的Webservice

我做的是我創建一個有我的方法的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文件部署軸線aplication得到了一些issue.i解決這個問題,通過複製,我在我的Java應用程序和以往有罐子在tomcat的lib文件夾中,然後錯誤消失,併成功部署。如果是問題的意思,如何糾正這個問題。 請幫助我。謝謝

+0

顯示你的代碼來調用這些Web服務 –

+0

我通過SOAP調用UI工具此WebService僅testing.at當時只有我在日食服務器得到這個錯誤控制檯 –

+0

webservice代碼和你的WSDL –

回答

1

在類路徑中,不應該在不同版本中包含相同的jar文件。請選擇你需要的httpcore和httpclient版本。

你把軸罐放在哪裏,你真的需要一個其他的http-clent.jar嗎?

已經有一個Axis2中:

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

組織/阿帕奇/公/ HttpClient的/ PARAMS/HttpParams.class

我猜想,有衝突....

+0

現在我刪除axis2庫中的commons-httpclient-3.1.jar,並再次部署它...沒有我自己部署時出現錯誤... [錯誤] org/apache/commons/httpclient/HttpException org.apache。 axis2.deployment.DeploymentException:org/apache/commons/httpclient/HttpException –

+0

請幫忙..如果我用http-clent.jar替換/commons-httpclient-3.1.jar,我已經使用它,在部署時會出錯。 –

+0

您應該保持軸包的原樣,所以最好用軸版本替換您的httpClient版本,並使用它替換....您還可以發佈更多關於您的設置的信息,例如版本信息,你的課程等 – beagle