You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "Nolan, Edell" <Ed...@iona.com> on 2008/05/27 12:29:48 UTC

Question on sharing a derby db with OpenJpa

Hi,

 

I am trying to fix a demo that demonstrates using OpenJpa and I hand I
have tried several solutions. I basically have two web services and each
are deployed in separate service units to Servicemix.

 

The idea here is that the first Service will persist an order to the db
and returns to the client. Then asynchronously the second service will
update the database once it processes the order. The client will later
do a ping to see what the Status of the order is. 

 

It all works fine but when I attempt to place my next order I get the
following error.

 

27-May-2008 10:31:55 org.apache.cxf.phase.PhaseInterceptorChain
doInterceptINFO: Application has thrown exception, unwinding now:
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: Failed to start database
target/data/derby, see the next exception for details.

        at
org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(Dat
aSourceFactory.java:234)

        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(
JDBCConfigurationImpl.java:709)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

 

Caused by: java.sql.SQLException: Another instance of Derby may have
already booted the database
C:\servicemix-4.0-m3\data\derby\target\data\derby.

        at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)

        at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)

        ... 49 more

Caused by: ERROR XSDB6: Another instance of Derby may have already
booted the database C:\servicemix-4.0-m3\data\derby\target\data\derby.

        at
org.apache.derby.iapi.error.StandardException.newException(Unknown
Source)

 

The following is my persistence.xml file. I know I have the
transaction-type="RESOURCE_LOCAL" and from reading around I can see that
you will get this error if you are trying to access the same db from
different jvms but I deploy to Servicemix 

 

<persistence xmlns="http://java.sun.com/xml/ns/persistence"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             version="1.0">

 

  <persistence-unit name="order-processor"
transaction-type="RESOURCE_LOCAL">

    <provider>

      org.apache.openjpa.persistence.PersistenceProviderImpl

    </provider>

 

    <class>com.iona.fuse.demo.logisticx.model.Order</class>

    <class>com.iona.fuse.demo.logisticx.model.LineItem</class>

    <class>com.iona.fuse.demo.logisticx.model.OrderStatus</class>

 

    <properties>

      <property name="openjpa.ConnectionURL"
value="jdbc:derby:target/data/derby;create=true"/>

      <property name="openjpa.ConnectionDriverName"
value="org.apache.derby.jdbc.EmbeddedDriver"/>

      <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>

      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO,
SQL=TRACE"/>

      <!-- <property name="openjpa.RuntimeUnenhancedClasses"
value="warn"/>  -->

    </properties>

  </persistence-unit>

 

</persistence>

 

So my question is - is there a way to get around this with my current
configuration ?

 

Or 

 

Can anyone point me to a location where there is an example of using
OpenJpa with sharing a derby db. 

 

Thanks, Edell.


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: Question on sharing a derby db with OpenJpa

Posted by Kevin Sutter <kw...@gmail.com>.
Edell,
I don't know anything about Servicemix, so I can't comment on the multiple
jvm usage.  But, you are correct that if you are attempting to use the
EmbeddedDriver for Derby, this can only be used by one JVM at a time.  So,
if this Servicemix is accidentally (or on purpose) using multiple JVMs to
process these service requests, then that may be your problem.

Another possible problem is that you are not properly cleaning up your
unused EntityManagers.  From your description, it sounds like you are using
the Application-managed environment.  If that is the case, then your
application is responsible for closing the EntityManagers when it is done
with them.  This will properly free up the connections to the database as
well.

If you are sure that you should only be using one Connection at a time, then
you'll have to debug why you are getting more than one (multiple jvms,
insufficient cleanup, etc).  Another potential workaround is to use Derby's
ClientDriver.  But, then you'll have to setup a Derby server.

Kevin


On Tue, May 27, 2008 at 5:29 AM, Nolan, Edell <Ed...@iona.com> wrote:

> Hi,
>
>
>
> I am trying to fix a demo that demonstrates using OpenJpa and I hand I
> have tried several solutions. I basically have two web services and each
> are deployed in separate service units to Servicemix.
>
>
>
> The idea here is that the first Service will persist an order to the db
> and returns to the client. Then asynchronously the second service will
> update the database once it processes the order. The client will later
> do a ping to see what the Status of the order is.
>
>
>
> It all works fine but when I attempt to place my next order I get the
> following error.
>
>
>
> 27-May-2008 10:31:55 org.apache.cxf.phase.PhaseInterceptorChain
> doInterceptINFO: Application has thrown exception, unwinding now:
> 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: Failed to start database
> target/data/derby, see the next exception for details.
>
>        at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(Dat
> aSourceFactory.java:234)
>
>        at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(
> JDBCConfigurationImpl.java:709)
>
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>
>
>
> Caused by: java.sql.SQLException: Another instance of Derby may have
> already booted the database
> C:\servicemix-4.0-m3\data\derby\target\data\derby.
>
>        at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
>
>        at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
>
>        ... 49 more
>
> Caused by: ERROR XSDB6: Another instance of Derby may have already
> booted the database C:\servicemix-4.0-m3\data\derby\target\data\derby.
>
>        at
> org.apache.derby.iapi.error.StandardException.newException(Unknown
> Source)
>
>
>
> The following is my persistence.xml file. I know I have the
> transaction-type="RESOURCE_LOCAL" and from reading around I can see that
> you will get this error if you are trying to access the same db from
> different jvms but I deploy to Servicemix
>
>
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
>             version="1.0">
>
>
>
>  <persistence-unit name="order-processor"
> transaction-type="RESOURCE_LOCAL">
>
>    <provider>
>
>      org.apache.openjpa.persistence.PersistenceProviderImpl
>
>    </provider>
>
>
>
>    <class>com.iona.fuse.demo.logisticx.model.Order</class>
>
>    <class>com.iona.fuse.demo.logisticx.model.LineItem</class>
>
>    <class>com.iona.fuse.demo.logisticx.model.OrderStatus</class>
>
>
>
>    <properties>
>
>      <property name="openjpa.ConnectionURL"
> value="jdbc:derby:target/data/derby;create=true"/>
>
>      <property name="openjpa.ConnectionDriverName"
> value="org.apache.derby.jdbc.EmbeddedDriver"/>
>
>      <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema"/>
>
>      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO,
> SQL=TRACE"/>
>
>      <!-- <property name="openjpa.RuntimeUnenhancedClasses"
> value="warn"/>  -->
>
>    </properties>
>
>  </persistence-unit>
>
>
>
> </persistence>
>
>
>
> So my question is - is there a way to get around this with my current
> configuration ?
>
>
>
> Or
>
>
>
> Can anyone point me to a location where there is an example of using
> OpenJpa with sharing a derby db.
>
>
>
> Thanks, Edell.
>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>