views:

95

answers:

4

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)

+1  A: 

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.

jabley
Thanx had to include all jars into WEB-INF now it works
Rob Hufschmitt
A: 

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.

Vivien Barousse
I'm assuming that the LoginManager has a dependency on jaxrpc.
jabley
Yes you're right.
Rob Hufschmitt
import javax.xml.rpc.*;public class LoginManager {
Rob Hufschmitt
A: 

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.

Ben Poole
A: 

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.

The Elite Gentleman