Skip to content

Unable to resolve persistence unit root URL with LocalContainerEntityManagerFactoryBean [SPR-15304] #19869

Closed as not planned
@spring-projects-issues

Description

@spring-projects-issues

Mark Anderson opened SPR-15304 and commented

When using LocalContainerEntityManagerFactoryBean without any JPA xml configurations the following error is seen
Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
My bean is defined as follows

<bean id="configEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="configDataSource"/>
    <property name="persistenceUnitName" value="configPersistenceUnit" />
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
    </property>
    <property name="mappingResources">
      <array value-type="java.lang.String">
        <value>mappings/mapping1.hbm.xml</value>
        <value>mappings/mapping2.hbm.xml</value>
      </array>
    </property>
    <property name="jpaProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
        hibernate.show_sql=false
        hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
        hibernate.cache.use_second_level_cache=true
        net.sf.ehcache.configurationResourceName=file:${conf.dir}/ehcache.xml
      </value>
    </property>
  </bean>

This issue seems to be a further variant of #13474, #15859 and #18819.

The error only occurs when my application is deployed with all code and resources in jar files. I can run without error when the classes and resources are within directories on the classpath.

As a workaround I can add the following and my application will start.

<property name="persistenceUnitRootLocation" value="file:${java.io.tmpdir}" />

Affects: 4.3.6

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions