You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Alessandro Ferrucci <al...@gmail.com> on 2007/06/22 05:24:50 UTC

openJPA with DBCP connection pool

hey guys

trying to configure openjpa to use a connection pool provided by dbcp.  my
persistence unit is:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
   <persistence-unit name="openjpa" transaction-type="RESOURCE_LOCAL">
      <class>com.foo.bar.myClass</class>
        <properties>
            <property name="openjpa.ConnectionDriverName"
                value="org.apache.commons.dbcp.BasicDataSource"/>
            <!-- <property name="openjpa.ConnectionDriverName"
                value="com.mysql.jdbc.Driver"/>-->
            <property name="openjpa.ConnectionURL"
                value="jdbc:mysql://localhost:3306/sports"/>
            <property name="openjpa.ConnectionFactoryProperties"
                value="PrettyPrint=true, PrettyPrintLineLength=80"/>
            <property name="openjpa.ConnectionUserName" value="root"/>
            <property name="openjpa.ConnectionPassword" value=""/>
            <property name="openjpa.Sequence"
                value="table(Table=OPENJPASEQ,Increment=100)"/>
        </properties>
   </persistence-unit>
</persistence>

as you can see I've swapped out my regular jdbc driver name with
BasicDataSource as docs describe (using jdbc driver works fine by the way).
Here's my small persistance snippet:

        EntityManagerFactory factory =
Persistence.createEntityManagerFactory("openjpa");
        EntityManager em = factory.createEntityManager();
        em.getTransaction().begin();
        em.persist(xLiveScoresBA);
        em.getTransaction().commit();
        em.close();

I get the following exception trace when using DBCP:

Caused by: <2|true|0.9.6-incubating>
org.apache.openjpa.persistence.RollbackException: Not supported by
BasicDataSource
        at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:388)
        at
com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.transmit(
NFLAtomicsTrxmitterUmo.java:294)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.mule.impl.model.resolvers.DynamicEntryPoint.invokeMethod(
DynamicEntryPoint.java:314)
        at org.mule.impl.model.resolvers.DynamicEntryPoint.invoke(
DynamicEntryPoint.java:261)
        at org.mule.impl.DefaultLifecycleAdapter.intercept(
DefaultLifecycleAdapter.java:217)
        ... 99 more
Caused by: <0|false|0.9.6-incubating>
org.apache.openjpa.persistence.PersistenceException: Not supported by
BasicDataSource
        at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
BrokerImpl.java:1764)
        at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
LocalManagedRuntime.java:76)
        at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1313)
        at org.apache.openjpa.kernel.DelegatingBroker.commit(
DelegatingBroker.java:863)
        at org.apache.openjpa.persistence.EntityManagerImpl.commit(
EntityManagerImpl.java:377)
        ... 107 more
Caused by: java.lang.UnsupportedOperationException: Not supported by
BasicDataSource
        at org.apache.commons.dbcp.BasicDataSource.getConnection(
BasicDataSource.java:899)
        at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
DelegatingDataSource.java:110)
        at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
DecoratingDataSource.java:90)
        at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
DelegatingDataSource.java:110)
        at
org.apache.openjpa.jdbc.schema.DataSourceFactory$DefaultsDataSource.getConnection
(DataSourceFactory.java:261)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal(
JDBCStoreManager.java:735)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(
JDBCStoreManager.java:720)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.retainConnection(
JDBCStoreManager.java:194)
        at org.apache.openjpa.kernel.DelegatingStoreManager.retainConnection
(DelegatingStoreManager.java:160)
        at org.apache.openjpa.kernel.BrokerImpl.retainConnection(
BrokerImpl.java:3618)
        at org.apache.openjpa.kernel.BrokerImpl.beginStoreManagerTransaction
(BrokerImpl.java:1246)
        at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1885)
        at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java
:1825)
        at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
BrokerImpl.java:1756)
        ... 111 more
ERROR 2007-06-21 23:11:19,619 [connector.file.0.scheduler.1]
org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in
Exception Strategy for: AtomicsTrxmitterUmo: org.mule.umo.ComponentException:
Failed to invoke com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.
Component that caused exception is: AtomicsTrxmitterUmo. Message payload is
of type: com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
org.mule.umo.ComponentException: Failed to invoke
com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo. Component that
caused exception is: AtomicsTrxmitterUmo. Message payload is of type:
com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter


