Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Mar 2, 2017 · 4 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: superseded An issue that has been superseded by another

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 2, 2017

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:

@spring-projects-issues
Copy link
Collaborator Author

Piotr Tempes commented

I am not sure if this helps, but I noticed this error when I run integration tests of my modules following way:
mvn clean install -f ../project_dir/pom.xml
key thing is ".." in the path.

funny thing is that when I run exactly same command on a multimodule project and integration tests are in submodules everything works fine.
Also below commands work as expected as well:
mvn clean install
mvn clean install -f project_dir/pom.xml
run it form IDE

I am using Spring Boot 2.0.0.M7, no xmls, just auto configs and annotations
sorry if this is not the right place for this comment.

@endss
Copy link

endss commented Jun 21, 2019

Hi guys, I had same problem with Jenkis in my company.

Followng comment in top , removing "." from command maven in the Jenkis, fixed the problem.

L am using Spring Boot 2.1.3.

Thanks for sharing.

@yasarkunduz
Copy link

If you want to use mvn -f ./pom.xml, you should have a multi-module project (just add at least 1 module to your project), then it will work!

@snicoll
Copy link
Member

snicoll commented Sep 20, 2023

The check has been relaxed, see #29137, so it shouldn't fail hard anymore now.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
@snicoll snicoll added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

4 participants