Guys this is my first real crack at a servlet. I'm getting a can not instantiate servlet error. Any insights as to what I should look at would help speed me up. Not sure where to look first. Thanks in advance,
There could be lots of things. Are you putting your servlet code in the WEB-INF/classes folder of your web application, and are you deploying it in the web.xml file for the same web application? If so, send in more info about what exactly you tried, and we'll see about getting your servlet working.
Jayson Falkner<br />firstname.lastname@example.org<br />Author of <a href="http://www.jspbook.com" target="_blank" rel="nofollow">Servlets and JavaServer Pages; the J2EE Web Tier</a>
This error can happen if you don't have all the classes needed for your servlet available to the servlet container, even though they were available to the compiler when you compiled your code. Servlet containers almost always ignore any external "classpath", and only recognize and load classes deployed within their own configuration and application structure. Typically you should ensure that your own application classes are placed in WEB-INF/classes, and that any third-party jar files needed by your code are placed in WEB-INF/lib.
For one thing, JRun 3.1 is a couple of years old and does not support the current servlet API, so there might be an incompatibility there. Is there some reason you have to use JRun 3.1 as opposed to - say - Tomcat 4? Are you using the JRun manager to deploy the servlet? In any case there should be something informative in the log files. Bill
Thank you for all the informative answers. I should have given a clearer picture. I have since found the batch file that compiles all files within JRUN and I have added my servlet to the web-inf.xml file. The problem that I am now running into is that I am using a 3rd party JAR file to create PDF forms, itext.jar. When I place this within the web-inf/lib directory, I am still not able to access the files within. I believe I need to add the JAR file directly to the class path. I am receiving a 500 internal server error. I would appreciate any help. Again, thank you all.
Joined: Jan 07, 1999
It's a while since I last used an older version of the servlet API, but I have this vague memory that there was no notion of WEB-INF/lib. Have you tried simply unzipping the third-party jsr into wherever you have located your own application class files?
Joined: Nov 05, 2003
The servlet is in the WEB-INF/classes directory, and has been. You were right about the servlet container not seeing the third party external classpath. I have since included the path to the jar file in the JRUN classpath and I am now receiving errors to the effect, "package does not exist" from within the jar directory structure. Please shed some pearls of wisdom.
Joined: Nov 05, 2003
Thank you for all the responses. I have come to find that a different jar file from iText was loaded than the one I was using. Hence, all is well now. Again, thank you all.