Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:22:13+00:00 2026-06-05T17:22:13+00:00

I got the chat example working from Atmosphere, and now I want to get

  • 0

I got the chat example working from Atmosphere, and now I want to get the session, but I get a null pointer exception. My configuration:

  • GlassFish 3.1.2
  • Atmosphere 1.0.0-SNAPSHOT

My ChatAtmosphereHandler.java file:

@Override
public void onRequest(AtmosphereResource r) throws IOException {

    AtmosphereRequest req = r.getRequest();

    // First, tell Atmosphere to allow bi-directional communication by suspending.
    if (req.getMethod().equalsIgnoreCase("GET")) {

    /* ------- ADDED LINES BY ME ------- */
        double i = Math.random();
        System.out.println(i);
        req.getSession(true).setAttribute("user", i); //Null pointer exception
    /* --------------------------------- */
        // The negotiation header is just needed by the sample to list all the supported transport.
        if (req.getHeader("negotiating") == null) {
            r.suspend();
        } else {
            r.getResponse().getWriter().write("OK");
        }
    // Second, broadcast message to all connected users.
    } else if (req.getMethod().equalsIgnoreCase("POST")) {
        r.getBroadcaster().broadcast(req.getReader().readLine().trim());
    }
}

And the exception stack trace:

INFO: 18:07:19.816 [http-thread-pool-8080(4)] WARN  o.a.websocket.WebSocketProcessor - Failed invoking AtmosphereFramework.doCometSupport()
java.lang.NullPointerException: null
    at com.sun.grizzly.tcp.http11.GrizzlyRequest.doGetSession(GrizzlyRequest.java:2271) ~[grizzly-utils.jar:1.9.46]
    at com.sun.grizzly.tcp.http11.GrizzlyRequest.getSession(GrizzlyRequest.java:2226) ~[grizzly-utils.jar:1.9.46]
    at com.sun.grizzly.http.servlet.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:986) ~[grizzly-http-servlet.jar:1.9.46]
    at com.sun.grizzly.http.servlet.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:1009) ~[grizzly-http-servlet.jar:1.9.46]
    at org.atmosphere.cpr.AtmosphereRequest.createSession(AtmosphereRequest.java:606) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.cpr.AtmosphereRequest.getSession(AtmosphereRequest.java:580) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.cpr.AtmosphereRequest.getSession(AtmosphereRequest.java:600) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.samples.chat.ChatAtmosphereHandler.onRequest(ChatAtmosphereHandler.java:43) ~[ChatAtmosphereHandler.class:na]
    at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:232) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:165) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.container.GlassFishWebSocketSupport.service(GlassFishWebSocketSupport.java:111) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1125) ~[atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.websocket.WebSocketProcessor.dispatch(WebSocketProcessor.java:183) [atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.websocket.WebSocketProcessor.dispatch(WebSocketProcessor.java:112) [atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at org.atmosphere.container.GlassFishWebSocketSupport$GrizzlyApplication.onConnect(GlassFishWebSocketSupport.java:163) [atmosphere-runtime-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
    at com.sun.grizzly.websockets.DefaultWebSocket.onConnect(DefaultWebSocket.java:128) [grizzly-websockets.jar:1.9.46]
    at com.sun.grizzly.websockets.WebSocketEngine.upgrade(WebSocketEngine.java:188) [grizzly-websockets.jar:1.9.46]
    at com.sun.grizzly.websockets.WebSocketAsyncFilter.doFilter(WebSocketAsyncFilter.java:54) [grizzly-websockets.jar:1.9.46]
    at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) [grizzly-http.jar:1.9.46]
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71) [grizzly-framework.jar:1.9.46]
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) [grizzly-utils.jar:1.9.46]
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) [grizzly-utils.jar:1.9.46]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_03]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:22:14+00:00Added an answer on June 5, 2026 at 5:22 pm

    The session handling code has been modified since then. Please try again with the latest master code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys i have got this far with a chat system but now i
I've got a chat program which pushes JSON data from Apache/PHP to Node.js, via
i got the sample code of bluetooth chat application.from here. is it possible to
I'm working on some small chat application. I want to implement smilies over there
I'm making a little chat, and I got a problem: I disabled HTML, but
I've got a couple SignalR basic demos working locally (chat, etc.) and I understand
So. I have got web-chat working on socket.io. I'm thinking of using it also
I want to create a chat room using HTML5 web sockets, but am pretty
i am developing chat application in android... i got some exception when i run
I've got a socket server running (it's something that's basically like a chat server).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.