Hello Jacek,

Not exactly, at least following the path of the <gbean-ref>. I took the
other approach manucet suggested, using the Kernel object from my message
bean and finding the GBean. That way it worked quite well.

But now I'm facing another problem: my message bean acquires the reference
to an object (call it UpdatesProcessor) from the GBean, which is in charge
of the inserts and updates to a database using entity beans with the data
received in my message bean. This UpdatesProcessor objects runs on it's own
thread (implements Runnable), and schedules all the operations to the
database to be executed by a timestamp attribute.

My problem comes when this UpdatesProcessor object tries to persist the
entities, because Geronimo says there is no active transaction and throws a
javax.persistence.TransactionRequiredException

The way it works is this: my GBean is injected with the reference to my
PersistenceUnit and from there I get the reference to the EntityManager.
This EntityManager is then passed to the UpdatesProcessor via its
constructor (this UpdatesProcessor is created and started inside the GBean
doStart() method), so it can find entities. Everything works right up to the
line where I call the persist() method of the EntityManager, with the
aforementioned exception.

>From there on, I've tried to find a transaction manager gbean in Geronimo,
to inject it to my own GBean and then to my UpdatesProcessor object. I've
found an object with a promising name,
org.apache.geronimo.transacion.manager.GeronimoTransacionManagerGBean, and
the JMX console shows it has methods for beginning, committing and rolling
back transactions. So, I inject my GBean with a reference to this
GeronimoTransactionManagerGBean, then get its TransactionManager interface
and pass it to my UpdatesProcessor object. But when I try to call persist()
on my EntityManager inside the UpdatesProcessor thread proc, Geronimo keeps
complaining about the same "No active transaction" error message and
TransactionRequiredException, even though I've surrounded this persist()
method call with the corresponding TransactionManager.begin() and
TransactionManager.commit().

I'm sure there is something wrong in my doings, but as I have not much idea
of Geronimo internals, I can't do much more. Now, I'll have to look inside
Geronimo to try to figure out how the persistence layer handles transactions
and see if I can somehow link the TransactionManager reference with the
EntityManager object to make them work together.

If anyone has advice, it's more than welcome :)



Jacek Laskowski wrote:
> 
> On Tue, Jul 1, 2008 at 1:40 PM, dsthode
> <[EMAIL PROTECTED]> wrote:
> 
>> I've followed your advice and changed the default namespace to openejb
>> version 2.2 and added a <pattern> element for the <gbean-ref> resolution,
>> but Geronimo keeps failing on deployment with the message that <ref-name>
>> is
>> not in geronimo-namespace-1.2 schema but in
>> http://openejb.apache.org/xml/ns/openejb-jar-2.2, even though you can
>> open
>> geronimo-naming-1.2 and find <ref-name> defined in this schema.
> 
> Did you happen to sort it out? What was the solution?
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Use-of-a-GBean-from-a-Message-EJB-tp18109820s134p18313576.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.

Reply via email to