You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Matthieu Riou <ma...@gmail.com> on 2007/01/03 22:23:31 UTC

Configuration: either / or ?

Hi all,

I've been fighting for some time now with my OpenJPA configuration and just
discovered why. It seems that you *either* consider the persistence.xml file
*or* the map passed as parameter of Persistence.createEntityManagerFactory.
If you look at PersistenceProductDerivation.load(String rsrc, String name,
Map m) (line 151), if the configuration provider can find a configuration
file then the configuration is returned as is and the provided configuration
Map doesn't even gets considered.

My expectations would have been to have both the xml file and the map being
used. One or the other can prevail if a property is defined twice but I
think the map shouldn't be plainly ignored when provided.

What do you think? Would that be a bug or is it the desired behavior?

Thanks!

Matthieu

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
Right. Sorry about that. Even though my ConnectionDriverName is still not
properly picked up:

ERROR - ApplicationContext.log(675) | StandardWrapper.Throwable
<4|true|0.9.6-incubating-SNAPSHOT>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in the ConnectionDriverName
property.
        at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(
DataSourceFactory.java:67)
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(
JDBCConfigurationImpl.java:797)
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(
JDBCConfigurationImpl.java:563)
        at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(
MappingRepository.java:1167)
        at org.apache.openjpa.lib.conf.Configurations.configureInstance(
Configurations.java:355)
        at org.apache.openjpa.lib.conf.Configurations.configureInstance(
Configurations.java:280)
        at org.apache.openjpa.lib.conf.PluginValue.instantiate(
PluginValue.java:99)
        at org.apache.openjpa.lib.conf.ObjectValue.instantiate(
ObjectValue.java:70)
        at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance
(OpenJPAConfigurationImpl.java:834)
        at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance
(OpenJPAConfigurationImpl.java:829)
        at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(
AbstractBrokerFactory.java:526)
        at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
AbstractBrokerFactory.java:147)
        at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
DelegatingBrokerFactory.java:139)
        at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
EntityManagerFactoryImpl.java:187)
        at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
EntityManagerFactoryImpl.java:52)
        at org.apache.ode.axis2.ODEServerJPA.initJPA(ODEServerJPA.java:344)


On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> > But if I don't provide openjpa.ConnectionDriverName the call to
> > createEntityManager fails with an exception saying that
> > ConnectionDriverName
> > should be provided (coming from DataSourceFactory):
>
> You need to provide it to createEntityManagerFactory.  Not to
> createEntityManager.  You shouldn't be passing anything to
> createEntityManager.  Use the no-args version.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
> But if I don't provide openjpa.ConnectionDriverName the call to
> createEntityManager fails with an exception saying that  
> ConnectionDriverName
> should be provided (coming from DataSourceFactory):

You need to provide it to createEntityManagerFactory.  Not to  
createEntityManager.  You shouldn't be passing anything to  
createEntityManager.  Use the no-args version.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
But if I don't provide openjpa.ConnectionDriverName the call to
createEntityManager fails with an exception saying that ConnectionDriverName
should be provided (coming from DataSourceFactory):

<4|true|0.9.6-incubating-SNAPSHOT>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in the ConnectionDriverName
property.
        at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(
DataSourceFactory.java:67)
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(
JDBCConfigurationImpl.java:797)
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(
JDBCConfigurationImpl.java:563)
        at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(
MappingRepository.java:1167)
        at org.apache.openjpa.lib.conf.Configurations.configureInstance(
Configurations.java:355)
        at org.apache.openjpa.lib.conf.Configurations.configureInstance(
Configurations.java:280)
        at org.apache.openjpa.lib.conf.PluginValue.instantiate(
PluginValue.java:99)
        at org.apache.openjpa.lib.conf.ObjectValue.instantiate(
ObjectValue.java:70)
        at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance
(OpenJPAConfigurationImpl.java:834)
        at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance
(OpenJPAConfigurationImpl.java:829)
        at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(
AbstractBrokerFactory.java:526)
        at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
AbstractBrokerFactory.java:147)
        at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
DelegatingBrokerFactory.java:139)
        at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
EntityManagerFactoryImpl.java:187)
        at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
EntityManagerFactoryImpl.java:52)
        at org.apache.ode.axis2.ODEServerJPA.initJPA(ODEServerJPA.java:344)


On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> > When execute, for each of the Map key I'm passing I'm getting:
> >
> > <4|false|0.9.6-incubating-SNAPSHOT>
> > org.apache.openjpa.persistence.ArgumentException: Missing getter for
> > property "ConnectionDriverName" in type "class
> > org.apache.openjpa.persistence.EntityManagerImpl".
>
> Because you shouldn't be passing your property map to the
> createEntityManager call.  That call takes EntityManager properties,
> not EntityManagerFactory settings.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
> When execute, for each of the Map key I'm passing I'm getting:
>
> <4|false|0.9.6-incubating-SNAPSHOT>
> org.apache.openjpa.persistence.ArgumentException: Missing getter for
> property "ConnectionDriverName" in type "class
> org.apache.openjpa.persistence.EntityManagerImpl".

Because you shouldn't be passing your property map to the  
createEntityManager call.  That call takes EntityManager properties,  
not EntityManagerFactory settings.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Marc Prud'hommeaux <mp...@apache.org>.
If you enable verbose logging on all channels (by setting the  
property "openjpa.Log" to "DefaultLevel=TRACE"), then you should see  
all the properties being outputted.

Note that "openjpa.ManagedRuntime" needs to be set to a plugin string  
or class name, not an actual object. That might be the cause of your  
problem.



On Jan 3, 2007, at 6:03 PM, Matthieu Riou wrote:

> I'm trying to debug why my properties don't get properly loaded.  
> Now my code
> looks like:
>
>        HashMap propMap = new HashMap();
>        propMap.put("openjpa.jdbc.DBDictionary", "
> org.apache.openjpa.jdbc.sql.DerbyDictionary");
>        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider 
> (_txMgr));
>        propMap.put("openjpa.ConnectionDriverName",
> org.apache.derby.jdbc.EmbeddedDriver.class.getName());
>        propMap.put("openjpa.ConnectionFactory", _datasource);
>        EntityManagerFactory emf =  
> Persistence.createEntityManagerFactory
> ("ode-dao");
>        EntityManager em = emf.createEntityManager(propMap);
>
> Where are the properties set on JDBConfigurationImpl? So I can  
> check what
> gets wrong in my case.
>
> Thanks,
>
> Matthieu
>
> On 1/3/07, Matthieu Riou <ma...@gmail.com> wrote:
>>
>> My ultimate goal is to provide directly an instance of DataSource  
>> that
>> OpenJPA would use instead of trying to lookup or create one. It  
>> seems that
>> it's possible by setting ConnectionFactory to the datasource  
>> instance but
>> OpenJPA fails before that if no ConnectionDriverName is specified.
>>
>> Abe is right when saying that I should provide the properties to
>> createEntityManager insteand of createEntityManagerFactory but I  
>> still can't
>> find to way to initialize everything property.
>>
>> Thanks,
>>
>> Matthieu
>>
>> On 1/3/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> >
>> > Matthieu-
>> >
>> > Can you send the complete stack trace?
>> >
>> > Also, I don't think this is the cause of the problem, but why  
>> are you
>> > specifying both ConnectionDriverName and ConnectionFactory? With
>> > ConnectionFactory specified, you shouldn't need to specify the
>> > ConnectionDriverName.
>> >
>> >
>> >
>> > On Jan 3, 2007, at 5:01 PM, Matthieu Riou wrote:
>> >
>> > > Sorry I've jumped too quickly to conclusions. The mistake was  
>> mine.
>> > >
>> > > However I'm trying to initialize OpenJPA programmatically  
>> using the
>> > > following code:
>> > >
>> > >        HashMap propMap = new HashMap();
>> > >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider
>> > > (_txMgr));
>> > >        propMap.put("openjpa.ConnectionDriverName ",
>> > > org.apache.derby.jdbc.EmbeddedDriver.class.getName());
>> > >        propMap.put("openjpa.ConnectionFactory", _datasource);
>> > >        EntityManagerFactory emf =
>> > > Persistence.createEntityManagerFactory ("ode-dao",
>> > > propMap);
>> > >        EntityManager em = emf.createEntityManager(propMap);
>> > >
>> > > The TxMgrProvider implements the ManagedRuntime interface.
>> > >
>> > > When execute, for each of the Map key I'm passing I'm getting:
>> > >
>> > > <4|false|0.9.6-incubating-SNAPSHOT>
>> > > org.apache.openjpa.persistence.ArgumentException: Missing  
>> getter for
>> > > property "ConnectionDriverName" in type "class
>> > > org.apache.openjpa.persistence.EntityManagerImpl ".
>> > >
>> > > With the NoSuchMethodException that comes together. As I'm  
>> passing
>> > > configuration properties I don't get why it tries to set of get
>> > > them on the
>> > > entity manager. I guess I'm doing something wrong, do you have an
>> > > idea of
>> > > what could that be?
>> > >
>> > > Thanks!
>> > >
>> > > Matthieu
>> > >
>> > > On 1/3/07, Abe White <aw...@bea.com> wrote:
>> > >>
>> > >> > I've been fighting for some time now with my OpenJPA  
>> configuration
>> > >> > and just
>> > >> > discovered why. It seems that you *either* consider the
>> > >> > persistence.xml file
>> > >> > *or* the map passed as parameter of
>> > >> > Persistence.createEntityManagerFactory .
>> > >> > If you look at PersistenceProductDerivation.load(String rsrc,
>> > >> > String name,
>> > >> > Map m) (line 151), if the configuration provider can find a
>> > >> > configuration
>> > >> > file then the configuration is returned as is and the provided
>> > >> > configuration
>> > >> > Map doesn't even gets considered.
>> > >>
>> > >> I don't see this.  The Map is passed along to the method that  
>> loads
>> > >> the configuration file, which passes it along to the  
>> configuration
>> > >> parser, which sets its entries over the properties it parses.
>> > >>  
>> _____________________________________________________________________
>> >
>> > >> __
>> > >> Notice:  This email message, together with any attachments, may
>> > >> contain
>> > >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
>> > >> affiliated
>> > >> entities,  that may be confidential,  proprietary,  copyrighted
>> > >> and/or
>> > >> legally privileged, and is intended solely for the use of the
>> > >> individual
>> > >> or entity named in this message. If you are not the intended
>> > >> recipient,
>> > >> and have received this message in error, please immediately  
>> return
>> > >> this
>> > >> by email and then delete it.
>> > >>
>> >
>> >
>>


Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
Sorry about that, I've been persistently reading your sentence the other way
around: use createEntityManager instead of createEntityManagerFactory. I've
finally got it in the right order, I guess I should get my eyes checked or
something. Thanks for insisting though :)

