Websocket giving 404 in jboss4.2 and weblogic -
below example tried websocket,
import java.io.ioexception; import java.util.queue; import java.util.concurrent.concurrentlinkedqueue; import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.future; import javax.websocket.onclose; import javax.websocket.onerror; import javax.websocket.onmessage; import javax.websocket.onopen; import javax.websocket.session; import javax.websocket.server.serverendpoint; @serverendpoint("/socket") public class examplewebsocket { private static queue<session> queue = new concurrentlinkedqueue<session>(); @onmessage public void onmessage(session session, string msg) { try { system.out.println("received msg "+msg+" "+session.getid()); executorservice executorservice = executors .newfixedthreadpool(1); threadclass newthread = new threadclass(session); // thread class going perform async operations future<string> fut = executorservice.submit(newthread); int =10; while(fut.isdone()){ if(i > 50){ fut.cancel(true); return; } thread.sleep(1000); i++; } executorservice.shutdown(); } catch (exception e) { e.printstacktrace(); } } @onopen public void open(session session) { queue.add(session); system.out.println("new session opened: "+session.getid()); } @onerror public void error(session session, throwable t) { queue.remove(session); system.err.println("error on session "+session.getid()); } @onclose public void closedconnection(session session) throws ioexception { queue.remove(session); system.out.println("session closed: "+session.getid()); } }
i added below dependency in jar,
<dependency> <groupid>javax.websocket</groupid> <artifactid>javax.websocket-api</artifactid> <version>1.1</version> </dependency>
for example, getting 404 when tried hit browser. our project runs spring 3.2. have add class config in xml files we.xml.. totally stuck here.
also tried adding <scope>provided</scope>
in dependency of javax.websocket-api deployment getting failed class not found exception.
websocket not supported servers of lower version. below rul provide list of websocket supported web servers. https://github.com/atmosphere/atmosphere/wiki/supported-webservers-and-browsers
Comments
Post a Comment