Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JRun servlets (Win2K)--can't load after update

0 views
Skip to first unread message

Harlan Messinger

unread,
Dec 21, 2001, 2:03:42 PM12/21/01
to
I've just started experimenting with JRun Studio and Server on a Windows
2000 machine. I've got an application on the default server, "learn1". I
created my first servlet, HelloWorld1, and put the class file in

C:\Program Files\Allaire\JRun\servers\default\learn1\WEB-INF\classes

The HelloWorld1.class file is essentially a combination of the initial
examples from "CORE Servlets and JavaServer Pages":

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

public class HelloWorld1 extends HttpServlet {

private String message;
private String defaultMessage = "This is the default message.";
private int repeats = 1;

public void init(ServletConfig config)
throws ServletException
{
try
{
repeats = Integer.parseInt(config.getInitParameter("repeats"));
} catch (NumberFormatException nfe) { repeats = 1; }

message = config.getInitParameter("message");
if (message == null)
message = defaultMessage;
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hello World<br><ol>");
for (int i = 1; i <= repeats; i++)
out.println("<li>" + message + "</li>");
out.println("</ol>");
}

}

I added a Servlet Definition in the JRun Manager, defining "hw" as follows
(I bothered with this so as to define initial application arguments:

Name: hw
Class Name: HelloWorld1
Display Name: Hello World 1
Description: Hello World Experiment
Init Arguments:
repeats=4
message=This is a test.

The URL http://localhost:8100/learn1/servlet/hw then works fine, giving me:

Hello World

1.. This is a test.
2.. This is a test.
3.. This is a test.
4.. This is a test.
Now, I add some characters after the </ol> tag:

out.println("</ol>ABC");

and recompile the class. Then I refresh the browser. I get

500 Internal Server Error
/learn1/servlet/hw:

java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
at javax.servlet.GenericServlet.log(GenericServlet.java:300)
at javax.servlet.GenericServlet.destroy(GenericServlet.java:122)
at
allaire.jrun.servlet.JRunServletLoader.destroyAll(../servlet/JRunServletLoad
er.java:257)
at
allaire.jrun.servlet.JRunServletLoader.destroyAll(../servlet/JRunServletLoad
er.java:221)
at allaire.jrun.servlet.JRunSE.destroyAll(../servlet/JRunSE.java:1802)
at
allaire.jrun.servlet.JRunSE.getServletReference(../servlet/JRunSE.java:1730)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1231)
[etc.]

I refresh the browser again--and I get the same result as the previous time,
not reflecting my change to the code. If I continue refreshing the browser,
it goes back and forth between the internal server error message and the
earlier display. The only way I can figure out to fix it is to restart the
default server.

What's wrong?


0 new messages