Now that I got it the right way, it seems to work as the I get the right
value for ConnectionFactory in the log after setting
javax.persistence.nonJtaDataSource as you recommended:

openjpa.ConnectionFactory:
org.opentools.minerva.connector.jdbc.JDBCDataSource@9a44f1

I'm hitting another problem but it comes from my code. I'll let you know if
I can get everything working this way.

Thanks a lot for your help!

On 1/3/07, Abe White <aw...@bea.com> wrote:
>
>
> >        EntityManagerFactory emf =
> > Persistence.createEntityManagerFactory
> > ("ode-dao");
> >        EntityManager em = emf.createEntityManager(propMap);
>
> Once again, you should be passing your props to
> createEntityManagerFactory, not createEntityManager.  As I said, use
> the no-arg version of createEntityManager:
>
> EntityManagerFactory emf = Persistence.createEntityManagerFactory
> ("ode-dao", propMap);
> EntityManager em = emf.createEntityManager();
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
>        EntityManagerFactory emf =  
> Persistence.createEntityManagerFactory
> ("ode-dao");
>        EntityManager em = emf.createEntityManager(propMap);

Once again, you should be passing your props to  
createEntityManagerFactory, not createEntityManager.  As I said, use  
the no-arg version of createEntityManager:

EntityManagerFactory emf = Persistence.createEntityManagerFactory 
("ode-dao", propMap);
EntityManager em = emf.createEntityManager();
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
I'm still having the same problem (it can't find my ConnectionDriverName
property). Now my code looks like:

        HashMap propMap = new HashMap();
        propMap.put("openjpa.jdbc.DBDictionary", "
org.apache.openjpa.jdbc.sql.DerbyDictionary");
        propMap.put("openjpa.ManagedRuntime", TxMgrProvider.class.getName
());
        propMap.put("openjpa.ConnectionDriverName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
        propMap.put("javax.persistence.nonJtaDataSource", _datasource);
        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
        EntityManagerFactory emf = Persistence.createEntityManagerFactory
("ode-dao");
        EntityManager em = emf.createEntityManager(propMap);

As you can see everything is a string exception
javax.persistence.nonJtaDataSource. I even tried to comment out this
property to only have string properties and I still got the same error.

I have 2 questions thought:

   1. If the loading of one property fails, no property gets loaded?
   2. I keep on looking at the code in
EntityManagerFactoryImpl.createEntityManager. The error appears on the call
to _factory.newBroker and it seems to me that nothing much is done with the
provided Map before that. When does the Map gets used exactly?

Thanks a lot for your help!

On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> OK, the problem is that we're only paying attention to openjpa.*
> property keys with String values when you bootstrap through
> Persistence.  I have no idea why, and I'll change it momentarily.
> But for now, you can work around the problem for your DataSource
> using the "javax.persistence.nonJtaDataSource" key instead of
> "openjpa.ConnectionFactory".  Unfortunately no such workaround exists
> for the ManagedRuntime.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

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

The following code works for me against the most recent OpenJPA build:

         org.apache.derby.jdbc.EmbeddedDataSource ds =
             new org.apache.derby.jdbc.EmbeddedDataSource();
         ds.setDatabaseName("testdb");
         ds.setCreateDatabase("create");

         Map props = new HashMap();
         props.put("openjpa.ConnectionFactory", ds);

         EntityManagerFactory emf = Persistence.
             createEntityManagerFactory("", props);
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         em.getTransaction().commit();
         em.close();
         emf.close();


Can you try again with the most recent snapshot and see if you still  
get the error?



On Jan 9, 2007, at 1:07 PM, Matthieu Riou wrote:

> So if I do:
>
>        propMap.put("openjpa.ConnectionDriverName",
> org.apache.derby.jdbc.EmbeddedDriver.class.getName());
>        propMap.put("openjpa.ConnectionFactoryName",
> org.apache.derby.jdbc.EmbeddedDriver.class.getName());
>        propMap.put("openjpa.ConnectionFactory", _datasource);
>
> It tries to lookup ConnectionFactoryName in JNDI which doesn't  
> work. If I
> remove ConnectionFactoryName and keep the other 2 it instantiates the
> EmbeddedDriver itself and ignores the datasource instance I provided.
>
> Another idea?
>
> On 1/9/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>>
>> Matthieu-
>>
>> We may not be expecting you to just manually set the DataSource. Try
>> setting the "openjpa.ConnectionFactory" property to the DataSource
>> object you are using, and then set "openjpa.ConnectionFactoryName" to
>> some bogus string and see what happens.
>>
>> If there is an error, be sure to post the complete stack trace.
>>
>>
>>
>> On Jan 9, 2007, at 9:11 AM, Matthieu Riou wrote:
>>
>> > If I don't set "openjpa.ConnectionDriverName" (and even if I set "
>> > openjpa.ConnectionFactory" with my datasource instance) I get the
>> > "A JDBC
>> > Driver or DataSource class name must be specified in the
>> > ConnectionDriverName property" error. So I'm getting more and more
>> > confused
>> > as to which properties I should set...
>> >
>> > On 1/8/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>> >>
>> >> Matthieu-
>> >>
>> >> I think you want "openjpa.ConnectionFactory", not
>> >> "openjpa.ConnectionDriverName".
>> >>
>> >>
>> >>
>> >> On Jan 8, 2007, at 9:45 AM, Matthieu Riou wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > I've just tried your fix after compiling the OpenJPA trunk. I'm
>> >> > getting a
>> >> > ClassCastException as the openjpa.ConnectionDriverName is set  
>> as a
>> >> > StringValue. Should I use another property instead?
>> >> >
>> >> > My code:
>> >> >
>> >> >        propMap.put("openjpa.jdbc.DBDictionary", "
>> >> > org.apache.openjpa.jdbc.sql.DerbyDictionary");
>> >> >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider 
>> ());
>> >> >        propMap.put("openjpa.ConnectionDriverName", _datasource);
>> >> >        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
>> >> >        EntityManagerFactory emf =
>> >> > Persistence.createEntityManagerFactory("ode-dao",
>> >> > propMap);
>> >> >        EntityManager em = emf.createEntityManager();
>> >> >
>> >> > The exception:
>> >> >
>> >> > <0|true|0.9.7-incubating-SNAPSHOT>
>> >> > org.apache.openjpa.persistence.PersistenceException: There  
>> was an
>> >> > error when
>> >> > invoking the static newInstance method on the named factory  
>> class "
>> >> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the  
>> nested
>> >> > exception
>> >> > for details.
>> >> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
>> >> > Bootstrap.java:62)
>> >> >        at
>> >> >
>> >>  
>> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa
>> >> n
>> >> > agerFactory
>> >> > (PersistenceProviderImpl.java:70)
>> >> >        at
>> >> >
>> >>  
>> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa
>> >> n
>> >> > agerFactory
>> >> > (PersistenceProviderImpl.java:78)
>> >> >        at  
>> javax.persistence.Persistence.createEntityManagerFactory(
>> >> > Persistence.java:83)
>> >> >        at org.apache.ode.axis2.ODEServerJPA.initJPA
>> >> > (ODEServerJPA.java:345)
>> >> >        at org.apache.ode.axis2.ODEServerJPA.init
>> >> (ODEServerJPA.java:96)
>> >> >        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
>> >> > ODEAxisServlet.java:50)
>> >> >        at org.apache.catalina.core.StandardWrapper.loadServlet(
>> >> > StandardWrapper.java:1105)
>> >> >        at org.apache.catalina.core.StandardWrapper.load(
>> >> > StandardWrapper.java:932)
>> >> >        at  
>> org.apache.catalina.core.StandardContext.loadOnStartup(
>> >> > StandardContext.java:3917)
>> >> >        at org.apache.catalina.core.StandardContext.start(
>> >> > StandardContext.java:4201)
>> >> >        at  
>> org.apache.catalina.core.ContainerBase.addChildInternal(
>> >> > ContainerBase.java:759)
>> >> >        at org.apache.catalina.core.ContainerBase.addChild(
>> >> > ContainerBase.java:739)
>> >> >        at org.apache.catalina.core.StandardHost.addChild
>> >> > (StandardHost.java
>> >> > :524)
>> >> >        at org.apache.catalina.startup.HostConfig.deployWAR
>> >> > (HostConfig.java
>> >> > :809)
>> >> >        at org.apache.catalina.startup.HostConfig.deployWARs
>> >> > (HostConfig.java
>> >> > :698)
>> >> >        at org.apache.catalina.startup.HostConfig.deployApps
>> >> > (HostConfig.java
>> >> > :472)
>> >> >        at org.apache.catalina.startup.HostConfig.start
>> >> (HostConfig.java
>> >> > :1122)
>> >> >        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
>> >> > HostConfig.java:310)
>> >> >        at
>> >> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
>> >> > LifecycleSupport.java:119)
>> >> >        at org.apache.catalina.core.ContainerBase.start
>> >> > (ContainerBase.java
>> >> > :1021)
>> >> >        at org.apache.catalina.core.StandardHost.start
>> >> > (StandardHost.java
>> >> > :718)
>> >> >        at org.apache.catalina.core.ContainerBase.start
>> >> > (ContainerBase.java
>> >> > :1013)
>> >> >        at org.apache.catalina.core.StandardEngine.start
>> >> > (StandardEngine.java
>> >> > :442)
>> >> >        at org.apache.catalina.core.StandardService.start(
>> >> > StandardService.java:450)
>> >> >        at org.apache.catalina.core.StandardServer.start
>> >> > (StandardServer.java
>> >> > :709)
>> >> >        at org.apache.catalina.startup.Catalina.start 
>> (Catalina.java:
>> >> > 551)
>> >> >        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.apache.catalina.startup.Bootstrap.start
>> >> > (Bootstrap.java:294)
>> >> >        at org.apache.catalina.startup.Bootstrap.main
>> >> (Bootstrap.java:
>> >> > 432)
>> >> > Caused by: org.apache.openjpa.lib.util.ParseException:
>> >> > ConnectionDriverName:
>> >> > org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
>> >> >        at org.apache.openjpa.lib.conf.Value.setObject 
>> (Value.java:
>> >> 298)
>> >> >        at
>> >> > org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
>> >> > ConfigurationImpl.java:627)
>> >> >        at
>> >> > org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
>> >> > MapConfigurationProvider.java:82)
>> >> >        at
>> >> > org.apache.openjpa.persistence.PersistenceProductDerivation
>> >> > $ConfigurationProviderImpl.setInto
>> >> > (PersistenceProductDerivation.java:406)
>> >> >        at
>> >> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
>> >> > JDBCBrokerFactory.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:585)
>> >> >        at org.apache.openjpa.kernel.Bootstrap.invokeFactory
>> >> > (Bootstrap.java
>> >> > :117)
>> >> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
>> >> > Bootstrap.java:57)
>> >> >        ... 32 more
>> >> > Caused by: java.lang.ClassCastException:
>> >> > org.opentools.minerva.connector.jdbc.JDBCDataSource
>> >> >        at
>> >> org.apache.openjpa.lib.conf.StringValue.setInternalObject(
>> >> > StringValue.java:63)
>> >> >        at org.apache.openjpa.lib.conf.Value.setObject 
>> (Value.java:
>> >> 294)
>> >> >        ... 42 more
>> >> >
>> >> > Thanks!
>> >> >
>> >> > Matthieu
>> >> >
>> >> > On 1/3/07, Abe White <aw...@bea.com> wrote:
>> >> >>
>> >> >> SVN revision 492368 no long ignores non-String values for
>> >> openjpa.*
>> >> >> keys in the Map passed to  
>> Persistence.createEntityManagerFactory.
>> >> >>
>> >>  
>> _____________________________________________________________________
>> >> >> __
>> >> >> Notice:  This email message, together with any attachments, may
>> >> >> contain
>> >> >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
>> >> >> affiliated
>> >> >> entities,  that may be confidential,  proprietary,  copyrighted
>> >> >> and/or
>> >> >> legally privileged, and is intended solely for the use of the
>> >> >> individual
>> >> >> or entity named in this message. If you are not the intended
>> >> >> recipient,
>> >> >> and have received this message in error, please immediately  
>> return
>> >> >> this
>> >> >> by email and then delete it.
>> >> >>
>> >>
>> >>
>>
>>


Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
So if I do:

        propMap.put("openjpa.ConnectionDriverName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
        propMap.put("openjpa.ConnectionFactoryName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
        propMap.put("openjpa.ConnectionFactory", _datasource);

It tries to lookup ConnectionFactoryName in JNDI which doesn't work. If I
remove ConnectionFactoryName and keep the other 2 it instantiates the
EmbeddedDriver itself and ignores the datasource instance I provided.

Another idea?

On 1/9/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> Matthieu-
>
> We may not be expecting you to just manually set the DataSource. Try
> setting the "openjpa.ConnectionFactory" property to the DataSource
> object you are using, and then set "openjpa.ConnectionFactoryName" to
> some bogus string and see what happens.
>
> If there is an error, be sure to post the complete stack trace.
>
>
>
> On Jan 9, 2007, at 9:11 AM, Matthieu Riou wrote:
>
> > If I don't set "openjpa.ConnectionDriverName" (and even if I set "
> > openjpa.ConnectionFactory" with my datasource instance) I get the
> > "A JDBC
> > Driver or DataSource class name must be specified in the
> > ConnectionDriverName property" error. So I'm getting more and more
> > confused
> > as to which properties I should set...
> >
> > On 1/8/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >>
> >> Matthieu-
> >>
> >> I think you want "openjpa.ConnectionFactory", not
> >> "openjpa.ConnectionDriverName".
> >>
> >>
> >>
> >> On Jan 8, 2007, at 9:45 AM, Matthieu Riou wrote:
> >>
> >> > Hi,
> >> >
> >> > I've just tried your fix after compiling the OpenJPA trunk. I'm
> >> > getting a
> >> > ClassCastException as the openjpa.ConnectionDriverName is set as a
> >> > StringValue. Should I use another property instead?
> >> >
> >> > My code:
> >> >
> >> >        propMap.put("openjpa.jdbc.DBDictionary", "
> >> > org.apache.openjpa.jdbc.sql.DerbyDictionary");
> >> >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider());
> >> >        propMap.put("openjpa.ConnectionDriverName", _datasource);
> >> >        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
> >> >        EntityManagerFactory emf =
> >> > Persistence.createEntityManagerFactory("ode-dao",
> >> > propMap);
> >> >        EntityManager em = emf.createEntityManager();
> >> >
> >> > The exception:
> >> >
> >> > <0|true|0.9.7-incubating-SNAPSHOT>
> >> > org.apache.openjpa.persistence.PersistenceException: There was an
> >> > error when
> >> > invoking the static newInstance method on the named factory class "
> >> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the nested
> >> > exception
> >> > for details.
> >> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> >> > Bootstrap.java:62)
> >> >        at
> >> >
> >> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa
> >> n
> >> > agerFactory
> >> > (PersistenceProviderImpl.java:70)
> >> >        at
> >> >
> >> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa
> >> n
> >> > agerFactory
> >> > (PersistenceProviderImpl.java:78)
> >> >        at javax.persistence.Persistence.createEntityManagerFactory(
> >> > Persistence.java:83)
> >> >        at org.apache.ode.axis2.ODEServerJPA.initJPA
> >> > (ODEServerJPA.java:345)
> >> >        at org.apache.ode.axis2.ODEServerJPA.init
> >> (ODEServerJPA.java:96)
> >> >        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
> >> > ODEAxisServlet.java:50)
> >> >        at org.apache.catalina.core.StandardWrapper.loadServlet(
> >> > StandardWrapper.java:1105)
> >> >        at org.apache.catalina.core.StandardWrapper.load(
> >> > StandardWrapper.java:932)
> >> >        at org.apache.catalina.core.StandardContext.loadOnStartup(
> >> > StandardContext.java:3917)
> >> >        at org.apache.catalina.core.StandardContext.start(
> >> > StandardContext.java:4201)
> >> >        at org.apache.catalina.core.ContainerBase.addChildInternal(
> >> > ContainerBase.java:759)
> >> >        at org.apache.catalina.core.ContainerBase.addChild(
> >> > ContainerBase.java:739)
> >> >        at org.apache.catalina.core.StandardHost.addChild
> >> > (StandardHost.java
> >> > :524)
> >> >        at org.apache.catalina.startup.HostConfig.deployWAR
> >> > (HostConfig.java
> >> > :809)
> >> >        at org.apache.catalina.startup.HostConfig.deployWARs
> >> > (HostConfig.java
> >> > :698)
> >> >        at org.apache.catalina.startup.HostConfig.deployApps
> >> > (HostConfig.java
> >> > :472)
> >> >        at org.apache.catalina.startup.HostConfig.start
> >> (HostConfig.java
> >> > :1122)
> >> >        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
> >> > HostConfig.java:310)
> >> >        at
> >> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
> >> > LifecycleSupport.java:119)
> >> >        at org.apache.catalina.core.ContainerBase.start
> >> > (ContainerBase.java
> >> > :1021)
> >> >        at org.apache.catalina.core.StandardHost.start
> >> > (StandardHost.java
> >> > :718)
> >> >        at org.apache.catalina.core.ContainerBase.start
> >> > (ContainerBase.java
> >> > :1013)
> >> >        at org.apache.catalina.core.StandardEngine.start
> >> > (StandardEngine.java
> >> > :442)
> >> >        at org.apache.catalina.core.StandardService.start(
> >> > StandardService.java:450)
> >> >        at org.apache.catalina.core.StandardServer.start
> >> > (StandardServer.java
> >> > :709)
> >> >        at org.apache.catalina.startup.Catalina.start(Catalina.java:
> >> > 551)
> >> >        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.apache.catalina.startup.Bootstrap.start
> >> > (Bootstrap.java:294)
> >> >        at org.apache.catalina.startup.Bootstrap.main
> >> (Bootstrap.java:
> >> > 432)
> >> > Caused by: org.apache.openjpa.lib.util.ParseException:
> >> > ConnectionDriverName:
> >> > org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
> >> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:
> >> 298)
> >> >        at
> >> > org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
> >> > ConfigurationImpl.java:627)
> >> >        at
> >> > org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
> >> > MapConfigurationProvider.java:82)
> >> >        at
> >> > org.apache.openjpa.persistence.PersistenceProductDerivation
> >> > $ConfigurationProviderImpl.setInto
> >> > (PersistenceProductDerivation.java:406)
> >> >        at
> >> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
> >> > JDBCBrokerFactory.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:585)
> >> >        at org.apache.openjpa.kernel.Bootstrap.invokeFactory
> >> > (Bootstrap.java
> >> > :117)
> >> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> >> > Bootstrap.java:57)
> >> >        ... 32 more
> >> > Caused by: java.lang.ClassCastException:
> >> > org.opentools.minerva.connector.jdbc.JDBCDataSource
> >> >        at
> >> org.apache.openjpa.lib.conf.StringValue.setInternalObject(
> >> > StringValue.java:63)
> >> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:
> >> 294)
> >> >        ... 42 more
> >> >
> >> > Thanks!
> >> >
> >> > Matthieu
> >> >
> >> > On 1/3/07, Abe White <aw...@bea.com> wrote:
> >> >>
> >> >> SVN revision 492368 no long ignores non-String values for
> >> openjpa.*
> >> >> keys in the Map passed to Persistence.createEntityManagerFactory.
> >> >>
> >> _____________________________________________________________________
> >> >> __
> >> >> Notice:  This email message, together with any attachments, may
> >> >> contain
> >> >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
> >> >> affiliated
> >> >> entities,  that may be confidential,  proprietary,  copyrighted
> >> >> and/or
> >> >> legally privileged, and is intended solely for the use of the
> >> >> individual
> >> >> or entity named in this message. If you are not the intended
> >> >> recipient,
> >> >> and have received this message in error, please immediately return
> >> >> this
> >> >> by email and then delete it.
> >> >>
> >>
> >>
>
>