Not quite sure if the BasicDataSource is getting initialized correctly.

thanks a bunch

--
alessandro ferrucci =]

Re: openJPA with DBCP connection pool

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Alessandro-

Unfortunately, I don't think DBCP has any logging ability to tell  
when pooled connections are obtained, etc.

You might be able to gather that information from OpenJPA's JDBC and  
SQL log, which might contain information about the connection that it  
obtains from the DataSource. You can try these out by setting the  
"openjpa.Log" property to "SQL=TRACE,JDBC=TRACE".


On Jun 21, 2007, at 10:34 PM, Alessandro Ferrucci wrote:

> Hey man thx a lot for the help..  yes I had it configured like the  
> docs have
> it and kept getting errors in constructing a Connection.  I  
> actually copied
> and pasted the sample configuration for DBCP and changed the  
> attributes to
> match my environment and it would not work....has someone tested that
> configuration?
>
> In any case, I changed the config to use an aggregated property  
> element like
> so:
>
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"  
> version="1.0">
>   <persistence-unit name="openjpa" transaction-type="RESOURCE_LOCAL">
>       
> <class>com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
> </class>
>        <properties>
>            <property name="openjpa.ConnectionDriverName"
>                value="org.apache.commons.dbcp.BasicDataSource"/>
>            <property name="openjpa.ConnectionProperties"
>                value="DriverClassName=com.mysql.jdbc.Driver
> ,Url=jdbc:mysql://localhost:3306/sports,Username=root,Password="/>
>
>            <!-- <property name="openjpa.ConnectionDriverName"
>            value="com.mysql.jdbc.Driver"/>
>            <property name="openjpa.ConnectionURL"
>            value="jdbc:mysql://localhost:3306/sports"/>
>            <property name="openjpa.ConnectionFactoryProperties"
>            value="PrettyPrint=true, PrettyPrintLineLength=80"/>
>            <property name="openjpa.ConnectionUserName" value="root"/>
>            <property name="openjpa.ConnectionPassword" value=""/>
>            <property name="openjpa.Sequence"
>            value="table(Table=OPENJPASEQ,Increment=100)"/> -->
>
>        </properties>
>   </persistence-unit>
> </persistence>
>
>
> And it works... now on to verifying it's actually using connection  
> pools
> correctly.  As I have no visibility into that right now, if someone  
> knows
> how to inspect a connection pool created by DBCP, please enlighten  
> me.  I
> tried just running  my persist with and without DBCP configs and  
> measuring
> the time but I noticed no time improvement by using DBCP (I persisted
> continuously), however this tells me nothing, I want to somehow be  
> able to
> inspect the connection pool that DBCP is supposedly creating.
>
> thx a lot
>
> --
> alessandro ferrucci =]
>
> On 6/22/07, Michael Dick <mi...@gmail.com> wrote:
>>
>> Have you tried using openjpa.ConnectionProperties to specify the
>> connection
>> information?
>>
>> It would look something like this :
>>        . . .
>>        <properties>
>>            <property name="openjpa.ConnectionDriverName"
>>                value="org.apache.commons.dbcp.BasicDataSource"/>
>>            <property name="openjpa.ConnectionProperties"
>>                value="DriverClassName=com.mysql.jdbc.Driver,
>>
>> Url=jdbc:mysql://localhost:3306/ 
>> sports,Username=root,Password=root'sPassword"
>> />
>>            <property name="openjpa.ConnectionFactoryProperties"
>>                value="PrettyPrint=true, PrettyPrintLineLength=80"/>
>>            <property name="openjpa.Sequence"
>>                value="table(Table=OPENJPASEQ,Increment=100)"/>
>>        </properties>
>>        . . .
>>
>> This is how our examples are configured. I've never tried using
>> commons-dbcp
>> with the individual openjpa.Connnection properties. It looks like  
>> it might
>> work if you pass in the DriverClassName though.
>>
>> Hope this helps,
>> Mike
>>
>> On 6/21/07, Alessandro Ferrucci <al...@gmail.com> wrote:
>> >
>> > hey guys
>> >
>> > trying to configure openjpa to use a connection pool provided by
>> dbcp.  my
>> > persistence unit is:
>> >
>> > <persistence xmlns="http://java.sun.com/xml/ns/persistence"  
>> version="1.0
>> ">
>> >    <persistence-unit name="openjpa" transaction- 
>> type="RESOURCE_LOCAL">
>> >       <class>com.foo.bar.myClass</class>
>> >         <properties>
>> >             <property name="openjpa.ConnectionDriverName"
>> >                 value="org.apache.commons.dbcp.BasicDataSource"/>
>> >             <!-- <property name="openjpa.ConnectionDriverName"
>> >                 value="com.mysql.jdbc.Driver"/>-->
>> >             <property name="openjpa.ConnectionURL"
>> >                 value="jdbc:mysql://localhost:3306/sports"/>
>> >             <property name="openjpa.ConnectionFactoryProperties"
>> >                 value="PrettyPrint=true,  
>> PrettyPrintLineLength=80"/>
>> >             <property name="openjpa.ConnectionUserName"  
>> value="root"/>
>> >             <property name="openjpa.ConnectionPassword" value=""/>
>> >             <property name="openjpa.Sequence"
>> >                 value="table(Table=OPENJPASEQ,Increment=100)"/>
>> >         </properties>
>> >    </persistence-unit>
>> > </persistence>
>> >
>> > as you can see I've swapped out my regular jdbc driver name with
>> > BasicDataSource as docs describe (using jdbc driver works fine  
>> by the
>> > way).
>> > Here's my small persistance snippet:
>> >
>> >         EntityManagerFactory factory =
>> > Persistence.createEntityManagerFactory("openjpa");
>> >         EntityManager em = factory.createEntityManager();
>> >         em.getTransaction().begin();
>> >         em.persist(xLiveScoresBA);
>> >         em.getTransaction().commit();
>> >         em.close();
>> >
>> > I get the following exception trace when using DBCP:
>> >
>> > Caused by: <2|true|0.9.6-incubating>
>> > org.apache.openjpa.persistence.RollbackException: Not supported by
>> > BasicDataSource
>> >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
>> > EntityManagerImpl.java:388)
>> >         at
>> >  
>> com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.transmit(
>> > NFLAtomicsTrxmitterUmo.java:294)
>> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native  
>> Method)
>> >         at sun.reflect.NativeMethodAccessorImpl.invoke(
>> > NativeMethodAccessorImpl.java:39)
>> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> > DelegatingMethodAccessorImpl.java:25)
>> >         at java.lang.reflect.Method.invoke(Method.java:585)
>> >         at  
>> org.mule.impl.model.resolvers.DynamicEntryPoint.invokeMethod(
>> > DynamicEntryPoint.java:314)
>> >         at org.mule.impl.model.resolvers.DynamicEntryPoint.invoke(
>> > DynamicEntryPoint.java:261)
>> >         at org.mule.impl.DefaultLifecycleAdapter.intercept(
>> > DefaultLifecycleAdapter.java:217)
>> >         ... 99 more
>> > Caused by: <0|false|0.9.6-incubating>
>> > org.apache.openjpa.persistence.PersistenceException: Not  
>> supported by
>> > BasicDataSource
>> >         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
>> > BrokerImpl.java:1764)
>> >         at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
>> > LocalManagedRuntime.java:76)
>> >         at org.apache.openjpa.kernel.BrokerImpl.commit 
>> (BrokerImpl.java
>> > :1313)
>> >         at org.apache.openjpa.kernel.DelegatingBroker.commit(
>> > DelegatingBroker.java:863)
>> >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
>> > EntityManagerImpl.java:377)
>> >         ... 107 more
>> > Caused by: java.lang.UnsupportedOperationException: Not  
>> supported by
>> > BasicDataSource
>> >         at org.apache.commons.dbcp.BasicDataSource.getConnection(
>> > BasicDataSource.java:899)
>> >         at
>> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
>> > DelegatingDataSource.java:110)
>> >         at
>> org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
>> > DecoratingDataSource.java:90)
>> >         at
>> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
>> > DelegatingDataSource.java:110)
>> >         at
>> >
>> >
>> org.apache.openjpa.jdbc.schema.DataSourceFactory 
>> $DefaultsDataSource.getConnection
>> > (DataSourceFactory.java:261)
>> >         at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal
>> > (
>> > JDBCStoreManager.java:735)
>> >         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(
>> > JDBCStoreManager.java:720)
>> >         at
>> > org.apache.openjpa.jdbc.kernel.JDBCStoreManager.retainConnection(
>> > JDBCStoreManager.java:194)
>> >         at
>> > org.apache.openjpa.kernel.DelegatingStoreManager.retainConnection
>> > (DelegatingStoreManager.java:160)
>> >         at org.apache.openjpa.kernel.BrokerImpl.retainConnection(
>> > BrokerImpl.java:3618)
>> >         at
>> > org.apache.openjpa.kernel.BrokerImpl.beginStoreManagerTransaction
>> > (BrokerImpl.java:1246)
>> >         at org.apache.openjpa.kernel.BrokerImpl.flush 
>> (BrokerImpl.java
>> > :1885)
>> >         at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
>> BrokerImpl.java
>> > :1825)
>> >         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
>> > BrokerImpl.java:1756)
>> >         ... 111 more
>> > ERROR 2007-06-21 23:11:19,619 [connector.file.0.scheduler.1]
>> > org.mule.impl.DefaultComponentExceptionStrategy: Caught  
>> exception in
>> > Exception Strategy for: AtomicsTrxmitterUmo:
>> > org.mule.umo.ComponentException:
>> > Failed to invoke
>> > com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.
>> > Component that caused exception is: AtomicsTrxmitterUmo. Message  
>> payload
>> > is
>> > of type:  
>> com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
>> > org.mule.umo.ComponentException: Failed to invoke
>> > com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.  
>> Component
>> > that
>> > caused exception is: AtomicsTrxmitterUmo. Message payload is of  
>> type:
>> > com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
>> >
>> >
>> > Not quite sure if the BasicDataSource is getting initialized  
>> correctly.
>> >
>> > thanks a bunch
>> >
>> > --
>> > alessandro ferrucci =]
>> >
>>


