I have been trying to get a Vaadin JPA application running and ran into a very vague error message that I have been tracking down.
OpenJPA: ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
The full error stacktrace I was getting at start-up was:
Caused by: <openjpa-1.2.2-r422266:898935 fatal user error> 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:74) at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:784) at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:561) at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1344) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430) at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103) at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68) at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:863) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:854) at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) ... 15 more
I finally tracked down the issue
public class EntityManagerListener implements ServletContextListener { ... public void contextInitialized(ServletContextEvent context) { this.factory = Persistence.createEntityManagerFactory("com.baselogic.jpa"); } ... }
The persistence unit that was configured was called “jpa_persistence_unit”
The solution was to change the name of the persistence unit in my persistence.xml like the following (“com.baselogic.jpa”):
<persistence-unit name="com.baselogic.jpa" transaction-type="RESOURCE_LOCAL">
I could have just changed the persistence unit name in the createEntityManagerFactory(“com.baselogic.jpa”) call, but I chose to keep the standard name and change the persistence.xml.
Hope this can help someone else…
Recent Comments