JAX-RS integration with managed beans

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

JAX-RS integration with managed beans

kkriszti
Hi,

I'm trying to migrate from WebSphere to TomEE.
I have a @ManagedBean annotated JAX-RS resource, but when I run my EAR on
apache-tomee-jaxrs-1.7.4 I'm getting below error:
Please advise.

For reference:  IBM JAX-RS 2.0 integration with managed beans
<https://www.ibm.com/support/knowledgecenter/en/SSEQTP_9.0.0/com.ibm.websphere.base.doc/ae/rwbs_jaxrs2.0_managedbeans.html>  


Thank you and regards,
Krisztina



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

Romain Manni-Bucau
Hi

Which managedbean annotation is it? Maybe use cdi integration too.

Side note: tomee 1 uses jaxrs 1, not 2 which is in tomee 7.

Le 5 mai 2018 00:07, "kkriszti" <[hidden email]> a écrit :

> Hi,
>
> I'm trying to migrate from WebSphere to TomEE.
> I have a @ManagedBean annotated JAX-RS resource, but when I run my EAR on
> apache-tomee-jaxrs-1.7.4 I'm getting below error:
> Please advise.
>
> For reference:  IBM JAX-RS 2.0 integration with managed beans
> <https://www.ibm.com/support/knowledgecenter/en/SSEQTP_9.0.
> 0/com.ibm.websphere.base.doc/ae/rwbs_jaxrs2.0_managedbeans.html>
>
>
> Thank you and regards,
> Krisztina
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
> f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

kkriszti
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
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

Romain Manni-Bucau
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 <[hidden email]>:

> 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
>
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

Mark Struberg-2
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 <[hidden email]>:
>
> 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 <[hidden email]>:
>
>> 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
>>

Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

kkriszti
In reply to this post by Romain Manni-Bucau
Hi,

I see, thank you!

I have fixed my REST app!  Tested solution on
 - apache-tomee-jaxrs-1.7.4
 - apache-tomee-webprofile-7.0.2
 - WebSphere Platform 8.5.5.11 [ND 8.5.5.11 cf111649.01] [IBMJAVA7 7.0.9.60
cf111647.02]

I got rid of the @javax.annotation.ManagedBean annotation and added the
@javax.enterprise.context.RequestScoped to my root resource class and
@javax.enterprise.context.ApplicationScoped to my
javax.ws.rs.core.Application sub-class.

I also read this:  Implement JAX-RS resources with different lifecycle
scopes
<https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.0.0/com.ibm.websphere.nd.doc/info/ae/ae/twbs_jaxrs_jcdi_lifecycle.html>  


Regards,
Krisztina



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

kkriszti
In reply to this post by Mark Struberg-2
Hi,

Thank you for highlighting this!

Grüße,
Krisztina



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

Romain Manni-Bucau
Looks good, the side note being that if you dont need the request scope,
you will get better performances with application scoped for endpoints.

Le 5 mai 2018 14:57, "kkriszti" <[hidden email]> a écrit :

> Hi,
>
> Thank you for highlighting this!
>
> Grüße,
> Krisztina
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
> f979441.html
>
Reply | Threaded
Open this post in threaded view
|

Re: JAX-RS integration with managed beans

kkriszti
Yeah, I'm considering it... actually I don't have state in that resource, so
why not.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html