Reputation: 119
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.
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.
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.
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
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. Kindly help me.Thanks
Upvotes: 0
Views: 3543
Reputation: 154
You should not have same jar files in different Version in your classpath. Please choose your needed version of httpcore and httpclient.
Where do you put the axis jars, and do you realy need an other http-clent.jar?
There is already one in axis2:
./axis2-1.6.2/lib/commons-httpclient-3.1.jar
org/apache/commons/httpclient/params/HttpParams.class
I would guess that there is the conflict ....
Upvotes: 1