Axis 2 web services in eclipse: Exception java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory thrown when Services link clicked

I created the web service using axis2 and deploy through tomcat in eclipse following a Tutorial. Then axis2 homepage get displayed OK. But when the Services link clicked an exception page will get displayed as follows.

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet AxisServlet threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory
org.apache.axis2.transport.http.SimpleHTTPServer.init(SimpleHTTPServer.java:116)
org.apache.axis2.engine.ListenerManager.init(ListenerManager.java:74)
org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:449)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)


SOLUTION


The reason here is that jar file related to class org.apache.http.HttpResponseFactory is missing to the project which is httpcore-x.jar. It is always not the case that eclipse automatically adds all required libraries. So we need to add this lib to the project. We can find httpcore-x.jar from your axis2 libraries (AXIS_HOME/libs). Go to project WebContent/WEB-INF/libs folder add the jar there.


Even you can copy the httpcore-x.jar and add it to tomcat libraries (CATALINA_HOME/lib). So that you do not need to add it all the time you create a new web service.


Comments

  1. Great article Glad to find your blog. Thanks for sharing.
    oracle training in chennai

    ReplyDelete
  2. hi really awesome blog.thank you for this awesome blog.
    apachespark training

    ReplyDelete
  3. Updating with the latest technology and implementing it is the only way to survive in our niche. Thanks for making me this article. You have done a great job by sharing this content in here. Keep writing article like this.
    Angularjs training in chennai | Angularjs course in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Manually install a maven dependency

PHP-SOAP web service with out a WSDL