Re: Configuration: either / or ?

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

We may not be expecting you to just manually set the DataSource. Try  
setting the "openjpa.ConnectionFactory" property to the DataSource  
object you are using, and then set "openjpa.ConnectionFactoryName" to  
some bogus string and see what happens.

If there is an error, be sure to post the complete stack trace.



On Jan 9, 2007, at 9:11 AM, Matthieu Riou wrote:

> If I don't set "openjpa.ConnectionDriverName" (and even if I set "
> openjpa.ConnectionFactory" with my datasource instance) I get the  
> "A JDBC
> Driver or DataSource class name must be specified in the
> ConnectionDriverName property" error. So I'm getting more and more  
> confused
> as to which properties I should set...
>
> On 1/8/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>>
>> Matthieu-
>>
>> I think you want "openjpa.ConnectionFactory", not
>> "openjpa.ConnectionDriverName".
>>
>>
>>
>> On Jan 8, 2007, at 9:45 AM, Matthieu Riou wrote:
>>
>> > Hi,
>> >
>> > I've just tried your fix after compiling the OpenJPA trunk. I'm
>> > getting a
>> > ClassCastException as the openjpa.ConnectionDriverName is set as a
>> > StringValue. Should I use another property instead?
>> >
>> > My code:
>> >
>> >        propMap.put("openjpa.jdbc.DBDictionary", "
>> > org.apache.openjpa.jdbc.sql.DerbyDictionary");
>> >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider());
>> >        propMap.put("openjpa.ConnectionDriverName", _datasource);
>> >        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
>> >        EntityManagerFactory emf =
>> > Persistence.createEntityManagerFactory("ode-dao",
>> > propMap);
>> >        EntityManager em = emf.createEntityManager();
>> >
>> > The exception:
>> >
>> > <0|true|0.9.7-incubating-SNAPSHOT>
>> > org.apache.openjpa.persistence.PersistenceException: There was an
>> > error when
>> > invoking the static newInstance method on the named factory class "
>> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the nested
>> > exception
>> > for details.
>> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
>> > Bootstrap.java:62)
>> >        at
>> >  
>> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa 
>> n
>> > agerFactory
>> > (PersistenceProviderImpl.java:70)
>> >        at
>> >  
>> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMa 
>> n
>> > agerFactory
>> > (PersistenceProviderImpl.java:78)
>> >        at javax.persistence.Persistence.createEntityManagerFactory(
>> > Persistence.java:83)
>> >        at org.apache.ode.axis2.ODEServerJPA.initJPA
>> > (ODEServerJPA.java:345)
>> >        at org.apache.ode.axis2.ODEServerJPA.init 
>> (ODEServerJPA.java:96)
>> >        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
>> > ODEAxisServlet.java:50)
>> >        at org.apache.catalina.core.StandardWrapper.loadServlet(
>> > StandardWrapper.java:1105)
>> >        at org.apache.catalina.core.StandardWrapper.load(
>> > StandardWrapper.java:932)
>> >        at org.apache.catalina.core.StandardContext.loadOnStartup(
>> > StandardContext.java:3917)
>> >        at org.apache.catalina.core.StandardContext.start(
>> > StandardContext.java:4201)
>> >        at org.apache.catalina.core.ContainerBase.addChildInternal(
>> > ContainerBase.java:759)
>> >        at org.apache.catalina.core.ContainerBase.addChild(
>> > ContainerBase.java:739)
>> >        at org.apache.catalina.core.StandardHost.addChild
>> > (StandardHost.java
>> > :524)
>> >        at org.apache.catalina.startup.HostConfig.deployWAR
>> > (HostConfig.java
>> > :809)
>> >        at org.apache.catalina.startup.HostConfig.deployWARs
>> > (HostConfig.java
>> > :698)
>> >        at org.apache.catalina.startup.HostConfig.deployApps
>> > (HostConfig.java
>> > :472)
>> >        at org.apache.catalina.startup.HostConfig.start 
>> (HostConfig.java
>> > :1122)
>> >        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
>> > HostConfig.java:310)
>> >        at
>> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
>> > LifecycleSupport.java:119)
>> >        at org.apache.catalina.core.ContainerBase.start
>> > (ContainerBase.java
>> > :1021)
>> >        at org.apache.catalina.core.StandardHost.start
>> > (StandardHost.java
>> > :718)
>> >        at org.apache.catalina.core.ContainerBase.start
>> > (ContainerBase.java
>> > :1013)
>> >        at org.apache.catalina.core.StandardEngine.start
>> > (StandardEngine.java
>> > :442)
>> >        at org.apache.catalina.core.StandardService.start(
>> > StandardService.java:450)
>> >        at org.apache.catalina.core.StandardServer.start
>> > (StandardServer.java
>> > :709)
>> >        at org.apache.catalina.startup.Catalina.start(Catalina.java:
>> > 551)
>> >        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.apache.catalina.startup.Bootstrap.start
>> > (Bootstrap.java:294)
>> >        at org.apache.catalina.startup.Bootstrap.main 
>> (Bootstrap.java:
>> > 432)
>> > Caused by: org.apache.openjpa.lib.util.ParseException:
>> > ConnectionDriverName:
>> > org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
>> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java: 
>> 298)
>> >        at
>> > org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
>> > ConfigurationImpl.java:627)
>> >        at
>> > org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
>> > MapConfigurationProvider.java:82)
>> >        at
>> > org.apache.openjpa.persistence.PersistenceProductDerivation
>> > $ConfigurationProviderImpl.setInto
>> > (PersistenceProductDerivation.java:406)
>> >        at
>> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
>> > JDBCBrokerFactory.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:585)
>> >        at org.apache.openjpa.kernel.Bootstrap.invokeFactory
>> > (Bootstrap.java
>> > :117)
>> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
>> > Bootstrap.java:57)
>> >        ... 32 more
>> > Caused by: java.lang.ClassCastException:
>> > org.opentools.minerva.connector.jdbc.JDBCDataSource
>> >        at  
>> org.apache.openjpa.lib.conf.StringValue.setInternalObject(
>> > StringValue.java:63)
>> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java: 
>> 294)
>> >        ... 42 more
>> >
>> > Thanks!
>> >
>> > Matthieu
>> >
>> > On 1/3/07, Abe White <aw...@bea.com> wrote:
>> >>
>> >> SVN revision 492368 no long ignores non-String values for  
>> openjpa.*
>> >> keys in the Map passed to Persistence.createEntityManagerFactory.
>> >>  
>> _____________________________________________________________________
>> >> __
>> >> Notice:  This email message, together with any attachments, may
>> >> contain
>> >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
>> >> affiliated
>> >> entities,  that may be confidential,  proprietary,  copyrighted
>> >> and/or
>> >> legally privileged, and is intended solely for the use of the
>> >> individual
>> >> or entity named in this message. If you are not the intended
>> >> recipient,
>> >> and have received this message in error, please immediately return
>> >> this
>> >> by email and then delete it.
>> >>
>>
>>


Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
If I don't set "openjpa.ConnectionDriverName" (and even if I set "
openjpa.ConnectionFactory" with my datasource instance) I get the "A JDBC
Driver or DataSource class name must be specified in the
ConnectionDriverName property" error. So I'm getting more and more confused
as to which properties I should set...

