Ok, I've found a workaround.  The code seems to be failing because it cannot
determine the DBDictionary to use.  It uses the ConnectionURL (null) and the
ConnectionDriverName (which points to the pool) to determine the
DBDictionary.  Once that fails, it attempts to connect to the database to
try and determine the dictionary.  It tries to grab a slice, but the
collection of slices is empty, since this is all happening during the
process of adding the first slice.  With no slice, it cannot connect and
throws no slices configured exception.

The workaround that I'm doing is explicitly setting the DBDictionary with
the following in my persistence-unit properties:
<property name="openjpa.jdbc.DBDictionary" value="mysql"/>

Hope that helps anyone else that runs into the same issue.

Richard.

On Tue, Aug 2, 2011 at 8:51 AM, RICHARD LUONG <rlu...@gmail.com> wrote:

> I'm getting the following error:
>
> Caused by: <openjpa-2.1.0-r422266:1071316 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: No slices are configured
> or available
>  at
> org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createDistributedDataStore(DistributedJDBCConfigurationImpl.java:363)
> at
> org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.createConnectionFactory(DistributedJDBCConfigurationImpl.java:626)
>  at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)
> at
> org.apache.openjpa.jdbc.meta.MappingDefaultsImpl.setConfiguration(MappingDefaultsImpl.java:878)
>  at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:486)
> at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443)
>  at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
> at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
>  at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getMappingDefaultsInstance(JDBCConfigurationImpl.java:706)
> at
> org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.newSlice(DistributedJDBCConfigurationImpl.java:467)
>  at
> org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl.fromProperties(DistributedJDBCConfigurationImpl.java:618)
> at
> org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(MapConfigurationProvider.java:85)
>  at
> org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto(PersistenceProductDerivation.java:698)
> at
> org.apache.openjpa.slice.jdbc.DistributedJDBCBrokerFactory.newInstance(DistributedJDBCBrokerFactory.java:56)
>  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:597)
>  at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)
> at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:65)
>  at
> org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:151)
> at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:191)
>  at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:66)
> at
> org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
>  at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
>  at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
> ... 130 more
>
> On Tue, Aug 2, 2011 at 6:29 AM, Rick Curtis <curti...@gmail.com> wrote:
>
>> What is the error that you are seeing?
>>
>> On Mon, Aug 1, 2011 at 8:03 PM, RICHARD LUONG <rlu...@gmail.com> wrote:
>>
>> > Hi,
>> >
>> > Does Slice support using a connection pool?  I was able to get the
>> > connection pool working when not using Slice with the following
>> > persistence-unit:
>> >
>> >    <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
>> >        <provider>
>> >            org.apache.openjpa.persistence.PersistenceProviderImpl
>> >        </provider>
>> >
>> >        <properties>
>> > <property name="openjpa.ConnectionProperties"
>> >                value="DriverClassName=com.mysql.jdbc.Driver,
>> >                  Url=jdbc:mysql://url:3306/test,
>> >                  MaxActive=300,
>> >                  TestOnBorrow=true,
>> >                  Username=user,
>> >                  Password=password"/>
>> >            <property name="openjpa.ConnectionDriverName"
>> >                value="org.apache.commons.dbcp.BasicDataSource"/>
>> >        </properties>
>> >     </persistence-unit>
>> >
>> > However, I got an error when attempting to use it in Slice, with the
>> > following:
>> >
>> >    <persistence-unit name="test2" transaction-type="RESOURCE_LOCAL">
>> >        <provider>
>> >            org.apache.openjpa.persistence.PersistenceProviderImpl
>> >        </provider>
>> >
>> > <properties>
>> >  <property name="openjpa.Log" value="Runtime=TRACE, SQL=TRACE,
>> > DefaultLevel=TRACE, Tool=TRACE"/>
>> > <property name="openjpa.BrokerFactory" value="slice"/>
>> >  <property name="openjpa.slice.Names"   value="slice1"/>
>> > <property name="openjpa.slice.Master"  value="slice1"/>
>> >  <!-- Lenient: Allows DB to continue, even when one slice is
>> unavailable.
>> > -->
>> > <property name="openjpa.slice.Lenient" value="true"/>
>> >
>> > <property name="openjpa.ConnectionDriverName"
>> >          value="org.apache.commons.dbcp.BasicDataSource"/>
>> >
>> > <property name="openjpa.slice.slice1.ConnectionProperties"
>> >                value="DriverClassName=com.mysql.jdbc.Driver,
>> >                  Url=jdbc:mysql://url:3306/test,
>> >                  MaxActive=300,
>> >                  TestOnBorrow=true,
>> >                  Username=user,
>> >                  Password=password"/>
>> >  <property name="openjpa.slice.DistributionPolicy"
>> >
>> > value="com.....service.openjpa.DistributeByInstitutionPolicy"/>
>> > <property name="openjpa.slice.FinderTargetPolicy"
>> >
>> value="com.....service.openjpa.ShardFinderTargetPolicy"/>
>> > <property name="openjpa.slice.ReplicatedTypes"
>> >                   value="com...."/>
>> >
>> > . <property name="openjpa.QueryCache" value="false"/>
>> >  <property name="openjpa.DataCache" value="false"/>
>> > . <property name="openjpa.QueryCompilationCache" value="false"/>
>> >  <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
>> > <property name="openjpa.jdbc.FinderCache" value="false"/>
>> >  <property name="openjpa.DetachState"
>> > value="loaded(DetachedStateField=false)"/>
>> >  </properties>
>> >    </persistence-unit>
>> >
>> >
>> > Am I missing something in my configuration or is this just something
>> that
>> > is
>> > not supported by Slice?  If it's not supported, are there any
>> recommended
>> > alternatives?
>> >
>> > Thanks,
>> > Richard.
>> >
>>
>>
>>
>> --
>> *Rick Curtis*
>>
>
>

Reply via email to