1
votes

I have servlet that does the following:

public class LoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        request.getAttribute("username");
        request.getAttribute("password");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        LoginManager lm = new LoginManager(username.trim(), password.trim());

Whenever I reach the last tomcat apache "crashes" with the following error message:

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
    servlets.LoginServlet.doPost(LoginServlet.java:20)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.ClassNotFoundException: javax.xml.rpc.ServiceException
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
    servlets.LoginServlet.doPost(LoginServlet.java:20)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Please Help Thanks!

When including jaxrpc.jar in the WEB-INF/lib folder I get following error:

root cause

java.lang.NoClassDefFoundError: org/apache/axis/AxisFault java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511) servlets.LoginServlet.doPost(LoginServlet.java:20) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.ClassNotFoundException: org.apache.axis.AxisFault org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2778) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1139) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511) servlets.LoginServlet.doPost(LoginServlet.java:20) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

5
You are missing a jar file. You can find which jar file should be in your classpath by looking at this list: jarfinder.com/index.php/java/info/…James Black

5 Answers

3
votes

Tomcat version and JDK / JRE version would be helpful.

It looks like your webapp is missing some required jars from WEB-INF/lib; in particular the jaxrpc jar.

1
votes

The server tells you that you're missing a library, the one that contains javax.xml.rpc.ServiceException.

However, the code you gave don't seem to use this class, so I think your problem isn't related to your Servlet.

0
votes

Looks to me as though somewhere along the line there's an Apache Axis dependency which needs to be addressed in your app's build path. Chances are, this is in the error handling for your JAXRPC calls.

0
votes

The reason why you're getting the 2nd exception:

java.lang.NoClassDefFoundError: org/apache/axis/AxisFault

It's because you've included javax.xml.rpc.ServiceException. I'm assuming you're using Axis else you're wouldn't be getting AxisFault. There are some jars that are missing.

If you want AxisFault to disappear, copy the axis.jar (assuming you're running the old axis 1) to the WEB-INF/lib folder.

-1
votes

sorry for the late reply..this may help someone in future..

java.lang.ClassNotFoundException: javax.xml.rpc.ServiceException It says it cant found the javax.xml.rpc jar. Please add the dependency to your POM file.

<dependency>
    <groupId>  javax.xml.rpc  </groupId>
    <artifactId>  javax.xml.rpc-api  </artifactId>
    <version>  1.1.1  </version>
</dependency>