On 1/8/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> Matthieu-
>
> I think you want "openjpa.ConnectionFactory", not
> "openjpa.ConnectionDriverName".
>
>
>
> On Jan 8, 2007, at 9:45 AM, Matthieu Riou wrote:
>
> > Hi,
> >
> > I've just tried your fix after compiling the OpenJPA trunk. I'm
> > getting a
> > ClassCastException as the openjpa.ConnectionDriverName is set as a
> > StringValue. Should I use another property instead?
> >
> > My code:
> >
> >        propMap.put("openjpa.jdbc.DBDictionary", "
> > org.apache.openjpa.jdbc.sql.DerbyDictionary");
> >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider());
> >        propMap.put("openjpa.ConnectionDriverName", _datasource);
> >        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
> >        EntityManagerFactory emf =
> > Persistence.createEntityManagerFactory("ode-dao",
> > propMap);
> >        EntityManager em = emf.createEntityManager();
> >
> > The exception:
> >
> > <0|true|0.9.7-incubating-SNAPSHOT>
> > org.apache.openjpa.persistence.PersistenceException: There was an
> > error when
> > invoking the static newInstance method on the named factory class "
> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the nested
> > exception
> > for details.
> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> > Bootstrap.java:62)
> >        at
> > org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMan
> > agerFactory
> > (PersistenceProviderImpl.java:70)
> >        at
> > org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMan
> > agerFactory
> > (PersistenceProviderImpl.java:78)
> >        at javax.persistence.Persistence.createEntityManagerFactory(
> > Persistence.java:83)
> >        at org.apache.ode.axis2.ODEServerJPA.initJPA
> > (ODEServerJPA.java:345)
> >        at org.apache.ode.axis2.ODEServerJPA.init(ODEServerJPA.java:96)
> >        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
> > ODEAxisServlet.java:50)
> >        at org.apache.catalina.core.StandardWrapper.loadServlet(
> > StandardWrapper.java:1105)
> >        at org.apache.catalina.core.StandardWrapper.load(
> > StandardWrapper.java:932)
> >        at org.apache.catalina.core.StandardContext.loadOnStartup(
> > StandardContext.java:3917)
> >        at org.apache.catalina.core.StandardContext.start(
> > StandardContext.java:4201)
> >        at org.apache.catalina.core.ContainerBase.addChildInternal(
> > ContainerBase.java:759)
> >        at org.apache.catalina.core.ContainerBase.addChild(
> > ContainerBase.java:739)
> >        at org.apache.catalina.core.StandardHost.addChild
> > (StandardHost.java
> > :524)
> >        at org.apache.catalina.startup.HostConfig.deployWAR
> > (HostConfig.java
> > :809)
> >        at org.apache.catalina.startup.HostConfig.deployWARs
> > (HostConfig.java
> > :698)
> >        at org.apache.catalina.startup.HostConfig.deployApps
> > (HostConfig.java
> > :472)
> >        at org.apache.catalina.startup.HostConfig.start(HostConfig.java
> > :1122)
> >        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
> > HostConfig.java:310)
> >        at
> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
> > LifecycleSupport.java:119)
> >        at org.apache.catalina.core.ContainerBase.start
> > (ContainerBase.java
> > :1021)
> >        at org.apache.catalina.core.StandardHost.start
> > (StandardHost.java
> > :718)
> >        at org.apache.catalina.core.ContainerBase.start
> > (ContainerBase.java
> > :1013)
> >        at org.apache.catalina.core.StandardEngine.start
> > (StandardEngine.java
> > :442)
> >        at org.apache.catalina.core.StandardService.start(
> > StandardService.java:450)
> >        at org.apache.catalina.core.StandardServer.start
> > (StandardServer.java
> > :709)
> >        at org.apache.catalina.startup.Catalina.start(Catalina.java:
> > 551)
> >        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.apache.catalina.startup.Bootstrap.start
> > (Bootstrap.java:294)
> >        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:
> > 432)
> > Caused by: org.apache.openjpa.lib.util.ParseException:
> > ConnectionDriverName:
> > org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:298)
> >        at
> > org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
> > ConfigurationImpl.java:627)
> >        at
> > org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
> > MapConfigurationProvider.java:82)
> >        at
> > org.apache.openjpa.persistence.PersistenceProductDerivation
> > $ConfigurationProviderImpl.setInto
> > (PersistenceProductDerivation.java:406)
> >        at
> > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
> > JDBCBrokerFactory.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:585)
> >        at org.apache.openjpa.kernel.Bootstrap.invokeFactory
> > (Bootstrap.java
> > :117)
> >        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> > Bootstrap.java:57)
> >        ... 32 more
> > Caused by: java.lang.ClassCastException:
> > org.opentools.minerva.connector.jdbc.JDBCDataSource
> >        at org.apache.openjpa.lib.conf.StringValue.setInternalObject(
> > StringValue.java:63)
> >        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:294)
> >        ... 42 more
> >
> > Thanks!
> >
> > Matthieu
> >
> > On 1/3/07, Abe White <aw...@bea.com> wrote:
> >>
> >> SVN revision 492368 no long ignores non-String values for openjpa.*
> >> keys in the Map passed to Persistence.createEntityManagerFactory.
> >> _____________________________________________________________________
> >> __
> >> Notice:  This email message, together with any attachments, may
> >> contain
> >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
> >> affiliated
> >> entities,  that may be confidential,  proprietary,  copyrighted
> >> and/or
> >> legally privileged, and is intended solely for the use of the
> >> individual
> >> or entity named in this message. If you are not the intended
> >> recipient,
> >> and have received this message in error, please immediately return
> >> this
> >> by email and then delete it.
> >>
>
>

