Skip to content

Commit bd8e908

Browse files
committed
Fix Load class
1 parent d3a347f commit bd8e908

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/src/main/java/ua/naiksoftware/stomp/Stomp.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ public static StompClient over(Class clazz, String uri) {
2929
* @return StompClient for receiving and sending messages. Call #StompClient.connect
3030
*/
3131
public static StompClient over(Class clazz, String uri, Map<String, String> connectHttpHeaders) {
32-
if (clazz == WebSocket.class) {
33-
return createStompClient(new WebSocketsConnectionProvider(uri, connectHttpHeaders));
32+
try {
33+
if (Class.forName("org.java_websocket.WebSocket") != null && clazz == WebSocket.class) {
34+
return createStompClient(new WebSocketsConnectionProvider(uri, connectHttpHeaders));
35+
} else {
36+
throw new RuntimeException("Not supported overlay transport: " + clazz.getName());
37+
}
38+
} catch (ClassNotFoundException e) {
39+
throw new RuntimeException("Class for transport " + clazz.getName() + " not included to project", e);
3440
}
35-
36-
throw new RuntimeException("Not supported overlay transport: " + clazz.getName());
3741
}
3842

3943
private static StompClient createStompClient(ConnectionProvider connectionProvider) {

0 commit comments

Comments
 (0)