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 8007241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:45:48+00:00 2026-06-04T17:45:48+00:00

I extended the chat example and added a stay-alive message every 5 seconds. If

  • 0

I extended the chat example and added a “stay-alive” message every 5 seconds. If I debug and run the code through break points, it runs perfectly. However if I just run the app it crashes with the log below:

// Loop while the socket is open
        while (inbound.isOpen()) {

            // Wait for an event (either something coming on the inbound
            // socket channel, or ChatRoom messages)
            Either<WebSocketEvent, Chat> e = await(Promise.waitEither(
                    inbound.nextEvent(), serverStream.nextEvent()));

            // Incoming text event on WebSocket
            for (String json : TextFrame.match(e._1)) {
                Chat message = Chat.fromJSON(json);
                message.saveAsChatMessage(client, user);

                if (message.isPublishable()) {
                    serverStream.publish(message);
                }
            }

            // After processing information we need to beam this done on the
            // WebSocket
            for (Chat chat : ClassOf(Chat.class).match(e._2)) {
                if (chat.isMeantForMe(client, user, threads)) {
                    outbound.send(chat.toJSON());
                }
            }

            // Case: The socket has been closed
            for (WebSocketClose closed : SocketClosed.match(e._1)) {
                user.setOnline(false);
                user._save();

                // Update all the threads for this user
                for (Thread t : threads) {
                    Chat chat = new Chat();
                    chat.event = event_type.OFFLINE;
                    chat.userId = user.id;
                    serverStream.publish(chat);
                }

                disconnect();
            }
        }

Here is the complete log:

Execution exception
InvocationTargetException occured : null

play.exceptions.JavaExecutionException
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:233)
    at play.mvc.WebSocketInvoker.invoke(WebSocketInvoker.java:28)
    at play.server.PlayHandler$WebSocketInvocation.execute(PlayHandler.java:1161)
    at play.Invoker$Invocation.run(Invoker.java:276)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.reflect.InvocationTargetException
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:551)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
    ... 11 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Iterator
    at controllers.ChatServerController.join(ChatServerController.java)
    ... 16 more

I know its got to do with something to do with concurrency. What do I do to prevent a dead lock?

  • 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-04T17:45:50+00:00Added an answer on June 4, 2026 at 5:45 pm

    The mistake I was making was to send JPA models on the event stream. Which were being called from different threads causing the crash. I modified to the code to send a json (string type) on the event stream or a simple object.

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

Sidebar

Related Questions

I've successfully extended some SASS functions with Ruby code (http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#adding_custom_functions), and my extensions are
I have extended my domain service using a shared code file to add an
In the sun extended RMI tutorial, they have some interesting code which implements a
With the new extended RTTI in Delphi 2010, can a Delphi application (at run
I've slightly extended the jQueryUI example Draggable + Sortable ( http://jqueryui.com/demos/draggable/sortable.html ) to make
I have an extended UITextField (added a NSString property, inputType to it) to take
I made an activity extended from ExpandableListActivity with ExpandableListView. I added a button into
I extended the User model in django to include several other variables, such as
I extended JDialog to create a custom dialog where the user must fill some
I extended the JAAS javax.security.auth.spi.LoginModule, and installed it into a WAS server. It works;

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.