warp-persist-2.0-20090214.zip / entitymanager closed?

20 views
Skip to first unread message

nino martinez wael

unread,
May 29, 2010, 2:20:52 AM5/29/10
to warp...@googlegroups.com
Hi

What could cause entitymanager to be closed, I am following this guide :

http://www.atomicgamer.com/dev/2009/10/wicket-guice-2-0-warp-persist-2-0/

-Regards Nino

nino martinez wael

unread,
May 30, 2010, 1:03:22 PM5/30/10
to warp...@googlegroups.com
Never mind i think is caused by my usage @inject on setters instead of
the field in combination with the Wicket Guice IOC

2010/5/29 nino martinez wael <nino.mart...@gmail.com>:

Dhanji R. Prasanna

unread,
May 30, 2010, 2:43:01 PM5/30/10
to warp...@googlegroups.com
OK sounds great!

--
You received this message because you are subscribed to the Google Groups "warp-core" group.
To post to this group, send email to warp...@googlegroups.com.
To unsubscribe from this group, send email to warp-core+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/warp-core?hl=en.


nino martinez wael

unread,
Jun 24, 2010, 9:27:23 AM6/24/10
to warp...@googlegroups.com
Im still messing around with this problem. I don't think it has anything todo with wicket anymore..

It has something todo with the @transactional annotation not being picked up correctly or something, this code works, of course the uow could just be removed as it seems it does nothing:

@Override
    @Transactional
    public void create(Object o) {
        logger.debug("creating object");
        unitOfWork.beginWork();
        EntityManager createEntityManager = getEntityManager();
        createEntityManager.
getTransaction().begin();

        createEntityManager.persist(o);
        createEntityManager.flush();
        createEntityManager.getTransaction().commit();
        unitOfWork.endWork();

    }

However if I follow this path, it seems my entities get's detached...


2010/5/30 Dhanji R. Prasanna <dha...@gmail.com>

yaniv kessler

unread,
Jun 24, 2010, 1:06:23 PM6/24/10
to warp...@googlegroups.com
Nino and I had a remote session on his computer I'm scraching my head ever since, because I ran into a similar issue earlier this year, though god help me I don't remember how I made it go away.

Come to think of it, @transactional doesn't count in OSVI paradigm no ?

This means something isn't configured right or there is a problem with the PersistenceFilter ? 

Are we on track here ? :)

Dhanji R. Prasanna

unread,
Jun 24, 2010, 6:26:05 PM6/24/10
to warp...@googlegroups.com
Make sure it's not on private methods, and debug to check that
JpaLocalTxnInterceptor is in the call trace of your @transactional
method?

Dhanji

yaniv kessler

unread,
Jun 24, 2010, 6:59:36 PM6/24/10
to warp...@googlegroups.com
JpaLocalTxnInterceptor is in the call stack and those methods aren't private

Dhanji R. Prasanna

unread,
Jun 24, 2010, 8:25:27 PM6/24/10
to warp...@googlegroups.com
Are you using the PersistenceFilter? Is this a webapp?

yaniv kessler

unread,
Jun 24, 2010, 11:36:45 PM6/24/10
to warp...@googlegroups.com
Aye it is

Dhanji R. Prasanna

unread,
Jun 24, 2010, 11:44:25 PM6/24/10
to warp...@googlegroups.com
You should check to make sure that UnitOfWork is set to Request and if using hibernate set the currentsession context to "managed"
Also ensure that you're using Provider<EntityManager> and not directly injecting it.

Dhanji.

yaniv kessler

unread,
Jun 25, 2010, 12:43:19 AM6/25/10
to warp...@googlegroups.com
The Provider<EntityManager> was nino's first problem but I told him about that in our remote session, I also saw he module declaration and he is using UnitOfWork.Request

The only diff is that he is using JPA and hibernate as a provider and not hibernate directly

Dhanji R. Prasanna

unread,
Jun 25, 2010, 12:50:24 AM6/25/10
to warp...@googlegroups.com
and you're sure you've set the currentsession_context property to "managed" ?

nino martinez wael

unread,
Jun 25, 2010, 2:51:59 AM6/25/10
to warp...@googlegroups.com
Hmm no, where do I set that property? In persistence.xml?


2010/6/25 Dhanji R. Prasanna <dha...@gmail.com>

Dhanji R. Prasanna

unread,
Jun 25, 2010, 4:57:59 AM6/25/10
to warp...@googlegroups.com
Yea, look up the hibernate docs. 

Or you can check out warp-persist docs on http://www.wideplay.com which describes the using hibernate bit.

nino martinez wael

