users@glassfish.java.net

CometContext.notify(..) causes NullPointerException

From: <glassfish_at_javadesktop.org>
Date: Tue, 03 Aug 2010 03:38:33 PDT

I got this Exception:

java.lang.NullPointerException
    at com.sun.enterprise.web.connector.grizzly.LinkedListPipeline.addTask(LinkedListPipeline.java:263)
    at com.sun.enterprise.web.portunif.PortUnificationPipeline.addTask(PortUnificationPipeline.java:181)
    at com.sun.enterprise.web.connector.grizzly.comet.DefaultNotificationHandler.notify(DefaultNotificationHandler.java:110)
    at com.sun.enterprise.web.connector.grizzly.comet.CometContext.notify(CometContext.java:610)
    at com.sun.enterprise.web.connector.grizzly.comet.CometContext.notify(CometContext.java:521)
    at mypackage.MyClass.notifyComet(MyClass.java:33)
    at mypackage.MyClass.onMessage(MyClass.java:44)
    at sun.reflect.GeneratedMethodAccessor2330.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:181)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:985)
    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:186)
    at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2929)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4020)
    at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
    at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
    at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
    at $Proxy227.onMessage(Unknown Source)
    at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
    at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:77)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)

If I downloaded the correct grizzly sources

<groupId>com.sun.grizzly</groupId>
<artifactId>grizzly-framework-http</artifactId>
<packaging>jar</packaging>
<version>1.0.30</version>

this is the code, that fails:

public synchronized void addTask(Task task) {
    int queueSize = size();
    if ( maxQueueSizeInBytes != -1 && maxQueueSizeInBytes <= queueSize){
        SelectorThread st = task.getSelectorThread();
        st.cancelKey(task.getSelectionKey()); // <--- st IS NULL, BUT WHY?
        SelectorThread.logger().log(Level.WARNING,"Maximum connections queued reached " +

                "(max-pending-count) "
                + maxQueueSizeInBytes +
                ". Dropping requests until queued connections have been freed up.");
        st.returnTask(task);
        return;
    }
    
    addLast(task);
    notify();

    // Create worker threads if we know we will run out of them
    if (threadCount < maxThreads && waitingThreads < (queueSize + 1)){
        int left = maxThreads - threadCount;
        if (threadsIncrement > left){
            threadsIncrement = left;
        }
        increaseWorkerThread(threadsIncrement,true);
    }
}

I wonder, why is the selector thread null and how I can prevent this?
[Message sent by forum member 'hegalor']

http://forums.java.net/jive/thread.jspa?messageID=479200