users@tyrus.java.net

Re: CDI Interceptor on a WebSocket endpoint

From: Stepan Kopriva <stepan.kopriva_at_oracle.com>
Date: Mon, 18 Feb 2013 20:29:22 +0100

Hi Arun,

could you send me the case you are deploying please? I will take a look.

Stepan


On Feb 17, 2013, at 2:42 AM, Arun Gupta <arun.p.gupta_at_oracle.com> wrote:

> Deployed a POJO endpoint as defined at:
>
> @WebSocketEndpoint(value="/websocket-cdi")
> @Logging
> public class MyEndpointWithCDI {
>
> @Inject MyBean bean;
>
> @WebSocketMessage
> public String sayHello(String name) {
> return bean.sayHello(name);
> }
> }
>
> @Logging is a standard CDI interceptor with @AroundInvoke and MyBean is a POJO. Deploying this application throws the following exception:
>
> INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint_at_361cb3dd
> INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint_at_23a18c70
> SEVERE: Exception during invocation of InjectionManager.destroyManagedObject on org.glassfish.tyrus.servlet.TyrusServletFilter_at_2add39c5 of web module StandardEngine[glassfish-web].StandardHost[server].StandardContext[/injection]
> java.lang.IllegalStateException: Unknown JCDI-enabled managed bean org.glassfish.tyrus.servlet.TyrusServletFilter_at_2add39c5 of class class org.glassfish.tyrus.servlet.TyrusServletFilter
> at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:622)
> at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:439)
> at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:414)
> at com.sun.web.server.WebContainerListener.preDestroy(WebContainerListener.java:186)
> at com.sun.web.server.WebContainerListener.containerEvent(WebContainerListener.java:151)
> at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1579)
> at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:334)
> at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:5322)
> at org.apache.catalina.core.StandardContext.stop(StandardContext.java:6085)
>
> Invoking the endpoint throws the following message in server.log:
>
> SEVERE: No valid EE environment for injection of org.glassfish.injection.MyEndpointWithCDI
> SEVERE: No valid EE environment for injection of org.glassfish.injection.MyBean
>
> However the communication between client and endpoint works as expected.
>
> What should happen if a CDI interceptor is enabled on a WebSocket endpoint ?
>
> Arun
>
> --
> http://twitter.com/arungupta
> http://blogs.oracle.com/arungupta
>