Announcement Announcement Module
Collapse
No announcement yet.
No persistence providers available for "null"... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No persistence providers available for "null"...

    I'm attempting to start a new project, with a brand new, hand-cranked Spring configuration.

    This is something I haven't worked through in some time, and unsurprisingly, I've hit some errors. The current error I'm experiencing occurs during my builds, when Maven runs my unit tests.

    The actual error content is "No persistence providers available for "null" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider"

    My context XML file is:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:p="http://www.springframework.org/schema/p"
           xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <!-- Entity Manager Factory -->
        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" />
    
        <!-- Bean Configuration -->
        <bean id="resourceDao" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="proxyInterfaces">
                <value>xx.xx.xx.ResourceDao</value>
            </property>
            <property name="target">
                <ref local="resourceDaoImpl"/>
            </property>
        </bean>
    
        <!-- Bean Classes -->
        <bean id="resourceDaoImpl" class="xx.xx.xx.ResourceDaoImpl"/>
    
        <!-- Exception Translation -->
        <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
    
        <!-- Persistence -->
        <bean class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
    
        <!-- Transactions -->
        <tx:annotation-driven />
    </beans>
    My bean code is:
    Code:
    import java.util.List;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import org.springframework.dao.DataAccessException;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public class ResourceDaoImpl implements ResourceDao {
    
        private EntityManager entityManager;
    
        @PersistenceContext
        public void setEntityManager(EntityManager entityManager) {
            this.entityManager = entityManager;
        }
    }
    My persistence.xml is:
    Code:
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="mypu" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/mydb</jta-data-source>
        <non-jta-data-source>jdbc/mydb</non-jta-data-source>
        <class>xx.xx.xx.Resource</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
          
        </properties>
      </persistence-unit>
    </persistence>
    And finally, the stack trace is:
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in file [xxx\target\classes\applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [xxx\target\classes\applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No persistence providers available for "null" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            ...
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
            at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [xxx\target\classes\applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No persistence providers available for "null" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            ...
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
            at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:270)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:122)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:78)
            at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
            at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:97)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1326)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
            ... 43 more
    Caused by: javax.persistence.PersistenceException: No persistence providers available for "null" after trying the following discovered implementations: org.eclipse.persistence.jpa.PersistenceProvider
            at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:180)
            at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:91)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
            ... 60 more
    My data connection is using JNDI on my Java EE application server.

    Any help is much appreciated.

    Thanks.

    G.
    Last edited by genericprodigy; Feb 3rd, 2010, 09:01 AM. Reason: desensitizing
Working...
X