Re: openJPA with DBCP connection pool

Posted by Alessandro Ferrucci <al...@gmail.com>.
Hey man thx a lot for the help..  yes I had it configured like the docs have
it and kept getting errors in constructing a Connection.  I actually copied
and pasted the sample configuration for DBCP and changed the attributes to
match my environment and it would not work....has someone tested that
configuration?

In any case, I changed the config to use an aggregated property element like
so:


<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
   <persistence-unit name="openjpa" transaction-type="RESOURCE_LOCAL">
      <class>com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
</class>
        <properties>
            <property name="openjpa.ConnectionDriverName"
                value="org.apache.commons.dbcp.BasicDataSource"/>
            <property name="openjpa.ConnectionProperties"
                value="DriverClassName=com.mysql.jdbc.Driver
,Url=jdbc:mysql://localhost:3306/sports,Username=root,Password="/>

            <!-- <property name="openjpa.ConnectionDriverName"
            value="com.mysql.jdbc.Driver"/>
            <property name="openjpa.ConnectionURL"
            value="jdbc:mysql://localhost:3306/sports"/>
            <property name="openjpa.ConnectionFactoryProperties"
            value="PrettyPrint=true, PrettyPrintLineLength=80"/>
            <property name="openjpa.ConnectionUserName" value="root"/>
            <property name="openjpa.ConnectionPassword" value=""/>
            <property name="openjpa.Sequence"
            value="table(Table=OPENJPASEQ,Increment=100)"/> -->

        </properties>
   </persistence-unit>
