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

Cannot load provider in a servlet setup with spring #9

Open
knuclechan opened this issue Nov 30, 2021 · 6 comments
Open

Cannot load provider in a servlet setup with spring #9

knuclechan opened this issue Nov 30, 2021 · 6 comments

Comments

@knuclechan
Copy link

knuclechan commented Nov 30, 2021

Experience an error No provider of PromiseProvider found! when running servlet application with spring.

I guess it may be related to the class loader hierarchy or class loading sequence.

Currently I hack around this by adding a listener to the servlet

	<listener>
		<listener-class>ServletStartupListener</listener-class>
	</listener>
public class ServletStartupListener implements ServletContextListener {
	
	public void contextInitialized(ServletContextEvent sce) {
		log.info("Init JAsync");
		JAsync.just();
	}
	
}

I think one approach to solve this issue is to lazy load the provider instead of loading it in the static phase at JAsync.class

@vipcxj
Copy link
Owner

vipcxj commented Nov 30, 2021

Can you show me the full exception stack? Providing a minimal recurrence use case is certainly more welcome.

@knuclechan
Copy link
Author

Here is the stack trace.

11-30 15:00:05 WARN  - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountServiceImpl' defined in file [AccountServiceImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No provider of PromiseProvider found!
11-30 15:00:05 ERROR - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountServiceImpl' defined in file [AccountServiceImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No provider of PromiseProvider found!
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.13.jar:5.3.13]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.13.jar:5.3.13]
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401) ~[spring-web-5.3.13.jar:5.3.13]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292) ~[spring-web-5.3.13.jar:5.3.13]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) ~[spring-web-5.3.13.jar:5.3.13]
	at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1043) ~[?:?]
	at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:624) ~[?:?]
	at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:978) ~[?:?]
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:705) ~[?:?]
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392) ~[?:?]
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1304) ~[?:?]
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:895) ~[?:?]
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306) ~[?:?]
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:532) ~[?:?]
	at org.eclipse.jetty.maven.plugin.MavenWebAppContext.doStart(MavenWebAppContext.java:294) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40) ~[?:?]
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183) ~[?:?]
	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:516) ~[?:?]
	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:151) ~[?:?]
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:186) ~[?:?]
	at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:462) ~[?:?]
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:58) ~[?:?]
	at org.eclipse.jetty.util.Scanner$DiscreteListener.pathAdded(Scanner.java:282) ~[?:?]
	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:836) ~[?:?]
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:802) ~[?:?]
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:709) ~[?:?]
	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:597) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) ~[?:?]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121) ~[?:?]
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:158) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:605) ~[?:?]
	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:246) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) ~[?:?]
	at org.eclipse.jetty.server.Server.start(Server.java:469) ~[?:?]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121) ~[?:?]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:89) ~[?:?]
	at org.eclipse.jetty.server.Server.doStart(Server.java:414) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
	at org.eclipse.jetty.xml.XmlConfiguration.lambda$main$4(XmlConfiguration.java:1867) ~[?:?]
	at java.security.AccessController.doPrivileged(AccessController.java:569) [?:?]
	at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1810) [jetty-xml-10.0.7.jar:10.0.7]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.eclipse.jetty.start.Main.invokeMain(Main.java:227) [start.jar:10.0.7]
	at org.eclipse.jetty.start.Main.start(Main.java:512) [start.jar:10.0.7]
	at org.eclipse.jetty.start.Main.main(Main.java:74) [start.jar:10.0.7]
