Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet was found but is corrupt, message

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you compiling on the machine where it is running or compiling on your local machine and FTPing the class file to the server?
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After copying into Websphere, are you reloading the app?
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William also suggests that that an exception thrown in the servlet init() method may cause similar effects.
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the original have any static blocks?
Your new one may never be getting loaded.
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you've also restarted WAS.
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for getting back to us with your solution. Hopefully it will help someone else in the future
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic