Skip to content

"PersistenceException: Unable to resolve persistence unit root URL" when running jar #5833

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

Closed
dschulz opened this issue May 1, 2016 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@dschulz
Copy link

dschulz commented May 1, 2016

Simple barebones Gradle application runs without problems with gradle bootRun but fails when ran as jar. Here's a gist with the log.

 buildscript {
    ext {
        //springBootVersion = '1.4.0.BUILD-SNAPSHOT'
           springBootVersion = '1.4.0.M2'
    }
    repositories {
        mavenCentral()
       // jcenter()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'logistica'
    version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

 dependencies {
   compile('org.springframework.boot:spring-boot-starter-actuator')
   compile('org.springframework.boot:spring-boot-starter-data-jpa')
   compile('org.springframework.boot:spring-boot-devtools')
   compile('org.springframework.boot:spring-boot-starter-mail')
   compile('org.springframework.boot:spring-boot-starter-remote-shell')
   compile('org.springframework.boot:spring-boot-starter-security')
   compile('org.springframework.boot:spring-boot-starter-thymeleaf')
   compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
   compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
   compile('org.springframework.boot:spring-boot-starter-web')
   // compile('org.springframework.boot:spring-boot-starter-undertow')
   compile('org.hibernate:hibernate-java8')
   runtime('org.postgresql:postgresql')
   testCompile('org.springframework.boot:spring-boot-starter-test') 
}

bootRun {
     addResources = true
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.13'
}

This is how I build the jar:

./gradlew clean build
:clean
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 5.018 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.13/userguide/gradle_daemon.html

application.properties file:

spring.application.name="Logística"
spring.thymeleaf.cache=false
spring.datasource.url=jdbc:postgresql://localhost/dschulz
spring.datasource.username=dschulz
spring.datasource.password=yadayada
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

main application:

package com.dschulz;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class LogisticaApplication {

    public static void main(String[] args) {
        SpringApplication.run(LogisticaApplication.class, args);
    }
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 1, 2016
@dschulz
Copy link
Author

dschulz commented May 1, 2016

Forgot to mention that the app runs just fine (as fat jar) if I switch to 1.3.3.RELEASE.

@snicoll
Copy link
Member

snicoll commented May 2, 2016

@dschulz rather than pasting code here, can you please share a sample project that reproduces the issue? We have postgres instances around if we really have to use that we can. If you can reproduce the issue with H2 or something that would be obviously easier. Thanks.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 2, 2016
@dschulz
Copy link
Author

dschulz commented May 2, 2016

Someone reported the same bug with more details here: 5842.

@dschulz dschulz closed this as completed May 2, 2016
@philwebb philwebb added status: duplicate A duplicate of another issue and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants