1

채팅 예제를 확장하고 5 초마다 "stay-alive"메시지를 추가했습니다. 브레이크 포인트를 통해 코드를 디버깅하고 실행하면 완벽하게 실행됩니다. 여기Playframework InvocationTargetException이 발생했습니다 : null

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

를 전체 로그입니다 : 난 그냥 응용 프로그램을 실행하는 경우에는 그 아래의 로그와 충돌

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 

내가 동시성 함께 할 수있는 뭔가 함께 할 수있는 자사의 GOT 알고있다. 죽은 자물쇠를 막기 위해 무엇을해야합니까?

답변

0

실수로 내가 만든 것은 이벤트 스트림에서 JPA 모델을 보내는 것이 었습니다. 충돌을 일으키는 다른 스레드에서 호출되고있었습니다. 이벤트 스트림이나 간단한 객체에 json (문자열 유형)을 보내도록 코드를 수정했습니다.

관련 문제