geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: DB pool from admin console looks wrong
Date Fri, 22 Aug 2008 23:41:11 GMT

On Aug 22, 2008, at 1:11 PM, devdev wrote:

> David thanks again for the quick reply.
> regarding #2, I totally agree there is no benefit to use it the jsee  
> way.
> When rewriting persistence.xml touse mysql I get
> <openjpa-1.0.2-r420667:627158 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: There were errors
> initializing your configuration: <openjpa-1.0.2-r420667:627158 fatal  
> store
> error> org.apache.openjpa.util.StoreException: com.mysql.jdbc.Driver  
> in
> classloader org.apache.geronimo.configs/openjpa/2.1.2/car which i  
> believe is
> because it can't find the driver.  I got around it by providing a  
> deploy
> plan for a mysql connector where the dependency is stated.  Thus  
> it's really
> a bizaree setup, because it use the persistence-unit to write to the  
> DB and
> not the DB pool.
> If using the pool is the prefered way (to leverage JEE container), it
> surprising you are unsure if it would give problem or not.  Isn't it  
> a quite
> standard use case of access the DB?

yes, for server side apps.  The documentation you pointed to is for an  
a javaee application client.  I've never seen a javaee app client of  
any kind used in a production app, let alone one that used jpa.  I  
have a hard time imagining a reasonable use case for a javaee app  
client that used direct database access through local jpa -- perhaps  
for some kind of local backup when you can't connect to the server?   
Anyway I've never seen such a setup.

For web apps or ejbs, you definitely want to use a db pool.  There are  
some instructions here:

For some reason when you search the site for "persistence.xml" it  
doesn't show up on the first page which is rather unfortunate since I  
think they are the only instructions that explain this.
> regarding #3, according to javax.persistence.* API, the only way to  
> get a
> EntityTransaction instance is by follow that example and it first  
> start w/
> Persistence.createEntityManagerFactory(String persistenceUnitName).   
> If
> using the connector, how can I refer to my connector w/in my EJB?

I'm afraid I don't recall the details of when you can use application  
managed persistence units/contexts.  I think you have to specify this  
in the persistence.xml, and you might have to inject an  
EntityManagerFactory rather than an EntityManager.  In any case, once  
you have the EntityManager, you can get the EntityTransaction from it  
and use it.

In the server, however, I strongly recommend using container managed  
transactions and persistence contexts, and relying on the transaction  
annotations for the ejb methods.

hope this helps
david jencks

> Thank you in advance
> djencks wrote:
>> On Aug 22, 2008, at 11:36 AM, devdev wrote:
>>> Thank you David.  Could you please clarify the following is correct.
>>> 1) I was under the impression that the JDBC is also using a  
>>> connector
>>> underneath.
>> I don't understand what you are asking.  Geronimo provides jdbc
>> database pooling through the j2ca connector framework, and wrapping
>> jdbc drivers and datasources from db vendors with j2ca adapters from
>> the tranql project.
>>> 2) By JBDC you like like the JPA example from the tutorial at
>> I don't think I'd write this example this way.  It does not use any
>> javaee jpa support but only javase support.  In particular it does  
>> not
>> use and database connection pooling.  To get a similar example to  
>> work
>> with mysql you'd need to modify the persistence.xml properties to
>> point to the mysql database.
>> If I were to write a jpa app client example I would use injected
>> entity manager or entity manager factory and deploy a connection pool
>> on the app client and use it with the jta-datasource and/or non-jta-
>> datasource.  However I'm not sure anyone has done this and don't know
>> if there would be problems.
>>> 3) If using the connector, how would I get a EntityTransaction to
>>> start and
>>> commit a TXN.
>> The app client example isn't useing a connector.  However I think
>> there are methods on EntityManager to control jpa-mediated  
>> transactions.
>> I'm not sure I'm answering the questions you are asking but hopefully
>> this is of some help
>> david jencks
>>> Thanks a bunch
>>> JFR
>>> -- 
>>> View this message in context:
>>> Sent from the Apache Geronimo - Users mailing list archive at
> -- 
> View this message in context:
> Sent from the Apache Geronimo - Users mailing list archive at  

View raw message