unread,
Jun 25, 2010, 5:25:34 AM6/25/10
to warp...@googlegroups.com
Im using JPA, so I need todo this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="codan-jpa" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>


        <class>..</class>

        <properties>
----->     <property name="hibernate.current_session_context_class" value="managed" />
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
            <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver" />
            <property name="hibernate.c3p0.min_size" value="5" />
            <property name="hibernate.c3p0.max_size" value="20" />
            <property name="hibernate.c3p0.timeout" value="300" />
            <property name="hibernate.c3p0.max_statements" value="50" />
            <property name="hibernate.c3p0.idle_test_period" value="3000" />
            <!--
                use create-drop to start with a fresh database (if the entities
                changed)
            -->
            <!--<property name="hibernate.hbm2ddl.auto" value="create-drop"/>-->
            <property name="hibernate.hbm2ddl.auto" value="validate" />
        </properties>
    </persistence-unit>
</persistence>

nino martinez wael

unread,
Jun 25, 2010, 8:03:43 AM6/25/10
to warp...@googlegroups.com
BTW tried it out, made no difference.. The error I am getting are something like "Fatal error :failed to lazily initialize a collection of role: *Entity*, no session or session was closed or
java.lang.IllegalArgumentException: Removing a detached instance *entity*#801
Even though they have been loaded during the same request (I am using detachable models in wicket)...

2010/6/25 nino martinez wael <nino.mart...@gmail.com>

Dhanji R. Prasanna

unread,
Jun 26, 2010, 5:52:04 AM6/26/10
to warp...@googlegroups.com
Ahh, you're doing something beyond warp-persist then. You should track this down in the wicket or hibernate forums. 

I do not recommend detaching an instance during a request (or at all for that matter).

Dhanji.

yaniv kessler

unread,
Jun 26, 2010, 8:37:02 AM6/26/10
to warp...@googlegroups.com
But if session is closed during a request, which may indicate it was never opened in the first place, doesn't it mean he did something wrong with respect to warp? (some configuration or something) or that there is a problem with the PersistenceFilter?

Dhanji R. Prasanna

unread,
Jun 26, 2010, 7:29:35 PM6/26/10
to warp...@googlegroups.com
No the issue is with how you are sharing detached objects. warp-persist is really kinda hard to mess up configuration-wise. The only possibility is that you may be registering PersistenceFilter *below* WicketFilter (or below Sitemesh or whatever is trying to expand that collection that is detached), but this is an obvious one to catch.

Dhanji.

nino martinez wael

unread,
Jun 27, 2010, 1:23:19 PM6/27/10
to warp...@googlegroups.com
Hmm but the problem are that I do not detach anything during request and it's during the same request this problem shows up.

The detachable models in wicket are necessary to use if you want a "light" memory foot print or else you could end up saving the whole graph to disk. Im not doing anything fancy in this project.. :(


regards Nino

2010/6/26 Dhanji R. Prasanna <dha...@gmail.com>

nino martinez wael

unread,
Jun 27, 2010, 1:24:49 PM6/27/10
to warp...@googlegroups.com
Yeah caught this one early on and is fixed.. Well im almost at the point where im ready to rebuild the project to see where it went wrong..

regards Nino

2010/6/27 Dhanji R. Prasanna <dha...@gmail.com>

yaniv kessler

unread,
Jun 27, 2010, 1:27:45 PM6/27/10
to warp...@googlegroups.com
I'd try with a simple model just to rule out the possibility that it is the source of the problem, though I doubt it.

nino martinez wael

unread,
Jun 28, 2010, 5:27:03 AM6/28/10
to warp...@googlegroups.com
Hmm, yeah.. But have been using this approach for serveral years and have had no problems.. But will try it and report back the out come..

regards Nino

2010/6/27 yaniv kessler <yan...@gmail.com>

Dhanji R. Prasanna

unread,
Jun 28, 2010, 6:17:11 AM6/28/10
to warp...@googlegroups.com
Can you package up the app and attach it to this group? Because we have hundreds of users of warp-persist and wicket and no one has ever brought this up. We even use warp-persist internally at Google for some things, and this kind of thing has never been an issue. I'll wager it's something very simple like a leaked reference or something else in the wicket/hibernate config. As I said there isn't much to wp config beyond the Guice module and the order of filters.

Dhanji.

nino martinez wael

unread,
Jun 28, 2010, 6:35:58 AM6/28/10
to warp...@googlegroups.com
Ok, will do that during this week. And never had it failing before either, I agree it's very strange..

regards Nino

2010/6/28 Dhanji R. Prasanna <dha...@gmail.com>
Reply all
Reply to author
Forward
0 new messages