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

<Error: No auto configuration classes found in META-INF/spring.factories> #94

Closed
sangjiexun opened this issue Jun 10, 2022 · 6 comments
Closed

Comments

@sangjiexun
Copy link

sangjiexun commented Jun 10, 2022

Hello dear developer
There's a question here, it's about startup.
(1) Works fine when I start in the IDE.

bug-02

*(2) When I start via JAR, it reports an error like below.
bug-01
Please let me know how to solve this problem.
By the way ,I am using JDK17, SpringBoot 2.7

Thanks!

@tanyaofei
Copy link

I have the same problem. I am using JDK11 and SpringBoot 2.7

@tanyaofei
Copy link

tanyaofei commented Oct 15, 2022

I found out that the exception cause by CompletableFuture.supplyAsync(() -> SpringApplication.run(this.getClass(), savedArgs) )... at AbstractJavaFxApplicationSupport#init()

after I give a specify Executor, problem solved

  /*
   * (non-Javadoc)
   *
   * @see javafx.application.Application#init()
   */
  @Override
  public void init() throws Exception {
    // Load in JavaFx Thread and reused by Completable Future, but should not be a big deal.
    CompletableFuture.supplyAsync(() ->
        SpringApplication.run(this.getClass(), savedArgs), Executors.newFixedThreadPool(2)
    ).whenComplete((ctx, throwable) -> {
      if (throwable != null) {
        LOGGER.error("Failed to load spring application context: ", throwable);
        Platform.runLater(() -> showErrorAlert(throwable));
      } else {
        Platform.runLater(() -> {
          loadIcons(ctx);
          launchApplicationView(ctx);
        });
      }
    }).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
      Platform.runLater(closeSplash);
    });
  }

You can copy the AbstractJavaFxApplicationSupport.java file to src/main/java/de.felixroske.jfxsupport and rewrite the method, it will solved your problem;

@sangjiexun

@tanyaofei
Copy link

#96 This branch is about to fix this problem.

@darhao
Copy link

darhao commented Nov 26, 2022

I encountered a similar problem. I modified the source code, changed the thread context class loader to SpringBoot's class loader, and then solved the problem

    @Override
    public void init() throws Exception {
        // Load in JavaFx Thread and reused by Completable Future, but should no be a big deal.
        defaultIcons.addAll(loadDefaultIcons());
        CompletableFuture.supplyAsync(() -> {
                    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); //fix
                    return SpringApplication.run(this.getClass(), savedArgs);
                }
        ).whenComplete((ctx, throwable) -> {
            if (throwable != null) {
                LOGGER.error("Failed to load spring application context: ", throwable);
                Platform.runLater(() -> showErrorAlert(throwable));
            } else {
                Platform.runLater(() -> {
                    loadIcons(ctx);
                    launchApplicationView(ctx);
                });
            }
        }).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
            Platform.runLater(closeSplash);
        });
    }

@banmao999
Copy link

I encountered a similar problem. I modified the source code, changed the thread context class loader to SpringBoot's class loader, and then solved the problem

    @Override
    public void init() throws Exception {
        // Load in JavaFx Thread and reused by Completable Future, but should no be a big deal.
        defaultIcons.addAll(loadDefaultIcons());
        CompletableFuture.supplyAsync(() -> {
                    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); //fix
                    return SpringApplication.run(this.getClass(), savedArgs);
                }
        ).whenComplete((ctx, throwable) -> {
            if (throwable != null) {
                LOGGER.error("Failed to load spring application context: ", throwable);
                Platform.runLater(() -> showErrorAlert(throwable));
            } else {
                Platform.runLater(() -> {
                    loadIcons(ctx);
                    launchApplicationView(ctx);
                });
            }
        }).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
            Platform.runLater(closeSplash);
        });
    }

It works!! Thank u so much!!!!
I use the springboot-javafx-support code in SpringBoot3 with JavaFX17, and it work in IDEA, but fail to run in Jar
and finally works after use your modified code
it has took me two days to fingure out...tired

@sangjiexun
Copy link
Author

sangjiexun commented Jan 2, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants