質問編集履歴
1
エラー内容を詳しく記載いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,18 +1,44 @@
|
|
1
|
-
Javaで簡単なWebSocketサーバを作成しようとしています。
|
1
|
+
tyrusを使用してJavaで簡単なWebSocketサーバを作成しようとしています。
|
2
2
|
|
3
|
-
以下のようにソースを書きましたが、Ec
|
3
|
+
以下のようにソースを書きましたが、Eclipse上で実行してみたところ、"エラー内容"にあるclassNotFoundExceptionエラーが出ています。
|
4
|
-
|
5
|
-
The constructor Server(String, int, String,Class<EchoServerEndPoint>というエラーが出ています。
|
6
|
-
|
7
|
-
しかし、いかのリンクを見る限り、コンストラクタの引数は合っているようにも見えます。
|
8
4
|
|
9
5
|
|
10
6
|
|
11
|
-
|
7
|
+
対応方法をご教授いただけますでしょうか??
|
12
8
|
|
13
9
|
|
14
10
|
|
11
|
+
■エラー内容
|
12
|
+
|
13
|
+
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContainer
|
14
|
+
|
15
|
+
at org.glassfish.tyrus.spi.ServerContainerFactory.createServerContainer(ServerContainerFactory.java:85)
|
16
|
+
|
17
|
+
at org.glassfish.tyrus.server.Server.start(Server.java:222)
|
18
|
+
|
15
|
-
|
19
|
+
at EchoMain.main(EchoMain.java:17)
|
20
|
+
|
21
|
+
Caused by: java.lang.ClassNotFoundException: org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContainer
|
22
|
+
|
23
|
+
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
|
24
|
+
|
25
|
+
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
|
26
|
+
|
27
|
+
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
|
28
|
+
|
29
|
+
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
|
30
|
+
|
31
|
+
at org.glassfish.tyrus.spi.ServerContainerFactory.createServerContainer(ServerContainerFactory.java:80)
|
32
|
+
|
33
|
+
... 2 more
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
■tyrusの取得元
|
38
|
+
|
39
|
+
https://tyrus.java.net/dependencies.html
|
40
|
+
|
41
|
+
上記リンクのWebSocket RI archiveリンクからダウンロードし、api, ext,lib配下のjarを全てビルドパスに通しました。
|
16
42
|
|
17
43
|
|
18
44
|
|
@@ -23,6 +49,10 @@
|
|
23
49
|
|
24
50
|
|
25
51
|
```EchoServerEndPoint.java
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
26
56
|
|
27
57
|
|
28
58
|
|
@@ -44,35 +74,35 @@
|
|
44
74
|
|
45
75
|
|
46
76
|
|
47
|
-
|
77
|
+
@OnOpen
|
48
78
|
|
49
|
-
|
79
|
+
public void onOpen(Session session) {
|
50
80
|
|
51
|
-
|
81
|
+
System.out.println("[open] " + session);
|
52
82
|
|
53
|
-
|
83
|
+
}
|
54
84
|
|
55
85
|
|
56
86
|
|
57
|
-
|
87
|
+
@OnMessage
|
58
88
|
|
59
|
-
|
89
|
+
public String onMessage(String message, Session session) {
|
60
90
|
|
61
|
-
|
91
|
+
System.out.println("[" + message + "] " + session);
|
62
92
|
|
63
|
-
|
93
|
+
return message;
|
64
94
|
|
65
|
-
|
95
|
+
}
|
66
96
|
|
67
97
|
|
68
98
|
|
69
|
-
|
99
|
+
@OnClose
|
70
100
|
|
71
|
-
|
101
|
+
public void onClose(Session session) {
|
72
102
|
|
73
|
-
|
103
|
+
System.out.println("[close] " + session);
|
74
104
|
|
75
|
-
|
105
|
+
}
|
76
106
|
|
77
107
|
}
|
78
108
|
|
@@ -84,7 +114,15 @@
|
|
84
114
|
|
85
115
|
import java.io.IOException;
|
86
116
|
|
117
|
+
import java.util.Collections;
|
118
|
+
|
119
|
+
import java.util.Map;
|
120
|
+
|
121
|
+
|
122
|
+
|
87
123
|
import javax.websocket.DeploymentException;
|
124
|
+
|
125
|
+
|
88
126
|
|
89
127
|
import org.glassfish.tyrus.server.Server;
|
90
128
|
|
@@ -94,9 +132,15 @@
|
|
94
132
|
|
95
133
|
|
96
134
|
|
97
|
-
public static void main(String[] args) throws Exception
|
135
|
+
public static void main(String[] args) throws DeploymentException,
|
98
136
|
|
137
|
+
IOException {
|
138
|
+
|
139
|
+
Map<String, Object> properties = Collections.emptyMap();
|
140
|
+
|
99
|
-
Server server = new Server("localhost", 8080, "/ws",
|
141
|
+
Server server = new Server("localhost", 8080, "/ws", properties,
|
142
|
+
|
143
|
+
EchoServerEndPoint.class);
|
100
144
|
|
101
145
|
try {
|
102
146
|
|