You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by devdev <qu...@yahoo.com> on 2008/08/22 19:57:51 UTC
DB pool from admin console looks wrong
Hi all,
I get this deploy plan from the admin console and it looks incomplete to me.
In the connection section it only list the database name, username and
password. Without a hostname+port or some connection URL, i don't see how
it can ma the proper connection
Thanks
JFR
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
<dep:moduleId>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>db.pool</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>3.1.12</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
<connectiondefinition-instance>
<name>db.pool</name>
<config-property-setting
name="DatabaseName">MyDBName</config-property-setting>
<config-property-setting
name="Password">MyPass</config-property-setting>
<config-property-setting
name="UserName">MyUser</config-property-setting>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<match-one/>
</single-pool>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
--
View this message in context: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19112554.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: DB pool from admin console looks wrong
Posted by David Jencks <da...@yahoo.com>.
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:
http://cwiki.apache.org/GMOxDOC21/datasource-connectionfactory-mdb-and-jpa.html
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
> JFR
>
>
>
> 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
>>> http://cwiki.apache.org/GMOxDOC21/using-java-persistence-api-in-application-client.html
>>
>> 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:
>>> http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19113279.html
>>> Sent from the Apache Geronimo - Users mailing list archive at
>>> Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19114756.html
> Sent from the Apache Geronimo - Users mailing list archive at
> Nabble.com.
>
Re: DB pool from admin console looks wrong
Posted by devdev <qu...@yahoo.com>.
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?
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?
Thank you in advance
JFR
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
>> http://cwiki.apache.org/GMOxDOC21/using-java-persistence-api-in-application-client.html
>
> 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:
>> http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19113279.html
>> Sent from the Apache Geronimo - Users mailing list archive at
>> Nabble.com.
>>
>
>
>
--
View this message in context: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19114756.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: DB pool from admin console looks wrong
Posted by David Jencks <da...@yahoo.com>.
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
> http://cwiki.apache.org/GMOxDOC21/using-java-persistence-api-in-application-client.html
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: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19113279.html
> Sent from the Apache Geronimo - Users mailing list archive at
> Nabble.com.
>
Re: DB pool from admin console looks wrong
Posted by devdev <qu...@yahoo.com>.
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.
2) By JBDC you like like the JPA example from the tutorial at
http://cwiki.apache.org/GMOxDOC21/using-java-persistence-api-in-application-client.html
3) If using the connector, how would I get a EntityTransaction to start and
commit a TXN.
Thanks a bunch
JFR
--
View this message in context: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19113279.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: DB pool from admin console looks wrong
Posted by David Jencks <da...@yahoo.com>.
This connector is using a mysql datasource, not the Driver
implementation. I'd guess that if you don't supply values for the
server and port (assuming you can) the datasource implementation uses
defaults (such as localhost for the server).
Does it work :-) ?
thanks
david jencks
On Aug 22, 2008, at 10:57 AM, devdev wrote:
>
> Hi all,
>
> I get this deploy plan from the admin console and it looks
> incomplete to me.
> In the connection section it only list the database name, username and
> password. Without a hostname+port or some connection URL, i don't
> see how
> it can ma the proper connection
>
> Thanks
> JFR
>
> <?xml version="1.0" encoding="UTF-8"?>
> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/
> connector-1.2">
> <dep:environment
> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
> <dep:moduleId>
> <dep:groupId>console.dbpool</dep:groupId>
> <dep:artifactId>db.pool</dep:artifactId>
> <dep:version>1.0</dep:version>
> <dep:type>rar</dep:type>
> </dep:moduleId>
> <dep:dependencies>
> <dep:dependency>
> <dep:groupId>mysql</dep:groupId>
> <dep:artifactId>mysql-connector-java</dep:artifactId>
> <dep:version>3.1.12</dep:version>
> <dep:type>jar</dep:type>
> </dep:dependency>
> </dep:dependencies>
> </dep:environment>
> <resourceadapter>
> <outbound-resourceadapter>
> <connection-definition>
>
> <connectionfactory-interface>javax.sql.DataSource</connectionfactory-
> interface>
> <connectiondefinition-instance>
> <name>db.pool</name>
> <config-property-setting
> name="DatabaseName">MyDBName</config-property-setting>
> <config-property-setting
> name="Password">MyPass</config-property-setting>
> <config-property-setting
> name="UserName">MyUser</config-property-setting>
> <connectionmanager>
> <local-transaction/>
> <single-pool>
> <max-size>10</max-size>
> <min-size>0</min-size>
> <match-one/>
> </single-pool>
> </connectionmanager>
> </connectiondefinition-instance>
> </connection-definition>
> </outbound-resourceadapter>
> </resourceadapter>
> </connector>
> --
> View this message in context: http://www.nabble.com/DB-pool-from-admin-console-looks-wrong-tp19112554s134p19112554.html
> Sent from the Apache Geronimo - Users mailing list archive at
> Nabble.com.
>