see my responses below...

On Sat, Nov 9, 2013 at 1:38 AM, zeeman <[email protected]> wrote:

>
> I'm using Tomee latest snapshot (from yesterday) with JSF and Deltaspike
> .5.
> All on Apache stack with Hibernate 4.2.7.sp1
>

are you mentioning TomEE latest version, because this exception did not
occur with previous versions of TomEE 1.6.0 snapshot?


>
> I have a view scoped bean that gets called from from UI, then it saves to
> DB, and calls an EJB async.


per your code below, it seems as though you are doing an EJB async, first,
and then save to DB inside of your @Asynchronous method.



> I get below error if I click fast enough on link from UI.
>

that's interesting that you would test the speed of your /asynchronous/
commits. :)


>
> @Singleton
> public class SocialNotificationHandler implements Serializable {
>
> @PersistenceContext(unitName = PersistenceConfiguration.UNIT_NAME)
> private EntityManager entityManager;
>
>         @Asynchronous
>         public void handleAsyncSocialLike(UUID memId) {
>
>                         MemberSocialNotification notification = new
> MemberSocialNotification(memId);
>                         entityManager.persist(notification);
>
>
>         }
>
> }
>
>
> look at what you're doing above. You are instantiating a
@PersistenceContext inside your @Singleton, and then you assume/expect to
be able to use entityManager.persist(...) inside of an @Asynchronous
method...which obviously executes 'after' @Singleton bean/transaction is
invoked. I would assume that the entityManager belongs to the @Singleton
and does not belong to the @Asynchronous thread that is invoked 'after'
@Singleton is referenced and transaction should close 'prior' to
@Asynchronous executing. someone can correct me though, please. :)

the exception below says that the pooled connection closed during/while
asynchronous call/thread was executing/running.


>         at
>
> org.apache.openejb.async.AsynchronousPool$AsynchronousCall.call(AsynchronousPool.java:110)
>         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>         at java.util.concurrent.FutureTask.run(Unknown Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Unknown Source)
> Caused by: java.sql.SQLException: PooledConnection has already been closed.
>         at
>
> org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:86)
>         at $Proxy87.rollback(Unknown Source)
>         at
>
> org.apache.openejb.resource.jdbc.managed.local.LocalXAResource.rollback(LocalXAResource.java:158)
>         ... 18 more
>
>
>
I usually do entityManager.persist() in @Stateless @EJB, and I would never
add @Asynchronous inside of @Stateless @EJB. @Stateless @EJB is already
quite fast, so do your persist inside of your @EJB instead of persist()
inside of a @Singleton @Asynchronous (thread).

Reply via email to