https://issues.apache.org/bugzilla/show_bug.cgi?id=54805
Bug ID: 54805
Summary: [jsr 356] javax.websocket.server.ServerContainer is
null when Servlet.init(ServletContext)
Product: Tomcat 8
Version: trunk
Hardware: PC
OS: Mac OS X 10.4
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Classification: Unclassified
Using the following code:
public class JSR356AsyncSupport extends Servlet30CometSupport {
public JSR356AsyncSupport(AtmosphereConfig config) {
super(config);
Object serverContainer =
config.getServletContext().getAttribute("javax.websocket.server.ServerContainer");
if (serverContainer != null) {
try {
ServerContainer.class.cast(serverContainer).addEndpoint(JSR356ServerEndpointConfig.class);
} catch (DeploymentException e) {
e.printStackTrace();
}
}
}
}
The attribute is always null when calling ServletContext during the
Servlet.init() operation. From the javadoc:
===
The ServerContainer is the specialized view of the WebSocketContainer available
in server-side deployments. There is one ServerContainer instance per websocket
application. The ServerContainer holds the methods to be able to register
server endpoints during the initialization phase of the application.
For websocket enabled web containers, developers may obtain a reference to the
ServerContainer instance by retrieving it as an attribute named
javax.websocket.server.ServerContainer on the ServletContext. This way, the
registration methods held on this interface may be called to register server
endpoints from a ServletContextListener during the deployment of the WAR file
containing the endpoint.
===
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]