> -----Original Message----- > From: Stanislav Paskalev [mailto:[email protected]] > Sent: Saturday, July 17, 2010 8:19 AM > To: [email protected] > Subject: Using OpenJPA 2.0.0 with a JNDI-bound DataSource ? > > Hi, I've been trying to use OpenJPA like this: > > Properties props = new Properties(); > > props.put("openjpa.RuntimeUnenhancedClasses","supported"); > props.put("openjpa.Id","DERBY-JPA"); > props.put("openjpa.ConnectionFactory", ds); > props.put("openjpa.MetaDataFactory", > "jpa(ClasspathScan=bin;vzk.jar)"); > props.put("openjpa.jdbc.SynchronizeMappings", > "buildSchema(ForeignKeys=true,SchemaAction=add)"); > > entityManagerFactory = > Persistence.createEntityManagerFactory("openjpa", props); > > Where "ds" is a tomcat provided instance of a Derby datasource and > it's not null. This fails with "<openjpa-2.0.0-r422266:935683 fatal > general error> org.apache.openjpa.persistence.PersistenceException: > Cannot create JDBC driver of class '' for connect URL 'null'" > > When I replace the openjpa.ConnectionFactory with this: > props.put("openjpa.ConnectionFactoryName", "jdbc/DERBYDS"); > > I'm getting "<openjpa-2.0.0-r422266:935683 fatal user error> > org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or > DataSource class name must be specified in the ConnectionDriverName > property." > > > I DO NOT want to explicitly use the jdbc driver and url (it works > this way atleast :)). Any hints what am I missing here will be greatly > appreciated! :)
In my "persistence-unit", I have a "jta-data-source" element whose value is the JNDI for my datasource. I don't specify anything in my "openjpa" properties that is database-type specific. I use the same persistence.xml for either Oracle or Derby (unit tests).