Re: Configuration: either / or ?

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

I think you want "openjpa.ConnectionFactory", not  
"openjpa.ConnectionDriverName".



On Jan 8, 2007, at 9:45 AM, Matthieu Riou wrote:

> Hi,
>
> I've just tried your fix after compiling the OpenJPA trunk. I'm  
> getting a
> ClassCastException as the openjpa.ConnectionDriverName is set as a
> StringValue. Should I use another property instead?
>
> My code:
>
>        propMap.put("openjpa.jdbc.DBDictionary", "
> org.apache.openjpa.jdbc.sql.DerbyDictionary");
>        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider());
>        propMap.put("openjpa.ConnectionDriverName", _datasource);
>        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
>        EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("ode-dao",
> propMap);
>        EntityManager em = emf.createEntityManager();
>
> The exception:
>
> <0|true|0.9.7-incubating-SNAPSHOT>
> org.apache.openjpa.persistence.PersistenceException: There was an  
> error when
> invoking the static newInstance method on the named factory class "
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the nested  
> exception
> for details.
>        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> Bootstrap.java:62)
>        at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMan 
> agerFactory
> (PersistenceProviderImpl.java:70)
>        at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityMan 
> agerFactory
> (PersistenceProviderImpl.java:78)
>        at javax.persistence.Persistence.createEntityManagerFactory(
> Persistence.java:83)
>        at org.apache.ode.axis2.ODEServerJPA.initJPA 
> (ODEServerJPA.java:345)
>        at org.apache.ode.axis2.ODEServerJPA.init(ODEServerJPA.java:96)
>        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
> ODEAxisServlet.java:50)
>        at org.apache.catalina.core.StandardWrapper.loadServlet(
> StandardWrapper.java:1105)
>        at org.apache.catalina.core.StandardWrapper.load(
> StandardWrapper.java:932)
>        at org.apache.catalina.core.StandardContext.loadOnStartup(
> StandardContext.java:3917)
>        at org.apache.catalina.core.StandardContext.start(
> StandardContext.java:4201)
>        at org.apache.catalina.core.ContainerBase.addChildInternal(
> ContainerBase.java:759)
>        at org.apache.catalina.core.ContainerBase.addChild(
> ContainerBase.java:739)
>        at org.apache.catalina.core.StandardHost.addChild 
> (StandardHost.java
> :524)
>        at org.apache.catalina.startup.HostConfig.deployWAR 
> (HostConfig.java
> :809)
>        at org.apache.catalina.startup.HostConfig.deployWARs 
> (HostConfig.java
> :698)
>        at org.apache.catalina.startup.HostConfig.deployApps 
> (HostConfig.java
> :472)
>        at org.apache.catalina.startup.HostConfig.start(HostConfig.java
> :1122)
>        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
> HostConfig.java:310)
>        at  
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
> LifecycleSupport.java:119)
>        at org.apache.catalina.core.ContainerBase.start 
> (ContainerBase.java
> :1021)
>        at org.apache.catalina.core.StandardHost.start 
> (StandardHost.java
> :718)
>        at org.apache.catalina.core.ContainerBase.start 
> (ContainerBase.java
> :1013)
>        at org.apache.catalina.core.StandardEngine.start 
> (StandardEngine.java
> :442)
>        at org.apache.catalina.core.StandardService.start(
> StandardService.java:450)
>        at org.apache.catalina.core.StandardServer.start 
> (StandardServer.java
> :709)
>        at org.apache.catalina.startup.Catalina.start(Catalina.java: 
> 551)
>        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.apache.catalina.startup.Bootstrap.start 
> (Bootstrap.java:294)
>        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java: 
> 432)
> Caused by: org.apache.openjpa.lib.util.ParseException:  
> ConnectionDriverName:
> org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
>        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:298)
>        at  
> org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
> ConfigurationImpl.java:627)
>        at  
> org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
> MapConfigurationProvider.java:82)
>        at
> org.apache.openjpa.persistence.PersistenceProductDerivation 
> $ConfigurationProviderImpl.setInto
> (PersistenceProductDerivation.java:406)
>        at  
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
> JDBCBrokerFactory.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:585)
>        at org.apache.openjpa.kernel.Bootstrap.invokeFactory 
> (Bootstrap.java
> :117)
>        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
> Bootstrap.java:57)
>        ... 32 more
> Caused by: java.lang.ClassCastException:
> org.opentools.minerva.connector.jdbc.JDBCDataSource
>        at org.apache.openjpa.lib.conf.StringValue.setInternalObject(
> StringValue.java:63)
>        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:294)
>        ... 42 more
>
> Thanks!
>
> Matthieu
>
> On 1/3/07, Abe White <aw...@bea.com> wrote:
>>
>> SVN revision 492368 no long ignores non-String values for openjpa.*
>> keys in the Map passed to Persistence.createEntityManagerFactory.
>> _____________________________________________________________________ 
>> __
>> Notice:  This email message, together with any attachments, may  
>> contain
>> information  of  BEA Systems,  Inc.,  its subsidiaries  and   
>> affiliated
>> entities,  that may be confidential,  proprietary,  copyrighted   
>> and/or
>> legally privileged, and is intended solely for the use of the  
>> individual
>> or entity named in this message. If you are not the intended  
>> recipient,
>> and have received this message in error, please immediately return  
>> this
>> by email and then delete it.
>>


Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
Hi,

