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. I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference.
    Java Courses in chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

How to add Maven dependency from a relative path referencing a local jar

PHP-SOAP web service with out a WSDL

Manually install a maven dependency