긍정의힘!
50
2019-09-27 18:11:37
0
204

websockt 사용시 type 변환 오류 (Collections.synchronizedList)


안녕하세요.

웹소캣을 이용하여 채팅방 구현을 하려고 합니다.

소스는 아래와 같은데요

유저집합 저장하는 List  부분에서 에러가 계속 발생합니다.


import java.io.IOException;

import java.io.StringWriter;

import java.util.ArrayList;

import java.util.Collections;

import java.util.Iterator;

import java.util.List;

import javax.json.Json;

import javax.json.JsonObject;

import javax.json.JsonWriter;

import javax.websocket.OnClose;

import javax.websocket.OnMessage;

import javax.websocket.OnOpen;

import javax.websocket.Session;

import javax.websocket.server.ServerEndpoint;



@ServerEndpoint("/broadsocket")

public class broadsocket {

  //유저 집합 리스트

  static List<Session> sessionUsers = Collections.synchronizedList(new ArrayList<>());

  


  위와 같은 경우 x표시가 나면서  Type mismatch: cannot convert from List<Object> to List<Session>    오류가 발생합니다.

 

그래서 아래와 같이 변경후 톰캣을 실행하면 

static List<Object> sessionUsers = Collections.synchronizedList(new ArrayList<>());


톰캣 실행이 안되면서 Server Tomcat v7.0 Server at localhost failed to start. 메세지가 나옵니다.


console 에러내용은 아래와 같습니다.


Sep 27, 2019 6:08:37 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent

정보: Loaded APR based Apache Tomcat Native library 1.2.23 using APR version 1.7.0.

Sep 27, 2019 6:08:37 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent

정보: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

Sep 27, 2019 6:08:37 PM org.apache.catalina.core.AprLifecycleListener initializeSSL

정보: OpenSSL successfully initialized (OpenSSL 1.1.1d  10 Sep 2019)

Sep 27, 2019 6:08:37 PM org.apache.coyote.AbstractProtocol init

정보: Initializing ProtocolHandler ["http-apr-8080"]

Sep 27, 2019 6:08:37 PM org.apache.coyote.AbstractProtocol init

정보: Initializing ProtocolHandler ["ajp-apr-8009"]

Sep 27, 2019 6:08:37 PM org.apache.catalina.startup.Catalina load

정보: Initialization processed in 894 ms

Sep 27, 2019 6:08:37 PM org.apache.catalina.core.StandardService startInternal

정보: Starting service Catalina

Sep 27, 2019 6:08:37 PM org.apache.catalina.core.StandardEngine startInternal

정보: Starting Servlet Engine: Apache Tomcat/7.0.96

Sep 27, 2019 6:08:37 PM org.apache.catalina.startup.TldConfig execute

정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

Sep 27, 2019 6:08:38 PM org.apache.catalina.startup.TldConfig execute

정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

Sep 27, 2019 6:08:38 PM org.apache.catalina.core.ContainerBase startInternal

심각: A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:188)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1243)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:829)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

... 6 more

Caused by: java.lang.NoClassDefFoundError: javax/json/JsonStructure

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)

at java.lang.Class.getDeclaredMethods(Class.java:1868)

at org.apache.tomcat.websocket.pojo.PojoMethodMapping.<init>(PojoMethodMapping.java:86)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:195)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:320)

at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:150)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5709)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 6 more

Caused by: java.lang.ClassNotFoundException: javax.json.JsonStructure

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)

... 15 more


Sep 27, 2019 6:08:38 PM org.apache.catalina.core.ContainerBase startInternal

심각: A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:188)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1243)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:758)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.startup.Catalina.start(Catalina.java:711)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1254)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:829)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 6 more

Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:188)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1243)

... 8 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

... 6 more

Caused by: java.lang.NoClassDefFoundError: javax/json/JsonStructure

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)

at java.lang.Class.getDeclaredMethods(Class.java:1868)

at org.apache.tomcat.websocket.pojo.PojoMethodMapping.<init>(PojoMethodMapping.java:86)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:195)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:320)

at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:150)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5709)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 6 more

Caused by: java.lang.ClassNotFoundException: javax.json.JsonStructure

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)

... 15 more


Sep 27, 2019 6:08:38 PM org.apache.catalina.startup.Catalina start

심각: The required Server component failed to start so Tomcat is unable to start.

org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.startup.Catalina.start(Catalina.java:711)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:758)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 7 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 9 more

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1254)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 11 more

Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:188)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1243)

... 13 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1254)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:829)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 6 more

Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:188)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1243)

... 8 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebSocketEx]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

... 6 more

Caused by: java.lang.NoClassDefFoundError: javax/json/JsonStructure

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)

at java.lang.Class.getDeclaredMethods(Class.java:1868)

at org.apache.tomcat.websocket.pojo.PojoMethodMapping.<init>(PojoMethodMapping.java:86)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:195)

at org.apache.tomcat.websocket.server.WsServerContainer.addEndpoint(WsServerContainer.java:320)

at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:150)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5709)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 6 more

Caused by: java.lang.ClassNotFoundException: javax.json.JsonStructure

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)

... 15 more


Sep 27, 2019 6:08:38 PM org.apache.coyote.AbstractProtocol pause

정보: Pausing ProtocolHandler ["http-apr-8080"]

Sep 27, 2019 6:08:38 PM org.apache.coyote.AbstractProtocol pause

정보: Pausing ProtocolHandler ["ajp-apr-8009"]

Sep 27, 2019 6:08:38 PM org.apache.catalina.core.StandardService stopInternal

정보: Stopping service Catalina

Sep 27, 2019 6:08:38 PM org.apache.coyote.AbstractProtocol destroy

정보: Destroying ProtocolHandler ["http-apr-8080"]

Sep 27, 2019 6:08:38 PM org.apache.coyote.AbstractProtocol destroy

정보: Destroying ProtocolHandler ["ajp-apr-8009"] 


  



아래와 같이 해봐도 톰캣 에러 발생합니다.
static List<Session> sessionUsers = Collections.synchronizedList(new ArrayList<Session>());


0
  • 답변 0

  • 로그인을 하시면 답변을 등록할 수 있습니다.