I've just tried your fix after compiling the OpenJPA trunk. I'm getting a
ClassCastException as the openjpa.ConnectionDriverName is set as a
StringValue. Should I use another property instead?

My code:

        propMap.put("openjpa.jdbc.DBDictionary", "
org.apache.openjpa.jdbc.sql.DerbyDictionary");
        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider());
        propMap.put("openjpa.ConnectionDriverName", _datasource);
        propMap.put("openjpa.Log", "DefaultLevel=TRACE");
        EntityManagerFactory emf =
Persistence.createEntityManagerFactory("ode-dao",
propMap);
        EntityManager em = emf.createEntityManager();

The exception:

<0|true|0.9.7-incubating-SNAPSHOT>
org.apache.openjpa.persistence.PersistenceException: There was an error when
invoking the static newInstance method on the named factory class "
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory".  See the nested exception
for details.
        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
Bootstrap.java:62)
        at
org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory
(PersistenceProviderImpl.java:70)
        at
org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory
(PersistenceProviderImpl.java:78)
        at javax.persistence.Persistence.createEntityManagerFactory(
Persistence.java:83)
        at org.apache.ode.axis2.ODEServerJPA.initJPA(ODEServerJPA.java:345)
        at org.apache.ode.axis2.ODEServerJPA.init(ODEServerJPA.java:96)
        at org.apache.ode.axis2.hooks.ODEAxisServlet.init(
ODEAxisServlet.java:50)
        at org.apache.catalina.core.StandardWrapper.loadServlet(
StandardWrapper.java:1105)
        at org.apache.catalina.core.StandardWrapper.load(
StandardWrapper.java:932)
        at org.apache.catalina.core.StandardContext.loadOnStartup(
StandardContext.java:3917)
        at org.apache.catalina.core.StandardContext.start(
StandardContext.java:4201)
        at org.apache.catalina.core.ContainerBase.addChildInternal(
ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(
ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java
:524)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java
:809)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java
:698)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java
:472)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java
:1122)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java
:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java
:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java
:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java
:442)
        at org.apache.catalina.core.StandardService.start(
StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java
:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: org.apache.openjpa.lib.util.ParseException: ConnectionDriverName:
org.opentools.minerva.connector.jdbc.JDBCDataSource@dfbb43
        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:298)
        at org.apache.openjpa.lib.conf.ConfigurationImpl.fromProperties(
ConfigurationImpl.java:627)
        at org.apache.openjpa.lib.conf.MapConfigurationProvider.setInto(
MapConfigurationProvider.java:82)
        at
