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

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'motanMicrosoftEmailServiceImpl' defined in file [E:\2.0\microsoftEmail\target\classes\com\example\microsoftemail\rpc\MotanMicrosoftEmailServiceImpl.class]: Initialization of bean failed; nested exception is com.weibo.api.motan.exception.MotanFrameworkException: error_message: com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found, status: 503, error_code: 20001,r=null #1057

Open
lxyxjl opened this issue Feb 26, 2024 · 2 comments

Comments

@lxyxjl
Copy link

lxyxjl commented Feb 26, 2024

Hello, I encountered an issue. The details of the application.properties configuration are as follows:

Application service WEB access port

server.port=8090
spring.application.name=microsoftEmail

Motan protocol configuration

motan.protocol.name=motan
motan.protocol.default=motan
motan.registry.default=zookeeper
motan.service.interface=com.example.microsoftemail.rpc.motan.MotanMicrosoftEmailService
motan.service.ref=MotanMicrosoftEmailServiceImpl
motan.protocol.maxContentLength=1048576

Zookeeper registry center configuration

motan.registry.name=motanRegistry
motan.registry.address=zookeeper://127.0.0.1:2181

Service configuration

motan.service.export=motan:9988
motan.service.group=default_rpc_microsoftEmail
motan.service.accessLog=false
motan.service.shareChannel=true
motan.service.application=microsoftEmail
motan.service.registry=motanRegistry

The code details are as follows:

package com.example.microsoftemail.config;

import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@configuration
public class MotanConfig {

@Bean
public AnnotationBean motanAnnotationBean() {
    AnnotationBean motanAnnotationBean = new AnnotationBean();
    motanAnnotationBean.setPackage("com.example.microsoftemail.rpc");
    return motanAnnotationBean;
}

@Bean(name = "motan")
public ProtocolConfigBean protocolConfig() {
    ProtocolConfigBean config = new ProtocolConfigBean();
    config.setName("motan");
    config.setMaxWorkerThread(50);
    config.setMinWorkerThread(20);
    config.setFilter("statistic");
    config.setMaxContentLength(1048576);
    return config;
}

@Bean(name = "motanRegistry")
public RegistryConfigBean registryConfig() {
    RegistryConfigBean config = new RegistryConfigBean();
    config.setConnectTimeout(3000);
    config.setRequestTimeout(1000);
    config.setName("motanRegistry");
    config.setAddress("127.0.0.1:2181");
    config.setRegProtocol("zookeeper");
    return config;
}

@Bean
public BasicServiceConfigBean basicServiceConfig() {
    BasicServiceConfigBean config = new BasicServiceConfigBean();
    config.setExport("motan:9988");
    config.setGroup("default_rpc_microsoftEmail");
    config.setRegistry("motanRegistry");
    return config;
}

}

public interface MotanMicrosoftEmailService {
String hello(String name);
}

@MotanService
public class MotanMicrosoftEmailServiceImpl implements MotanMicrosoftEmailService {

@Override
public String hello(String name) {
    LoggerUtil.info("HelloServiceImpl is called, parameter: " + name);
    return "Hello " + name + "!";
}

}

@SpringBootApplication
@componentscan(basePackages = { "com.example" })
public class MicrosoftEmailApplication {

public static void main(String[] args) {
    SpringApplication.run(MicrosoftEmailApplication.class, args);
    MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
}

}
But the code starts with an error.
. ____ _ __ _ _
/\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |
| .__|| ||| |_, | / / / /
=========|
|==============|/=////
:: Spring Boot :: (v2.6.13)

18:30:05.554 [main] INFO c.e.m.MicrosoftEmailApplication - Starting MicrosoftEmailApplication using Java 1.8.0_231 on DESKTOP-9ORB13Q with PID 295672 (E:\2.0\microsoftEmail\target\classes started by echat in E:\2.0\microsoftEmail)
18:30:05.558 [main] INFO c.e.m.MicrosoftEmailApplication - No active profile set, falling back to 1 default profile: "default"
18:30:06.044 [main] INFO o.s.c.a.ConfigurationClassEnhancer - @bean method MotanConfig.motanAnnotationBean is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @resource and @PostConstruct within the method's declaring @configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @bean javadoc for complete details.
18:30:06.052 [main] INFO info - AllSpiInitialization init.
18:30:06.054 [main] INFO info - AllSpiInitialization init finish.
18:30:06.267 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8090 (http)
18:30:06.274 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8090"]
18:30:06.274 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
18:30:06.274 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.68]
18:30:06.367 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
18:30:06.367 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 744 ms
18:30:06.433 [main] INFO info - get local address by hostname, address:DESKTOP-9ORB13Q/192.168.0.104
18:30:06.435 [main] INFO info - export for service url :motan://192.168.0.104:9988/com.example.microsoftemail.rpc.motan.MotanMicrosoftEmailService?filter=statistic&minWorkerThread=20&protocol=motan&maxContentLength=1048576&maxWorkerThread=50&id=basicServiceConfig&nodeType=service&export=motan%3A9988&group=default_rpc_microsoftEmail&
18:30:06.452 [main] INFO info - ShutdownHook is initialized
18:30:06.453 [main] INFO info - add resource class com.weibo.api.motan.util.StatsUtil$2 to list
18:30:06.454 [main] INFO info - init compress codec
18:30:06.455 [main] INFO info - add method sign:hell358ab74d436e, methodinfo:MethodInfo [group=default_rpc_microsoftEmail, interfaceName=com.example.microsoftemail.rpc.motan.MotanMicrosoftEmailService, methodName=hello, paramtersDesc=java.lang.String, version=1.0]
18:30:06.455 [main] INFO info - RequestRouter addProvider: url=motan://192.168.0.104:9988/com.example.microsoftemail.rpc.motan.MotanMicrosoftEmailService?group=default_rpc_microsoftEmail all_public_method_count=1
18:30:06.459 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'motanMicrosoftEmailServiceImpl' defined in file [E:\2.0\microsoftEmail\target\classes\com\example\microsoftemail\rpc\MotanMicrosoftEmailServiceImpl.class]: Initialization of bean failed; nested exception is com.weibo.api.motan.exception.MotanFrameworkException: error_message: com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found, status: 503, error_code: 20001,r=null
18:30:06.461 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat]
18:30:06.469 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
18:30:06.499 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'motanMicrosoftEmailServiceImpl' defined in file [E:\2.0\microsoftEmail\target\classes\com\example\microsoftemail\rpc\MotanMicrosoftEmailServiceImpl.class]: Initialization of bean failed; nested exception is com.weibo.api.motan.exception.MotanFrameworkException: error_message: com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found, status: 503, error_code: 20001,r=null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at com.example.microsoftemail.MicrosoftEmailApplication.main(MicrosoftEmailApplication.java:14)
Caused by: com.weibo.api.motan.exception.MotanFrameworkException: error_message: com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found, status: 503, error_code: 20001,r=null
at com.weibo.api.motan.core.extension.ExtensionLoader.failThrows(ExtensionLoader.java:469)
at com.weibo.api.motan.core.extension.ExtensionLoader.getSingletonInstance(ExtensionLoader.java:132)
at com.weibo.api.motan.core.extension.ExtensionLoader.getExtension(ExtensionLoader.java:99)
at com.weibo.api.motan.core.extension.ExtensionLoader.getExtension(ExtensionLoader.java:82)
at com.weibo.api.motan.protocol.rpc.DefaultRpcExporter.(DefaultRpcExporter.java:54)
at com.weibo.api.motan.protocol.rpc.DefaultRpcProtocol.createExporter(DefaultRpcProtocol.java:41)
at com.weibo.api.motan.protocol.AbstractProtocol.export(AbstractProtocol.java:65)
at com.weibo.api.motan.protocol.support.ProtocolFilterDecorator.export(ProtocolFilterDecorator.java:58)
at com.weibo.api.motan.config.handler.SimpleConfigHandler.export(SimpleConfigHandler.java:76)
at com.weibo.api.motan.config.ServiceConfig.exportService(ServiceConfig.java:221)
at com.weibo.api.motan.config.ServiceConfig.doExport(ServiceConfig.java:184)
at com.weibo.api.motan.config.ServiceConfig.export(ServiceConfig.java:127)
at com.weibo.api.motan.config.springsupport.AnnotationBean.postProcessAfterInitialization(AnnotationBean.java:319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
... 15 common frames omitted

Please help me identify the issue. I have already tried changing the dependency versions, but the error still occurs.
@rayzhang0603
Copy link
Collaborator

com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found means the EndpointFactory SPI extension named "motan" was not found.
You can check whether the dependency of the "motan-transport-netty" or "motan-transport-netty4" module is introduced in the pom. These two modules can only depend on one of them.

@lxyxjl
Copy link
Author

lxyxjl commented Feb 27, 2024

com.weibo.api.motan.transport.EndpointFactory: get extension fail. extension name 'motan' not found means the EndpointFactory SPI extension named "motan" was not found. You can check whether the dependency of the "motan-transport-netty" or "motan-transport-netty4" module is introduced in the pom. These two modules can only depend on one of them.

I have already added the motan-transport-netty dependency. Then, I tried switching from motan-transport-netty to motan-transport-netty4, and the application successfully started. After that, when I switched back from motan-transport-netty4 to motan-transport-netty, it was also successful. Before switching, I checked whether my dependencies were loaded, and they were indeed loaded. However, I kept encountering the aforementioned issue yesterday.

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