users@grizzly.java.net

Re: Nullpointer in Comet

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 08 Jun 2009 12:30:57 -0400

Salut,

which version are you using?

FredrikJ wrote:
> Hi,
> I am getting this exception frequently when I am load testing my Comet
> application:
>
> java.lang.RuntimeException: java.lang.NullPointerException
> at
> com.sun.enterprise.web.connector.grizzly.async.AsyncProcessorTask.doTask(AsyncProcessorTask.java:110)
> at
> com.sun.enterprise.web.connector.grizzly.comet.CometEngine.flushResponse(CometEngine.java:583)
> at
> com.sun.enterprise.web.connector.grizzly.comet.CometEngine.resume(CometEngine.java:570)
> at
> com.sun.enterprise.web.connector.grizzly.comet.CometContext.resumeCometHandler(CometContext.java:487)
> at
> com.sun.enterprise.web.connector.grizzly.comet.CometContext.resumeCometHandler0(CometContext.java:451)
> at
> com.sun.enterprise.web.connector.grizzly.comet.CometContext.resumeCometHandler(CometContext.java:438)
>
> This is basically what my CometHandler looks like:
>
> public void onEvent(CometEvent event) throws IOException {
> try {
> ResultDTO result = (ResultDTO)event.attachment();
> String response = result.getBody();
> PrintWriter writer = response.getWriter();
> writer.write(text);
> writeToResponse(response);
> } finally {
> cometContext.resumeCometHandler(this);
> }
> }
>
> public void onInterrupt(CometEvent event) throws IOException {
> StringWriter writer = new StringWriter();
> XmlResponseBuilder.buildErrorResponse("error message");
> writeToResponse(writer.toString());
> }
>
> public void onTerminate(CometEvent event) throws IOException {}
> public void onInitialize(CometEvent event) throws IOException {}
>
> I am not sure why I am getting these NullPointers, the error message is not
> very descriptive =)

Agree. You should not see those at all.

> Perhaps I am not using the API correctly?

Depending on the version you are using, can you try synchronizing the
onEvent? Do you think you can send me a test case?

Thanks

-- Jeanfrancois

>
>
>