aspose file tools*
The moose likes Servlets and the fly likes Servlet was found but is corrupt, message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet was found but is corrupt, message" Watch "Servlet was found but is corrupt, message" New topic
Author

Servlet was found but is corrupt, message

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
Hi guys, wondering if any of you have had this before.

I have a basic login servlet, which simply checkers username/password with contents of a SQL database.

When I click on SUBMIT on the login.jsp the servlet fails to load and I get a -
javax.servlet.ServletException: Servlet [LoginServlet]: uk.co.domain.servlets.LoginServlet was found, but is corrupt:

The package path is correct
The name of the servlet is correct
The servlet compiles successfully (obviously for me to have a class file)

I have tried removing the class file and recompiling, removing the servlet mapping and recreating it. I just can't see any reason for this error.

K.


Cheers!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you compiling on the machine where it is running or compiling on your local machine and FTPing the class file to the server?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
The class is being compiled on the same machine as the source.

The class is then being copied to the appropriate folder within Websphere.

What I don't understand is, I'm sure I had this LoginServlet working last week.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

After copying into Websphere, are you reloading the app?
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
Yep.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Here's the rest of the message from Websphere:
1. Check that the class resides in the proper package directory. 2. Check that the classname has been defined in the server using the proper case and fully qualified package. 3. Check that the class was transfered to the filesystem using a binary tranfer mode. 4. Check that the class was compiled using the proper case (as defined in the class definition). 5. Check that the class file was not renamed after it was compiled.

(found via a search on the net)

I'm assuming you've done all these things? Personally I think you may not have it packaged as you expect, ie it might have been accidentally compiled as src.uk.co.domain...etc I did that just last week.
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
I have checked through these 'suggestions' given by Websphere, the servlet is packaged correctly, the name has not been changed, compiled successfully etc...
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Another possibility: does your servlet include any static code blocks or other code that gets run as the Class is loaded? When code of this type fails it prevents the class being loaded and sometimes causes strange ClassLoader side effects.

Heh, the best reference to a similar situation I found on the net has Marcus Green and William Brogden
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

William also suggests that that an exception thrown in the servlet init() method may cause similar effects.
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
OK becoming more and more annoyed by this now!

I've cut out ALL the code from teh LoginServlet, so now it literally does nothing but redirect to another JSP

package uk.co.domain.servlets;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.sendRedirect("success.jsp");
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}

And STILL i get the corrupted error.

Is this just the quality of websphere causing this?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Did the original have any static blocks?
Your new one may never be getting loaded.
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
It had the database name and location (server) in it but that's it.

I have now cleared out the servlet, removed the folders the classes were in and even deleted the webapp and recreated it with the new 'cut down' LoginServlet. Copied the new compiled servlet back into a new folder the new webapp and still i get the same error!

this is getting stupid, can Websphere just not see servlets or something? There's nothing there to go wrong.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I assume you've also restarted WAS.
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
I have now solved the problem I had a "moment of clearity" (As one Mr Samuel L Jackson once said), It was the Java version that was causing the problem, WAS could not understand the sevlet as it was compiled in 1.5.

Cheers for your help anyway
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Thanks for getting back to us with your solution. Hopefully it will help someone else in the future
 
 
subject: Servlet was found but is corrupt, message