tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berner Martin <>
Subject JAX-WS without EJB (Stateless) but with CDI
Date Wed, 21 Aug 2013 08:32:07 GMT
I have a Project for serving a JAX-WS Service.
Data is stored in a Oracle Database 11g.
In other Webprojects we discovered that it is a god Idea to have a EntityManager per Request
and per Service.

Simply annotate the Class BgsQualitas with @WebService produces the following Exception:
java.lang.IllegalArgumentException: Could not find servlet ch.qualitasag.BgsQualitas.BgsQualitas
in web application context /BgsQualitas
       at org.apache.tomee.webservices.TomcatWsRegistry.setWsContainer(
       at org.apache.openejb.server.webservices.WsService.afterApplicationCreated(
       at org.apache.tomee.webservices.TomeeJaxWsService.afterApplicationCreated(
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
       at java.lang.reflect.Method.invoke(
       at org.apache.openejb.loader.SystemInstance.fireEvent(
       at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(
       at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
       at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(
       at org.apache.catalina.util.LifecycleBase.setStateInternal(
       at org.apache.catalina.util.LifecycleBase.start(
       at org.apache.catalina.core.ContainerBase$
       at org.apache.catalina.core.ContainerBase$
       at java.util.concurrent.FutureTask$Sync.innerRun(
       at java.util.concurrent.ThreadPoolExecutor.runWorker(
       at java.util.concurrent.ThreadPoolExecutor$

So I added @Stateles as mentioned in the TomEE documentation (
But this makes it a EJB which I'm not familiar with.

In BgsQualitas I inject a Bean "DataService" which is annotated @RequestScoped and has itself
injected an EntityManager with @PersistenceContext to access the Database.
Although DataService is every request an new Bean, EntityManager isn't.

I think it has to do whit the EJB, where I don't really understand the Lifecycles of such
a Beans and its Dependencies. But I can't get it work without the @Stateless.
How do I do this. Or how do I influence the Lifetime of the injected EntityManager.

A Way to do this, is to write my one Producer of EntityManager in which I inject a EntityManagerFactory
and manage the Lifecycle myself.
But if it is possible to do this in a simpler Way, I well preferred this.

Best Regards
Martin Berner

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message