tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de.INVALID>
Subject Re: JAX-RS integration with managed beans
Date Sat, 05 May 2018 08:37:24 GMT
Hi!

+1 for @javax.annotation.ManagedBean is a mess in the spec.

I still remember how this got added to EE6. This annotation literally got added to EE6 in
the last week before the spec went final.
It was not discussed in the CDI, EJB and JSF Expert Groups and just had a single mention in
an umbrella meeting. 
It's also totally unspecified how it should behave. With other words: this annotation is a
total mess and should have never been added to any official spec in the first place. 

Oh and be careful, there are multiple packages which contain a @ManagedBean annotation! There
is e.g. @javax.faces.ManagedBean as well. This one predates CDI and at least back then had
it's place (for a short period in time). It should not have any effect on JAX-RS resources
though but would only be valid on JSF managed beans. In the meantime this now also got deprecated
by the JSF spec in favour of CDI.

So +1 to Romains suggestion to just make your JAX-RS resource a CDI bean and annotate it with
@javax.enterprise.context.ApplicationScoped.

LieGrue,
strub

> Am 05.05.2018 um 08:20 schrieb Romain Manni-Bucau <rmannibucau@gmail.com>:
> 
> Ok
> 
> managedbean are not that standardized and our impl is close to @Stateful
> 
> This is why i mentionned you can want to move to @Singleton, @Stateless or
> better @ApplicationScoped or @RequestScoped
> 
> 
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau>
|
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
> 
> 2018-05-05 0:23 GMT+02:00 kkriszti <kriszti.kozma@gmail.com>:
> 
>> Hi,
>> 
>> I have added stacktrace too in HTML format but it seems to be vanished
>> after
>> preview!
>> So here again:
>> May 04, 2018 6:09:20 PM org.apache.cxf.phase.PhaseInterceptorChain
>> doDefaultLogging
>> WARNING: Application {http://example.com/}MyService has thrown exception,
>> unwinding now
>> org.apache.cxf.interceptor.Fault: org.apache.openejb.SystemException:
>> java.lang.NullPointerException: Cannot obtain an instance of the stateful
>> session bean with a null session id: Cannot obtain an instance of the
>> stateful session bean with a null session id:
>> java.lang.NullPointerException: Cannot obtain an instance of the stateful
>> session bean with a null session id: Cannot obtain an instance of the
>> stateful session bean with a null session id
>>        at
>> org.apache.cxf.service.invoker.AbstractInvoker.
>> createFault(AbstractInvoker.java:162)
>>        at
>> org.apache.cxf.service.invoker.AbstractInvoker.
>> invoke(AbstractInvoker.java:128)
>>        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
>>        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
>>        at
>> org.apache.openejb.server.cxf.rs.AutoJAXRSInvoker.invoke(
>> AutoJAXRSInvoker.java:68)
>>        at
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.
>> run(ServiceInvokerInterceptor.java:57)
>>        at
>> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(
>> ServiceInvokerInterceptor.java:93)
>>        at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
>> PhaseInterceptorChain.java:263)
>>        at
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(
>> ChainInitiationObserver.java:121)
>>        at
>> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(
>> AbstractHTTPDestination.java:240)
>>        at
>> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(
>> CxfRsHttpListener.java:227)
>>        at
>> org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(
>> CXFJAXRSFilter.java:94)
>>        at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> ApplicationFilterChain.java:241)
>>        at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> ApplicationFilterChain.java:208)
>>        at org.apache.tomcat.websocket.server.WsFilter.doFilter(
>> WsFilter.java:52)
>>        at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> ApplicationFilterChain.java:241)
>>        at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> ApplicationFilterChain.java:208)
>>        at
>> org.apache.catalina.core.StandardWrapperValve.invoke(
>> StandardWrapperValve.java:220)
>>        at
>> org.apache.catalina.core.StandardContextValve.invoke(
>> StandardContextValve.java:122)
>>        at org.apache.tomee.catalina.OpenEJBValve.invoke(
>> OpenEJBValve.java:44)
>>        at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(
>> AuthenticatorBase.java:505)
>>        at
>> org.apache.catalina.core.StandardHostValve.invoke(
>> StandardHostValve.java:169)
>>        at
>> org.apache.catalina.valves.ErrorReportValve.invoke(
>> ErrorReportValve.java:103)
>>        at
>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
>>        at
>> org.apache.catalina.core.StandardEngineValve.invoke(
>> StandardEngineValve.java:116)
>>        at
>> org.apache.catalina.connector.CoyoteAdapter.service(
>> CoyoteAdapter.java:436)
>>        at
>> org.apache.coyote.http11.AbstractHttp11Processor.process(
>> AbstractHttp11Processor.java:1078)
>>        at
>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.
>> process(AbstractProtocol.java:625)
>>        at
>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.
>> run(JIoEndpoint.java:316)
>>        at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(
>> ThreadPoolExecutor.java:1145)
>>        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(
>> ThreadPoolExecutor.java:615)
>>        at
>> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(
>> TaskThread.java:61)
>>        at java.lang.Thread.run(Thread.java:745)
>> Caused by: org.apache.openejb.ApplicationException:
>> org.apache.openejb.SystemException: java.lang.NullPointerException: Cannot
>> obtain an instance of the stateful session bean with a null session id:
>> Cannot obtain an instance of the stateful session bean with a null session
>> id: java.lang.NullPointerException: Cannot obtain an instance of the
>> stateful session bean with a null session id: Cannot obtain an instance of
>> the stateful session bean with a null session id
>>        at
>> org.apache.openejb.core.transaction.EjbTransactionUtil.
>> handleApplicationException(EjbTransactionUtil.java:125)
>>        at
>> org.apache.openejb.core.managed.ManagedContainer.handleException(
>> ManagedContainer.java:750)
>>        at
>> org.apache.openejb.core.managed.ManagedContainer.businessMethod(
>> ManagedContainer.java:620)
>>        at
>> org.apache.openejb.core.managed.ManagedContainer.
>> invoke(ManagedContainer.java:352)
>>        at org.apache.openejb.util.proxy.ProxyEJB$Handler.invoke(
>> ProxyEJB.java:74)
>>        at
>> com.example.MyService$$LocalBeanProxy.sayPlainTextHello(com/example/
>> MyService.java)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> 57)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> DelegatingMethodAccessorImpl.java:43)
>>        at java.lang.reflect.Method.invoke(Method.java:606)
>>        at
>> org.apache.openejb.server.cxf.rs.PojoInvoker.
>> performInvocation(PojoInvoker.java:43)
>>        at
>> org.apache.cxf.service.invoker.AbstractInvoker.
>> invoke(AbstractInvoker.java:96)
>>        ... 31 more
>> Caused by: org.apache.openejb.SystemException:
>> java.lang.NullPointerException: Cannot obtain an instance of the stateful
>> session bean with a null session id: Cannot obtain an instance of the
>> stateful session bean with a null session id
>>        at
>> org.apache.openejb.core.managed.ManagedContainer.obtainInstance(
>> ManagedContainer.java:633)
>>        at
>> org.apache.openejb.core.managed.ManagedContainer.businessMethod(
>> ManagedContainer.java:589)
>>        ... 40 more
>> Caused by: java.lang.NullPointerException: Cannot obtain an instance of
>> the
>> stateful session bean with a null session id
>>        ... 42 more
>> 
>> I have the following:
>> @Path("/myService")
>> @ManagedBean
>> public class MyService {...}
>> 
>> I was also trying apache-tomee-webprofile-7.0.2 with same result.
>> 
>> 
>> Regards,
>> Krisztina
>> 
>> 
>> 
>> --
>> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
>> f979441.html
>> 


Mime
View raw message