geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Geronimo 2.2 + Spring + Hibernate and a Geronimo managed DB Pool with XA driver
Date Sat, 17 Jul 2010 06:36:29 GMT
Hi Billy,

We're having a little bit of a communication problem.  I know how geronimo works pretty well
but I don't know anything about your app.  You know how your app is put together but are wondering
how it relates to geronimo.   I can't give you very good advice unless I know more about what
you are trying to do.

Maybe you could show the progress of a typical request through the components in your app,
and indicate in each component what gets injected, what gets looked up in jndi, and what gets
passed on to the next component,, where transaction boundaries are, and where the problem
occurs?


On Jul 16, 2010, at 9:11 PM, Billy Vandory wrote:

> 
> Thanks for the answer, would you be able to tell me how I can identify the
> global name?

global name of what?

> Also, I've searched for how to configure this in the openejb
> config file, but i can't locate a configuration for a geronimo db pool. 
> normally, id keep looking, but i really need to get this going.. 

openejb config file == ??  openejb-jar.xml??

> 
> this project went into performance testing with a workaround (we inject the
> PU in the ejb using the @PersistenceContext annotation, then we pass the EM
> to the constructor of the DAO.

DAO == ?

> but of course, it caused massive threading
> issues on the entity manager.  
> 
> Btw, I'll have to note that the EntityManager is being injected into the EJB
> just fine and can use the DB - that's what's puzzling.  I can't do a JNDI
> lookup but the @PersistenceContext has no problems doing it.

In geronimo (2.x anyway) persistence units aren't configured using jndi.  the jta-datasource
and non-jta-datasource are, directly, the name specified in the datasource configuration.
 Just because the persistence unit can find them through non-jndi means does not mean that
your app can access the datasource.  You need an @Resource injection or a resource-ref.
> 
> You might be asking, well, if the EM is being injected, why are you looking
> it up?  The answer is because we need to inject the PU directly into the DAO
> via spring, and spring does a JNDI lookup on the DBPool...  

What exactly do you mean by PU?  what does spring have to do with it?  If you have configured
spring to set up a persistence unit through whatever means spring uses, it's not, AFAIK, going
to share a cache with the one geronimo sets up.  So if you do some work on jpa entities in
your ejb, and then in the same transaction do some more work on the same entities looked up
in a spring bean, they probably won't see each others changes on the "same" object.  If all
your jpa entity work is done in spring, you won't have this problem, but then you won't need
the persistence context ref in your ejb.at y

If you want to share the cache then you should not define a persistence unit in spring but
pass the EM or EMF from your ejb into your spring beans.

(it's possible that  your jpa provider somehow recognizes that both persistence units are
referring to the same stuff and figures out how to share a cache, but I don't know how this
would work)

> 
> I'd really appreciate it if you could send me some config examples, or how
> to look it up globally, as you mentioned, i'm really at a dead end with
> this.. I've assigned two guys to trace the code, 1 guy to trace why the PU
> is being injected and one guy to find out why the JNDI is failing.. but it's
> friday at midnight and they want to go home.. :(
> 

One of your previous emails showed the global jndi name for your datasource, so I thought
you were aware of it.  It's printed out in the geronimo.log as the datasource is started.

jca:/default/wakapeek-persist-ear/JCAManagedConnectionFactory/testmydb

You should be able to use that in the spring configuration.

Alternatively if you include a resource-ref like

<resource-ref>
<resource-ref-name>testmydb</resource-ref-name>
<resource-ref-type>javax.sql.DataSource</resource-ref-type>
</resource-ref>

in your ejb-jar.xml for any ejbs that call spring then you can use the jndi name

java:comp/env/testmydb

either in your ejb or in spring.

Hope this helps and that I'm starting to understand what you are asking about...
david jencks

> 
> -- 
> View this message in context: http://apache-geronimo.328035.n3.nabble.com/Geronimo-2-2-Spring-Hibernate-and-a-Geronimo-managed-DB-Pool-with-XA-driver-tp874759p974144.html
> Sent from the Users mailing list archive at Nabble.com.


Mime
View raw message