org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto
(PersistenceProductDerivation.java:406)
        at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(
JDBCBrokerFactory.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:585)
        at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java
:117)
        at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(
Bootstrap.java:57)
        ... 32 more
Caused by: java.lang.ClassCastException:
org.opentools.minerva.connector.jdbc.JDBCDataSource
        at org.apache.openjpa.lib.conf.StringValue.setInternalObject(
StringValue.java:63)
        at org.apache.openjpa.lib.conf.Value.setObject(Value.java:294)
        ... 42 more

Thanks!

Matthieu

On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> SVN revision 492368 no long ignores non-String values for openjpa.*
> keys in the Map passed to Persistence.createEntityManagerFactory.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
SVN revision 492368 no long ignores non-String values for openjpa.*  
keys in the Map passed to Persistence.createEntityManagerFactory.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
> OK, the problem is that we're only paying attention to openjpa.*  
> property keys with String values when you bootstrap through  
> Persistence.  I have no idea why, and I'll change it momentarily.

Actually I now see why, and I might not be able to fix it before I  
leave work today.  For anyone who's interested, it's because we  
combine the parsed persistence.xml with the Map into a  
PersistenceUnitInfo, and PersistenceUnitInfo returns a Properties  
instance from getProperties() instead of a generic Map, implying all  
String values. 
  
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
OK, the problem is that we're only paying attention to openjpa.*  
property keys with String values when you bootstrap through  
Persistence.  I have no idea why, and I'll change it momentarily.   
But for now, you can work around the problem for your DataSource  
using the "javax.persistence.nonJtaDataSource" key instead of  
"openjpa.ConnectionFactory".  Unfortunately no such workaround exists  
for the ManagedRuntime.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
Cool! I've tried to set openjpa.Log but like all other properties it doesn't
get considered by the entity manager. It's just like my whole Map gets
ignored. I'm also setting the DBDictionary but it also gets ignored as I get
the dictionary auto-detection message...

Something else I can do to debug this? I'm able to do a step-by-step into
the code but it seems that the properties on configuration classes are set
through introspection so it's hard to track down.

On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> I'm able to reproduce the ConnectionDriverName problem.  I'll have
> more info in a bit.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
I'm able to reproduce the ConnectionDriverName problem.  I'll have  
more info in a bit.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
I'm trying to debug why my properties don't get properly loaded. Now my code
looks like:

        HashMap propMap = new HashMap();
        propMap.put("openjpa.jdbc.DBDictionary", "
org.apache.openjpa.jdbc.sql.DerbyDictionary");
        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider(_txMgr));
        propMap.put("openjpa.ConnectionDriverName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
        propMap.put("openjpa.ConnectionFactory", _datasource);
        EntityManagerFactory emf = Persistence.createEntityManagerFactory
("ode-dao");
        EntityManager em = emf.createEntityManager(propMap);

Where are the properties set on JDBConfigurationImpl? So I can check what
gets wrong in my case.

Thanks,

Matthieu

On 1/3/07, Matthieu Riou <ma...@gmail.com> wrote:
>
> My ultimate goal is to provide directly an instance of DataSource that
> OpenJPA would use instead of trying to lookup or create one. It seems that
> it's possible by setting ConnectionFactory to the datasource instance but
> OpenJPA fails before that if no ConnectionDriverName is specified.
>
> Abe is right when saying that I should provide the properties to
> createEntityManager insteand of createEntityManagerFactory but I still can't
> find to way to initialize everything property.
>
> Thanks,
>
> Matthieu
>
> On 1/3/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
> >
> > Matthieu-
> >
> > Can you send the complete stack trace?
> >
> > Also, I don't think this is the cause of the problem, but why are you
> > specifying both ConnectionDriverName and ConnectionFactory? With
> > ConnectionFactory specified, you shouldn't need to specify the
> > ConnectionDriverName.
> >
> >
> >
> > On Jan 3, 2007, at 5:01 PM, Matthieu Riou wrote:
> >
> > > Sorry I've jumped too quickly to conclusions. The mistake was mine.
> > >
> > > However I'm trying to initialize OpenJPA programmatically using the
> > > following code:
> > >
> > >        HashMap propMap = new HashMap();
> > >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider
> > > (_txMgr));
> > >        propMap.put("openjpa.ConnectionDriverName ",
> > > org.apache.derby.jdbc.EmbeddedDriver.class.getName());
> > >        propMap.put("openjpa.ConnectionFactory", _datasource);
> > >        EntityManagerFactory emf =
> > > Persistence.createEntityManagerFactory ("ode-dao",
> > > propMap);
> > >        EntityManager em = emf.createEntityManager(propMap);
> > >
> > > The TxMgrProvider implements the ManagedRuntime interface.
> > >
> > > When execute, for each of the Map key I'm passing I'm getting:
> > >
> > > <4|false|0.9.6-incubating-SNAPSHOT>
> > > org.apache.openjpa.persistence.ArgumentException: Missing getter for
> > > property "ConnectionDriverName" in type "class
> > > org.apache.openjpa.persistence.EntityManagerImpl ".
> > >
> > > With the NoSuchMethodException that comes together. As I'm passing
> > > configuration properties I don't get why it tries to set of get
> > > them on the
> > > entity manager. I guess I'm doing something wrong, do you have an
> > > idea of
> > > what could that be?
> > >
> > > Thanks!
> > >
> > > Matthieu
> > >
> > > On 1/3/07, Abe White <aw...@bea.com> wrote:
> > >>
> > >> > I've been fighting for some time now with my OpenJPA configuration
> > >> > and just
> > >> > discovered why. It seems that you *either* consider the
> > >> > persistence.xml file
> > >> > *or* the map passed as parameter of
> > >> > Persistence.createEntityManagerFactory .
> > >> > If you look at PersistenceProductDerivation.load(String rsrc,
> > >> > String name,
> > >> > Map m) (line 151), if the configuration provider can find a
> > >> > configuration
> > >> > file then the configuration is returned as is and the provided
> > >> > configuration
> > >> > Map doesn't even gets considered.
> > >>
> > >> I don't see this.  The Map is passed along to the method that loads
> > >> the configuration file, which passes it along to the configuration
> > >> parser, which sets its entries over the properties it parses.
> > >> _____________________________________________________________________
> >
> > >> __
> > >> Notice:  This email message, together with any attachments, may
> > >> contain
> > >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
> > >> affiliated
> > >> entities,  that may be confidential,  proprietary,  copyrighted
> > >> and/or
> > >> legally privileged, and is intended solely for the use of the
> > >> individual
> > >> or entity named in this message. If you are not the intended
> > >> recipient,
> > >> and have received this message in error, please immediately return
> > >> this
> > >> by email and then delete it.
> > >>
> >
> >
>

Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
My ultimate goal is to provide directly an instance of DataSource that
OpenJPA would use instead of trying to lookup or create one. It seems that
it's possible by setting ConnectionFactory to the datasource instance but
OpenJPA fails before that if no ConnectionDriverName is specified.

Abe is right when saying that I should provide the properties to
createEntityManager insteand of createEntityManagerFactory but I still can't
find to way to initialize everything property.

Thanks,

Matthieu

