dev@grizzly.java.net

nullpointer using grizzly-servlet-webserver-1.9.28

From: rama <rama.rama_at_tiscali.it>
Date: Fri, 14 Jan 2011 21:48:29 +0100

hi there,

i found a strange nullpointer, maybe someone can enlighth me..


here the test case


public class Test {

    public static void main(String [] a) {
        GrizzlyWebServer ws = new GrizzlyWebServer(12345);
        ws.addGrizzlyAdapter(
                new GrizzlyAdapter() {
                    @Override
                    public void service(GrizzlyRequest grizzlyRequest, GrizzlyResponse grizzlyResponse) throws Exception {
                        HttpServletRequest httpReq = new HttpServletRequestImpl(grizzlyRequest);
                        httpReq.getSession(true).setAttribute("a", "a");
                    }
                }
        );
        try {
            ws.start();
        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    }
}


just exec it, i get a NullPointer on setAttribute (getSession return actually a object, is the method setAttribute that throw exception)

----
java.lang.NullPointerException
	at com.sun.grizzly.http.servlet.HttpSessionImpl.setAttribute(HttpSessionImpl.java:230)
	at rama.Test$1.service(Test.java:28)
	at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
	at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:183)
	at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:818)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1008)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:680)