发生Playframework调用TargetException:null

发生Playframework调用TargetException:null,playframework,java.util.concurrent,invocationtargetexception,Playframework,Java.util.concurrent,Invocationtargetexception,我扩展了聊天示例,每5秒钟添加一条保持活动状态的消息。如果我调试并通过断点运行代码,它会运行得很好。但是,如果我只是运行应用程序,它会崩溃,日志如下: // Loop while the socket is open while (inbound.isOpen()) { // Wait for an event (either something coming on the inbound // socket channel, o

我扩展了聊天示例,每5秒钟添加一条保持活动状态的消息。如果我调试并通过断点运行代码,它会运行得很好。但是,如果我只是运行应用程序,它会崩溃,日志如下:

// 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();
            }
        }

我知道这与并发性有关。如何防止死锁?

我犯的错误是在事件流中发送JPA模型。从导致崩溃的不同线程调用的。我修改了代码,在事件流或简单对象上发送json字符串类型

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