On 1/3/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> Matthieu-
>
> Can you send the complete stack trace?
>
> Also, I don't think this is the cause of the problem, but why are you
> specifying both ConnectionDriverName and ConnectionFactory? With
> ConnectionFactory specified, you shouldn't need to specify the
> ConnectionDriverName.
>
>
>
> On Jan 3, 2007, at 5:01 PM, Matthieu Riou wrote:
>
> > Sorry I've jumped too quickly to conclusions. The mistake was mine.
> >
> > However I'm trying to initialize OpenJPA programmatically using the
> > following code:
> >
> >        HashMap propMap = new HashMap();
> >        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider
> > (_txMgr));
> >        propMap.put("openjpa.ConnectionDriverName",
> > org.apache.derby.jdbc.EmbeddedDriver.class.getName());
> >        propMap.put("openjpa.ConnectionFactory", _datasource);
> >        EntityManagerFactory emf =
> > Persistence.createEntityManagerFactory("ode-dao",
> > propMap);
> >        EntityManager em = emf.createEntityManager(propMap);
> >
> > The TxMgrProvider implements the ManagedRuntime interface.
> >
> > When execute, for each of the Map key I'm passing I'm getting:
> >
> > <4|false|0.9.6-incubating-SNAPSHOT>
> > org.apache.openjpa.persistence.ArgumentException: Missing getter for
> > property "ConnectionDriverName" in type "class
> > org.apache.openjpa.persistence.EntityManagerImpl".
> >
> > With the NoSuchMethodException that comes together. As I'm passing
> > configuration properties I don't get why it tries to set of get
> > them on the
> > entity manager. I guess I'm doing something wrong, do you have an
> > idea of
> > what could that be?
> >
> > Thanks!
> >
> > Matthieu
> >
> > On 1/3/07, Abe White <aw...@bea.com> wrote:
> >>
> >> > I've been fighting for some time now with my OpenJPA configuration
> >> > and just
> >> > discovered why. It seems that you *either* consider the
> >> > persistence.xml file
> >> > *or* the map passed as parameter of
> >> > Persistence.createEntityManagerFactory.
> >> > If you look at PersistenceProductDerivation.load(String rsrc,
> >> > String name,
> >> > Map m) (line 151), if the configuration provider can find a
> >> > configuration
> >> > file then the configuration is returned as is and the provided
> >> > configuration
> >> > Map doesn't even gets considered.
> >>
> >> I don't see this.  The Map is passed along to the method that loads
> >> the configuration file, which passes it along to the configuration
> >> parser, which sets its entries over the properties it parses.
> >> _____________________________________________________________________
> >> __
> >> Notice:  This email message, together with any attachments, may
> >> contain
> >> information  of  BEA Systems,  Inc.,  its subsidiaries  and
> >> affiliated
> >> entities,  that may be confidential,  proprietary,  copyrighted
> >> and/or
> >> legally privileged, and is intended solely for the use of the
> >> individual
> >> or entity named in this message. If you are not the intended
> >> recipient,
> >> and have received this message in error, please immediately return
> >> this
> >> by email and then delete it.
> >>
>
>

Re: Configuration: either / or ?

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

Can you send the complete stack trace?

Also, I don't think this is the cause of the problem, but why are you  
specifying both ConnectionDriverName and ConnectionFactory? With  
ConnectionFactory specified, you shouldn't need to specify the  
ConnectionDriverName.



On Jan 3, 2007, at 5:01 PM, Matthieu Riou wrote:

> Sorry I've jumped too quickly to conclusions. The mistake was mine.
>
> However I'm trying to initialize OpenJPA programmatically using the
> following code:
>
>        HashMap propMap = new HashMap();
>        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider 
> (_txMgr));
>        propMap.put("openjpa.ConnectionDriverName",
> org.apache.derby.jdbc.EmbeddedDriver.class.getName());
>        propMap.put("openjpa.ConnectionFactory", _datasource);
>        EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("ode-dao",
> propMap);
>        EntityManager em = emf.createEntityManager(propMap);
>
> The TxMgrProvider implements the ManagedRuntime interface.
>
> When execute, for each of the Map key I'm passing I'm getting:
>
> <4|false|0.9.6-incubating-SNAPSHOT>
> org.apache.openjpa.persistence.ArgumentException: Missing getter for
> property "ConnectionDriverName" in type "class
> org.apache.openjpa.persistence.EntityManagerImpl".
>
> With the NoSuchMethodException that comes together. As I'm passing
> configuration properties I don't get why it tries to set of get  
> them on the
> entity manager. I guess I'm doing something wrong, do you have an  
> idea of
> what could that be?
>
> Thanks!
>
> Matthieu
>
> On 1/3/07, Abe White <aw...@bea.com> wrote:
>>
>> > I've been fighting for some time now with my OpenJPA configuration
>> > and just
>> > discovered why. It seems that you *either* consider the
>> > persistence.xml file
>> > *or* the map passed as parameter of
>> > Persistence.createEntityManagerFactory.
>> > If you look at PersistenceProductDerivation.load(String rsrc,
>> > String name,
>> > Map m) (line 151), if the configuration provider can find a
>> > configuration
>> > file then the configuration is returned as is and the provided
>> > configuration
>> > Map doesn't even gets considered.
>>
>> I don't see this.  The Map is passed along to the method that loads
>> the configuration file, which passes it along to the configuration
>> parser, which sets its entries over the properties it parses.
>> _____________________________________________________________________ 
>> __
>> Notice:  This email message, together with any attachments, may  
>> contain
>> information  of  BEA Systems,  Inc.,  its subsidiaries  and   
>> affiliated
>> entities,  that may be confidential,  proprietary,  copyrighted   
>> and/or
>> legally privileged, and is intended solely for the use of the  
>> individual
>> or entity named in this message. If you are not the intended  
>> recipient,
>> and have received this message in error, please immediately return  
>> this
>> by email and then delete it.
>>


Re: Configuration: either / or ?

Posted by Matthieu Riou <ma...@gmail.com>.
Sorry I've jumped too quickly to conclusions. The mistake was mine.

However I'm trying to initialize OpenJPA programmatically using the
following code:

        HashMap propMap = new HashMap();
        propMap.put("openjpa.ManagedRuntime", new TxMgrProvider(_txMgr));
        propMap.put("openjpa.ConnectionDriverName",
org.apache.derby.jdbc.EmbeddedDriver.class.getName());
        propMap.put("openjpa.ConnectionFactory", _datasource);
        EntityManagerFactory emf =
Persistence.createEntityManagerFactory("ode-dao",
propMap);
        EntityManager em = emf.createEntityManager(propMap);

The TxMgrProvider implements the ManagedRuntime interface.

When execute, for each of the Map key I'm passing I'm getting:

<4|false|0.9.6-incubating-SNAPSHOT>
org.apache.openjpa.persistence.ArgumentException: Missing getter for
property "ConnectionDriverName" in type "class
org.apache.openjpa.persistence.EntityManagerImpl".

With the NoSuchMethodException that comes together. As I'm passing
configuration properties I don't get why it tries to set of get them on the
entity manager. I guess I'm doing something wrong, do you have an idea of
what could that be?

Thanks!

Matthieu

On 1/3/07, Abe White <aw...@bea.com> wrote:
>
> > I've been fighting for some time now with my OpenJPA configuration
> > and just
> > discovered why. It seems that you *either* consider the
> > persistence.xml file
> > *or* the map passed as parameter of
> > Persistence.createEntityManagerFactory.
> > If you look at PersistenceProductDerivation.load(String rsrc,
> > String name,
> > Map m) (line 151), if the configuration provider can find a
> > configuration
> > file then the configuration is returned as is and the provided
> > configuration
> > Map doesn't even gets considered.
>
> I don't see this.  The Map is passed along to the method that loads
> the configuration file, which passes it along to the configuration
> parser, which sets its entries over the properties it parses.
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>

Re: Configuration: either / or ?

Posted by Abe White <aw...@bea.com>.
> I've been fighting for some time now with my OpenJPA configuration  
> and just
> discovered why. It seems that you *either* consider the  
> persistence.xml file
> *or* the map passed as parameter of  
> Persistence.createEntityManagerFactory.
> If you look at PersistenceProductDerivation.load(String rsrc,  
> String name,
> Map m) (line 151), if the configuration provider can find a  
> configuration
> file then the configuration is returned as is and the provided  
> configuration
> Map doesn't even gets considered.

I don't see this.  The Map is passed along to the method that loads  
the configuration file, which passes it along to the configuration  
parser, which sets its entries over the properties it parses.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.