Weblogic - 12.2.1 -未初始化ServerContainer !
大家好!我在weblogic 12.2.1上启动应用程序时面临一个问题,根据websocket规范,我在ServletContextListener中启动应用程序时初始化websocket端点。我使用atmosphere框架来启动websocket端点。在初始化类JSR356AsyncSupport - atmosphere中的套接字端点时,框架尝试从servletContext对象中获取属性。它没有找到它并失败....在weblogic 12.2.1/12.1.3中。然而,同样的应用程序,当部署在其他web/应用服务器,如tomcat, websphere liberty, jboss工作良好。(我正在使用jdk1.8)
(https://github.com/Atmosphere/atmosphere/blob/master/modules/cpr/src/main/java/org/atmosphere/container/JSR356AsyncSuppo..)。
我不知道如何解决这个问题-非常感激如果有人能帮助我。谢谢你。
public JSR356AsyncSupport(AtmosphereConfig config, ServletContext ctx) {
super(config);
ServerContainer container = (ServerContainer) ctx.getAttribute(ServerContainer.class.getName()); //javax.websocket.server.ServerContainer
if (container == null) {
if (ctx.getServerInfo().contains("WebLogic")) {
logger.error("{} must use JDK 1.8+ with WebSocket", ctx.getServerInfo());
}
throw new IllegalStateException("Unable to configure jsr356 at that stage. ServerContainer is null");
}
}
异常堆栈跟踪。
2016-08-16 16:10:31,459 [ WGHALBW7] [ STANDARD] [ ] [ ] (pr.DefaultAsyncSupportResolver) ERROR - Real error: Unable to configure jsr356 at that stage. ServerContainer is null
java.lang.IllegalStateException: Unable to configure jsr356 at that stage. ServerContainer is null
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:51)
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:235)
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:307)
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:293)
at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2004)
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:911)
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:835)
有点晚了,但我目前正在使用weblogic 12.1.3,虽然它确实实现了websocket协议(oracle文档,RFC 6455),不幸的是它不符合JSR356(仅从12.2.1版本及以上)。
如果您正在使用atmosphere,我已经通过微调一些atmosphere/primefaces servlet(我使用primefaces 6.0 套接字作为服务器通知)来配置一个或多或少可以工作的示例。
<servlet>
<description>PrimeFaces Push Notifications Servlet</description>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.packages</param-name>
<param-value>my.project.push</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.atmosphereHandlerPath</param-name>
<param-value>/WEB-INF/lib/_wl_cls_gen.jar</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.resumeOnBroadcast</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.websocket.suppressJSR356</param-name> <!-- les versions que tenim no son JSR356-compliant -->
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.interceptor.HeartbeatInterceptor.clientHeartbeatFrequencyInSeconds</param-name>
<param-value>20</param-value>
</init-param>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
无论如何,它真的很难实现,我正在考虑其他选择。