Caused by: java.lang.IllegalStateException: No provider of PromiseProvider found!
	at io.github.vipcxj.jasync.spec.JAsync.assertProvider(JAsync.java:15) ~[jasync-spec-0.1.9.jar:?]
	at io.github.vipcxj.jasync.spec.JAsync.just(JAsync.java:21) ~[jasync-spec-0.1.9.jar:?]
	at util.AsyncUtils.toPromise(AsyncUtils.java:33) ~[classes/:?]
	at service.account.AccountServiceImpl.init$$tmp$$3(AccountServiceImpl.java:56) ~[classes/:?]
	at io.github.vipcxj.jasync.spec.Utils.safeApply(Utils.java:22) ~[jasync-spec-0.1.9.jar:?]
	at io.github.vipcxj.jasync.reactive.ReactorPromise.lambda$then$0(ReactorPromise.java:48) ~[jasync-reactive-0.1.9.jar:?]
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.MonoUsingWhen$MonoUsingWhenSubscriber.deferredComplete(MonoUsingWhen.java:278) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.FluxUsingWhen$CommitInner.onComplete(FluxUsingWhen.java:540) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:209) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:209) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.pool.SimpleDequePool.lambda$maybeRecycleAndDrain$19(SimpleDequePool.java:512) ~[reactor-pool-0.2.5.jar:0.2.5]
	at reactor.core.publisher.LambdaMonoSubscriber.onComplete(LambdaMonoSubscriber.java:135) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onComplete(FluxDoFinally.java:145) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onComplete(MonoIgnoreElements.java:89) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1817) ~[reactor-core-3.4.12.jar:3.4.12]
	at reactor.core.publisher.MonoCompletionStage.lambda$subscribe$0(MonoCompletionStage.java:83) ~[reactor-core-3.4.12.jar:3.4.12]
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?]
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?]
	at com.github.jasync.sql.db.mysql.MySQLConnection$close$$inlined$onCompleteAsync$1$lambda$2.accept(FutureUtils.kt:107) ~[jasync-mysql-2.0.2.jar:?]
	at com.github.jasync.sql.db.mysql.MySQLConnection$close$$inlined$onCompleteAsync$1$lambda$2.accept(FutureUtils.kt) ~[jasync-mysql-2.0.2.jar:?]
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?]
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483) ~[?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
	at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[reactor-core-3.4.12.jar:3.4.12]
		at reactor.core.publisher.Mono.block(Mono.java:1707) ~[reactor-core-3.4.12.jar:3.4.12]
		at io.github.vipcxj.jasync.reactive.ReactorPromise.block(ReactorPromise.java:462) ~[jasync-reactive-0.1.9.jar:?]
		at service.account.AccountServiceImpl.afterPropertiesSet(AccountServiceImpl.java:47) ~[classes/:?]
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.13.jar:5.3.13]
		at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.13.jar:5.3.13]
		at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.13.jar:5.3.13]
		at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401) ~[spring-web-5.3.13.jar:5.3.13]
		at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292) ~[spring-web-5.3.13.jar:5.3.13]
		at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) ~[spring-web-5.3.13.jar:5.3.13]
		at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1043) ~[?:?]
		at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:624) ~[?:?]
		at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:978) ~[?:?]
		at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:705) ~[?:?]
		at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392) ~[?:?]
		at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1304) ~[?:?]
		at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:895) ~[?:?]
		at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306) ~[?:?]
		at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:532) ~[?:?]
		at org.eclipse.jetty.maven.plugin.MavenWebAppContext.doStart(MavenWebAppContext.java:294) ~[?:?]
		at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
		at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40) ~[?:?]
		at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183) ~[?:?]
		at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:516) ~[?:?]
		at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:151) ~[?:?]
		at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:186) ~[?:?]
		at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:462) ~[?:?]
		at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:58) ~[?:?]
		at org.eclipse.jetty.util.Scanner$DiscreteListener.pathAdded(Scanner.java:282) ~[?:?]
		at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:836) ~[?:?]
		at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:802) ~[?:?]
		at org.eclipse.jetty.util.Scanner.scan(Scanner.java:709) ~[?:?]
		at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:597) ~[?:?]
		at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
		at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) ~[?:?]
		at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121) ~[?:?]
		at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:158) ~[?:?]
		at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
		at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:605) ~[?:?]
		at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:246) ~[?:?]
		at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
		at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) ~[?:?]
		at org.eclipse.jetty.server.Server.start(Server.java:469) ~[?:?]
		at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121) ~[?:?]
		at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:89) ~[?:?]
		at org.eclipse.jetty.server.Server.doStart(Server.java:414) ~[?:?]
		at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[?:?]
		at org.eclipse.jetty.xml.XmlConfiguration.lambda$main$4(XmlConfiguration.java:1867) ~[?:?]
		at java.security.AccessController.doPrivileged(AccessController.java:569) [?:?]
		at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1810) [jetty-xml-10.0.7.jar:10.0.7]
		at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
		at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
		at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
		at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
		at org.eclipse.jetty.start.Main.invokeMain(Main.java:227) [start.jar:10.0.7]
		at org.eclipse.jetty.start.Main.start(Main.java:512) [start.jar:10.0.7]
		at org.eclipse.jetty.start.Main.main(Main.java:74) [start.jar:10.0.7]

@knuclechan
Copy link
Author

knuclechan commented Nov 30, 2021

I haven't tested this. But should be able to repeat the issue.

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
	version="4.0"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
	metadata-complete="true"
>

	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
	</context-param>
    	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>config.SpringConfig</param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
</web-app>

config.SpringConfg.java

package config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages="service")
public class SpringConfig {
	
}

service.account.AccountServiceImpl.java

package service.account;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements InitializingBean {
	
	public void afterPropertiesSet() throws Exception {
		JAsync.just();
	}
}

@vipcxj
Copy link
Owner

vipcxj commented Nov 30, 2021

Can you give me a scaffold project? Just push to you github repositories.

@knuclechan
Copy link
Author

Sorry, it will be too time consuming for me to make a scaffold project.

By the way, I think the cause maybe because I start the server using maven (without fork), where maven somehow didn't load the provider

@vipcxj
Copy link
Owner

vipcxj commented Dec 6, 2021

The provider is only loaded in the runtime. At compile time, nothing runtime thing is touched.

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

2 participants