Skip to content

"unable be resolved to persistence unit root url" in Spring Boot 2.0.4 #14279

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
jliuold opened this issue Sep 1, 2018 · 8 comments
Closed
Labels
for: external-project For an external project and not something we can fix

Comments

@jliuold
Copy link

jliuold commented Sep 1, 2018

My project pom is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.github.jliu666</groupId>
  <artifactId>develop-tools</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>develop-tools</name>
  <description>Demo project for Spring Boot</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>de.roskenet</groupId>
      <artifactId>springboot-javafx-support</artifactId>
      <version>2.1.6</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.datafx</groupId>
      <artifactId>flow</artifactId>
      <version>8.0.1</version>
    </dependency>
    <dependency>
      <groupId>io.datafx</groupId>
      <artifactId>datafx</artifactId>
      <version>8.0.1</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>Develop-Tools</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.zenjava</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>8.8.3</version>
        <configuration>
          <mainClass>org.github.jliu666.developtools.DevelopToolsApplication</mainClass>
          <appName>${project.build.finalName}-${project.version}</appName>
          <deployDir>${basedir}/src/deploy/</deployDir>
          <vendor>LIU JICHUN</vendor>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

I just use @SpringBootApplication annotation on my start class.

  1. I use maven jfx:native to package app on my mac os.
  2. I start the macos app by double click. An exception like below.
    image
  3. When I use java -jar Develop-Tools.jar to start the app in bash, It works.
  4. When I double click Develop-Tools.jar to start the jar file. An exception like below:
    image
@jliuold
Copy link
Author

jliuold commented Sep 1, 2018

Only when I start the jar file in bash, it works.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 1, 2018
@jliuold
Copy link
Author

jliuold commented Sep 1, 2018

I find #6983 #6983 #6537 issue like this. But that one was closed.

@wilkinsona
Copy link
Member

wilkinsona commented Sep 3, 2018

Can you please provide a minimal sample that reproduces the problem?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 3, 2018
@jliuold
Copy link
Author

jliuold commented Sep 3, 2018

Yes, I can.
The demo on https://github.com/jliu666/develop-tools is a sample. But I have removed the jpa dependencies. If you want to reproduce the problem. Maybe

  1. You need add jpa and h2 dependencies to the pom.
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
</dependency>
  1. Use mvn jfx:native to package a native app.
  2. Start the app by double click (in the target/jfx ) or start the fatjar (in the target) by double click.
  3. A window will show on your deskop. Then you can see the exception.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 3, 2018
@jliuold
Copy link
Author

jliuold commented Sep 3, 2018

Important! When started by java -jar develop-tools-0.0.1-SNAPSHOT.jar, it works correctly.

@wilkinsona
Copy link
Member

Thanks for the sample.

The built JavaFX app doesn't use Boot's launcher (the jar isn't fat) which is why it behaves differently. When there are only jars on the classpath, the JVM's app class loader is unable to resolve the root of the classpath. On the other hand, our launcher and its custom jar handling will return BOOT-INF/classes as the root of the classpath which allows the default persistence unit root to be resolved.

When resolving multiple resources, Spring Framework contains some logic to cope with the app class loader being unable to resolve the root of the classpath when there are only jars (no directories) on the class path. However, this logic is not used when resolving a single resource and I wonder if it should be. What do you think, @jhoeller?

@philwebb philwebb changed the title "unable be resolved to persistence unit root url" in Spirng Boot 2.0.4 "unable be resolved to persistence unit root url" in Spring Boot 2.0.4 Sep 4, 2018
@jhoeller
Copy link

jhoeller commented Sep 7, 2018

For the default persistence unit case, we have no persistence.xml file to derive a root URL from which is why we're relying on the default root URL (which is the classpath root by default but can be configured through the defaultPersistenceUnitRootLocation property).

The key question is: Which root URL should we expose to the persistence provider instead? The first of the packages to scan? The first mapping file in the list (if any)? Note that we're already deriving the root URL from a META-INF/orm.xml file if present (even if empty), so that might also be a workaround for the time being.

@wilkinsona
Copy link
Member

Thank you, @jhoeller. Perhaps the URL of the first resource that would be returned when resolving multiple resources could be used?

@jliu666 It looks like Framework, if anywhere, is going to be the right place to make a change for this. So that it's not forgotten, can you please open a JIRA providing as much information as possible and referencing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

4 participants