</persistence>


And it works... now on to verifying it's actually using connection pools
correctly.  As I have no visibility into that right now, if someone knows
how to inspect a connection pool created by DBCP, please enlighten me.  I
tried just running  my persist with and without DBCP configs and measuring
the time but I noticed no time improvement by using DBCP (I persisted
continuously), however this tells me nothing, I want to somehow be able to
inspect the connection pool that DBCP is supposedly creating.

thx a lot

--
alessandro ferrucci =]

On 6/22/07, Michael Dick <mi...@gmail.com> wrote:
>
> Have you tried using openjpa.ConnectionProperties to specify the
> connection
> information?
>
> It would look something like this :
>        . . .
>        <properties>
>            <property name="openjpa.ConnectionDriverName"
>                value="org.apache.commons.dbcp.BasicDataSource"/>
>            <property name="openjpa.ConnectionProperties"
>                value="DriverClassName=com.mysql.jdbc.Driver,
>
> Url=jdbc:mysql://localhost:3306/sports,Username=root,Password=root'sPassword"
> />
>            <property name="openjpa.ConnectionFactoryProperties"
>                value="PrettyPrint=true, PrettyPrintLineLength=80"/>
>            <property name="openjpa.Sequence"
>                value="table(Table=OPENJPASEQ,Increment=100)"/>
>        </properties>
>        . . .
>
> This is how our examples are configured. I've never tried using
> commons-dbcp
> with the individual openjpa.Connnection properties. It looks like it might
> work if you pass in the DriverClassName though.
>
> Hope this helps,
> Mike
>
> On 6/21/07, Alessandro Ferrucci <al...@gmail.com> wrote:
> >
> > hey guys
> >
> > trying to configure openjpa to use a connection pool provided by
> dbcp.  my
> > persistence unit is:
> >
> > <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0
> ">
> >    <persistence-unit name="openjpa" transaction-type="RESOURCE_LOCAL">
> >       <class>com.foo.bar.myClass</class>
> >         <properties>
> >             <property name="openjpa.ConnectionDriverName"
> >                 value="org.apache.commons.dbcp.BasicDataSource"/>
> >             <!-- <property name="openjpa.ConnectionDriverName"
> >                 value="com.mysql.jdbc.Driver"/>-->
> >             <property name="openjpa.ConnectionURL"
> >                 value="jdbc:mysql://localhost:3306/sports"/>
> >             <property name="openjpa.ConnectionFactoryProperties"
> >                 value="PrettyPrint=true, PrettyPrintLineLength=80"/>
> >             <property name="openjpa.ConnectionUserName" value="root"/>
> >             <property name="openjpa.ConnectionPassword" value=""/>
> >             <property name="openjpa.Sequence"
> >                 value="table(Table=OPENJPASEQ,Increment=100)"/>
> >         </properties>
> >    </persistence-unit>
> > </persistence>
> >
> > as you can see I've swapped out my regular jdbc driver name with
> > BasicDataSource as docs describe (using jdbc driver works fine by the
> > way).
> > Here's my small persistance snippet:
> >
> >         EntityManagerFactory factory =
> > Persistence.createEntityManagerFactory("openjpa");
> >         EntityManager em = factory.createEntityManager();
> >         em.getTransaction().begin();
> >         em.persist(xLiveScoresBA);
> >         em.getTransaction().commit();
> >         em.close();
> >
> > I get the following exception trace when using DBCP:
> >
> > Caused by: <2|true|0.9.6-incubating>
> > org.apache.openjpa.persistence.RollbackException: Not supported by
> > BasicDataSource
> >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
> > EntityManagerImpl.java:388)
> >         at
> > com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.transmit(
> > NFLAtomicsTrxmitterUmo.java:294)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:39)
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:585)
> >         at org.mule.impl.model.resolvers.DynamicEntryPoint.invokeMethod(
> > DynamicEntryPoint.java:314)
> >         at org.mule.impl.model.resolvers.DynamicEntryPoint.invoke(
> > DynamicEntryPoint.java:261)
> >         at org.mule.impl.DefaultLifecycleAdapter.intercept(
> > DefaultLifecycleAdapter.java:217)
> >         ... 99 more
> > Caused by: <0|false|0.9.6-incubating>
> > org.apache.openjpa.persistence.PersistenceException: Not supported by
> > BasicDataSource
> >         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
> > BrokerImpl.java:1764)
> >         at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
> > LocalManagedRuntime.java:76)
> >         at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java
> > :1313)
> >         at org.apache.openjpa.kernel.DelegatingBroker.commit(
> > DelegatingBroker.java:863)
> >         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
> > EntityManagerImpl.java:377)
> >         ... 107 more
> > Caused by: java.lang.UnsupportedOperationException: Not supported by
> > BasicDataSource
> >         at org.apache.commons.dbcp.BasicDataSource.getConnection(
> > BasicDataSource.java:899)
> >         at
> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> > DelegatingDataSource.java:110)
> >         at
> org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
> > DecoratingDataSource.java:90)
> >         at
> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> > DelegatingDataSource.java:110)
> >         at
> >
> >
> org.apache.openjpa.jdbc.schema.DataSourceFactory$DefaultsDataSource.getConnection
> > (DataSourceFactory.java:261)
> >         at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal
> > (
> > JDBCStoreManager.java:735)
> >         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(
> > JDBCStoreManager.java:720)
> >         at
> > org.apache.openjpa.jdbc.kernel.JDBCStoreManager.retainConnection(
> > JDBCStoreManager.java:194)
> >         at
> > org.apache.openjpa.kernel.DelegatingStoreManager.retainConnection
> > (DelegatingStoreManager.java:160)
> >         at org.apache.openjpa.kernel.BrokerImpl.retainConnection(
> > BrokerImpl.java:3618)
> >         at
> > org.apache.openjpa.kernel.BrokerImpl.beginStoreManagerTransaction
> > (BrokerImpl.java:1246)
> >         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java
> > :1885)
> >         at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
> BrokerImpl.java
> > :1825)
> >         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
> > BrokerImpl.java:1756)
> >         ... 111 more
> > ERROR 2007-06-21 23:11:19,619 [connector.file.0.scheduler.1]
> > org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in
> > Exception Strategy for: AtomicsTrxmitterUmo:
> > org.mule.umo.ComponentException:
> > Failed to invoke
> > com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.
> > Component that caused exception is: AtomicsTrxmitterUmo. Message payload
> > is
> > of type: com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
> > org.mule.umo.ComponentException: Failed to invoke
> > com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo. Component
> > that
> > caused exception is: AtomicsTrxmitterUmo. Message payload is of type:
> > com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
> >
> >
> > Not quite sure if the BasicDataSource is getting initialized correctly.
> >
> > thanks a bunch
> >
> > --
> > alessandro ferrucci =]
> >
>

Re: openJPA with DBCP connection pool

Posted by Michael Dick <mi...@gmail.com>.
Have you tried using openjpa.ConnectionProperties to specify the connection
information?

It would look something like this :
       . . .
       <properties>
           <property name="openjpa.ConnectionDriverName"
               value="org.apache.commons.dbcp.BasicDataSource"/>
           <property name="openjpa.ConnectionProperties"
               value="DriverClassName=com.mysql.jdbc.Driver,
Url=jdbc:mysql://localhost:3306/sports,Username=root,Password=root'sPassword"
/>
           <property name="openjpa.ConnectionFactoryProperties"
               value="PrettyPrint=true, PrettyPrintLineLength=80"/>
           <property name="openjpa.Sequence"
               value="table(Table=OPENJPASEQ,Increment=100)"/>
       </properties>
       . . .

This is how our examples are configured. I've never tried using commons-dbcp
with the individual openjpa.Connnection properties. It looks like it might
work if you pass in the DriverClassName though.

Hope this helps,
Mike

On 6/21/07, Alessandro Ferrucci <al...@gmail.com> wrote:
>
> hey guys
>
> trying to configure openjpa to use a connection pool provided by dbcp.  my
> persistence unit is:
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
>    <persistence-unit name="openjpa" transaction-type="RESOURCE_LOCAL">
>       <class>com.foo.bar.myClass</class>
>         <properties>
>             <property name="openjpa.ConnectionDriverName"
>                 value="org.apache.commons.dbcp.BasicDataSource"/>
>             <!-- <property name="openjpa.ConnectionDriverName"
>                 value="com.mysql.jdbc.Driver"/>-->
>             <property name="openjpa.ConnectionURL"
>                 value="jdbc:mysql://localhost:3306/sports"/>
>             <property name="openjpa.ConnectionFactoryProperties"
>                 value="PrettyPrint=true, PrettyPrintLineLength=80"/>
>             <property name="openjpa.ConnectionUserName" value="root"/>
>             <property name="openjpa.ConnectionPassword" value=""/>
>             <property name="openjpa.Sequence"
>                 value="table(Table=OPENJPASEQ,Increment=100)"/>
>         </properties>
>    </persistence-unit>
> </persistence>
>
> as you can see I've swapped out my regular jdbc driver name with
> BasicDataSource as docs describe (using jdbc driver works fine by the
> way).
> Here's my small persistance snippet:
>
>         EntityManagerFactory factory =
> Persistence.createEntityManagerFactory("openjpa");
>         EntityManager em = factory.createEntityManager();
>         em.getTransaction().begin();
>         em.persist(xLiveScoresBA);
>         em.getTransaction().commit();
>         em.close();
>
> I get the following exception trace when using DBCP:
>
> Caused by: <2|true|0.9.6-incubating>
> org.apache.openjpa.persistence.RollbackException: Not supported by
> BasicDataSource
>         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
> EntityManagerImpl.java:388)
>         at
> com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.transmit(
> NFLAtomicsTrxmitterUmo.java:294)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.mule.impl.model.resolvers.DynamicEntryPoint.invokeMethod(
> DynamicEntryPoint.java:314)
>         at org.mule.impl.model.resolvers.DynamicEntryPoint.invoke(
> DynamicEntryPoint.java:261)
>         at org.mule.impl.DefaultLifecycleAdapter.intercept(
> DefaultLifecycleAdapter.java:217)
>         ... 99 more
> Caused by: <0|false|0.9.6-incubating>
> org.apache.openjpa.persistence.PersistenceException: Not supported by
> BasicDataSource
>         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
> BrokerImpl.java:1764)
>         at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
> LocalManagedRuntime.java:76)
>         at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java
> :1313)
>         at org.apache.openjpa.kernel.DelegatingBroker.commit(
> DelegatingBroker.java:863)
>         at org.apache.openjpa.persistence.EntityManagerImpl.commit(
> EntityManagerImpl.java:377)
>         ... 107 more
> Caused by: java.lang.UnsupportedOperationException: Not supported by
> BasicDataSource
>         at org.apache.commons.dbcp.BasicDataSource.getConnection(
> BasicDataSource.java:899)
>         at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> DelegatingDataSource.java:110)
>         at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
> DecoratingDataSource.java:90)
>         at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> DelegatingDataSource.java:110)
>         at
>
> org.apache.openjpa.jdbc.schema.DataSourceFactory$DefaultsDataSource.getConnection
> (DataSourceFactory.java:261)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connectInternal
> (
> JDBCStoreManager.java:735)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.connect(
> JDBCStoreManager.java:720)
>         at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.retainConnection(
> JDBCStoreManager.java:194)
>         at
> org.apache.openjpa.kernel.DelegatingStoreManager.retainConnection
> (DelegatingStoreManager.java:160)
>         at org.apache.openjpa.kernel.BrokerImpl.retainConnection(
> BrokerImpl.java:3618)
>         at
> org.apache.openjpa.kernel.BrokerImpl.beginStoreManagerTransaction
> (BrokerImpl.java:1246)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java
> :1885)
>         at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java
> :1825)
>         at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
> BrokerImpl.java:1756)
>         ... 111 more
> ERROR 2007-06-21 23:11:19,619 [connector.file.0.scheduler.1]
> org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in
> Exception Strategy for: AtomicsTrxmitterUmo:
> org.mule.umo.ComponentException:
> Failed to invoke
> com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo.
> Component that caused exception is: AtomicsTrxmitterUmo. Message payload
> is
> of type: com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
> org.mule.umo.ComponentException: Failed to invoke
> com.aol.pubt.channels.sports.nfl.umo.NFLAtomicsTrxmitterUmo. Component
> that
> caused exception is: AtomicsTrxmitterUmo. Message payload is of type:
> com.aol.pubt.channels.sports.nfl.adapter.NflLiveBeanAdapter
>
>
> Not quite sure if the BasicDataSource is getting initialized correctly.
>
> thanks a bunch
>
> --
> alessandro ferrucci =]
>