Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

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

Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Yip
I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 
Reply | Threaded
Open this post in threaded view
|

RE: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Casey

        Does the object in question have uninitialized collections and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.

        You can potentially work around this.

        Given an "orphan" object foo (an object whose session has been
closed)

        Session newSession = ConfigurationFactory.createSession();
        newSession.lock(orphan, LockMode.NONE);

        The above will associate the object with the new "fresh" session and
let it resolve proxies or lazy collections again.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization (Tapestry
+Hibernate)

I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Yip
In reply to this post by Patrick Yip

The object that created from the Hibernate session is a plain POJO.
Does it mean that once the hibernate session is closed, the object
became an "ophan" and would cause synchronization problem if I use it?



-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:42 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Does the object in question have uninitialized collections
and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.

        You can potentially work around this.

        Given an "orphan" object foo (an object whose session has been
closed)

        Session newSession = ConfigurationFactory.createSession();
        newSession.lock(orphan, LockMode.NONE);

        The above will associate the object with the new "fresh" session
and
let it resolve proxies or lazy collections again.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization
(Tapestry
+Hibernate)

I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Casey

        Well, it depends. If it has regular old properties then it should
work fine e.g.

        Public class soldier extends Object {
                Private String name;
                Private String rank;
        }

        Should be fine.

        If it contains collections of other objects though e.g.

        Public class platoon extends Object {
                Private String name;
                Private Set soldiers;
        }

        Then you'll have a problem. Hibernate is *very* lazy about
initializing collections of subobjects so it'll fetch the platoon object but
not actually load the soldiers until you ask for them. So if you load the
platoon on Session 1, close session 1, and then do:

        Set s = myPlatoon.getSoldiers();

        You'll throw an error because hibernate will try to initialize the
platoon collection, but no longer have access to a session.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:50 AM
To: Tapestry users
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


The object that created from the Hibernate session is a plain POJO.
Does it mean that once the hibernate session is closed, the object
became an "ophan" and would cause synchronization problem if I use it?



-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:42 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Does the object in question have uninitialized collections
and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.

        You can potentially work around this.

        Given an "orphan" object foo (an object whose session has been
closed)

        Session newSession = ConfigurationFactory.createSession();
        newSession.lock(orphan, LockMode.NONE);

        The above will associate the object with the new "fresh" session
and
let it resolve proxies or lazy collections again.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization
(Tapestry
+Hibernate)

I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Yip
In reply to this post by Patrick Yip
It's great to know that!

In my case, the POJO only contains strings and integer.

On the page that uses the object, it is purely reading the properties of
the object. There is no update at all. Do you know when and why
Hibernate try  to synchronize?  I would think that since the hibernate
session is closed but the httpsession is still open, if hibernate tried
to do synchronize the current object with the database, it will run into
trouble.

Thanks again.


-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 11:00 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Well, it depends. If it has regular old properties then it
should
work fine e.g.

        Public class soldier extends Object {
                Private String name;
                Private String rank;
        }

        Should be fine.

        If it contains collections of other objects though e.g.

        Public class platoon extends Object {
                Private String name;
                Private Set soldiers;
        }

        Then you'll have a problem. Hibernate is *very* lazy about
initializing collections of subobjects so it'll fetch the platoon object
but
not actually load the soldiers until you ask for them. So if you load
the
platoon on Session 1, close session 1, and then do:

        Set s = myPlatoon.getSoldiers();

        You'll throw an error because hibernate will try to initialize
the
platoon collection, but no longer have access to a session.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:50 AM
To: Tapestry users
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


The object that created from the Hibernate session is a plain POJO.
Does it mean that once the hibernate session is closed, the object
became an "ophan" and would cause synchronization problem if I use it?



-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:42 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Does the object in question have uninitialized collections
and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.

        You can potentially work around this.

        Given an "orphan" object foo (an object whose session has been
closed)

        Session newSession = ConfigurationFactory.createSession();
        newSession.lock(orphan, LockMode.NONE);

        The above will associate the object with the new "fresh" session
and
let it resolve proxies or lazy collections again.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization
(Tapestry
+Hibernate)

I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Patrick Casey

        It's hard to predict precisely when hibernate will try to
synchronize. The basic rule is whenever you change a persistent object,
Hibernate throws a flag that says "I have something to persist".

        At some point later (when you do a query, when you manually call
session.flush(), when the moons align, etc), Hibernate will actually try to
"push" your changes into the database.

        The key thing to get your head around (and I had trouble with it) is
that once you persist an object, Hibernate keeps an eye on it from then on
and any change to a persistent property gets writer through eventually.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 11:14 AM
To: Tapestry users
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)

It's great to know that!

In my case, the POJO only contains strings and integer.

On the page that uses the object, it is purely reading the properties of
the object. There is no update at all. Do you know when and why
Hibernate try  to synchronize?  I would think that since the hibernate
session is closed but the httpsession is still open, if hibernate tried
to do synchronize the current object with the database, it will run into
trouble.

Thanks again.


-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 11:00 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Well, it depends. If it has regular old properties then it
should
work fine e.g.

        Public class soldier extends Object {
                Private String name;
                Private String rank;
        }

        Should be fine.

        If it contains collections of other objects though e.g.

        Public class platoon extends Object {
                Private String name;
                Private Set soldiers;
        }

        Then you'll have a problem. Hibernate is *very* lazy about
initializing collections of subobjects so it'll fetch the platoon object
but
not actually load the soldiers until you ask for them. So if you load
the
platoon on Session 1, close session 1, and then do:

        Set s = myPlatoon.getSoldiers();

        You'll throw an error because hibernate will try to initialize
the
platoon collection, but no longer have access to a session.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:50 AM
To: Tapestry users
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


The object that created from the Hibernate session is a plain POJO.
Does it mean that once the hibernate session is closed, the object
became an "ophan" and would cause synchronization problem if I use it?



-----Original Message-----
From: Patrick Casey [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:42 AM
To: 'Tapestry users'
Subject: RE: Error: JTATransaction Could not register Synchronization
(Tapestry +Hibernate)


        Does the object in question have uninitialized collections
and/or
proxies references on it? If so it'll try to use the (closed) session to
resolve these references if it needs to.

        You can potentially work around this.

        Given an "orphan" object foo (an object whose session has been
closed)

        Session newSession = ConfigurationFactory.createSession();
        newSession.lock(orphan, LockMode.NONE);

        The above will associate the object with the new "fresh" session
and
let it resolve proxies or lazy collections again.

        --- Pat

-----Original Message-----
From: Patrick Yip [mailto:[hidden email]]
Sent: Friday, May 06, 2005 10:27 AM
To: Tapestry users
Subject: Error: JTATransaction Could not register Synchronization
(Tapestry
+Hibernate)

I keep getting this error: JTATransaction Could not register
Synchronization.
 
And I can't find the cause of it.  
Question: will this cause the problem?
 
I created an object from a hibernate session and then set it as a
property on the next page
The hibernate session is closed immediately in the current page before
activating the next page.
When I continue on the next page and start using the object reference I
set earlier, would this cause the above error?
 
Any comment is greatly appreciated.
-Patrick
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Error: JTATransaction Could not register Synchronization (Tapestry +Hibernate)

Javier Sánchez-4
In reply to this post by Patrick Yip
We ran into the same problem until we did the following:

1.  Upgrade Tapestry to 3.0.3 (there is reported bug recovering from errors)
2.  Take off all transaction stuff (open/commit/rollback) from
queries.  Only use transactions when you modify the database.
3.  Tune parameteres in containers (JBoss/Tomcat) specially for
transactions.  There are some defaults that cause problems.

Hope this help,

JAVIER SANCHEZ.

On 5/6/05, Patrick Yip <[hidden email]> wrote:

> I keep getting this error: JTATransaction Could not register
> Synchronization.
>
> And I can't find the cause of it.
> Question: will this cause the problem?
>
> I created an object from a hibernate session and then set it as a
> property on the next page
> The hibernate session is closed immediately in the current page before
> activating the next page.
> When I continue on the next page and start using the object reference I
> set earlier, would this cause the above error?
>
> Any comment is greatly appreciated.
> -Patrick
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]