Closed bykgh closed 2 years ago
确认一下providerTraceFilter 所在的类二进制文件是否有被打进去
确认一下providerTraceFilter 所在的类二进制文件是否有被打进去
打进去了, 这个providerTraceFilter,和 META-INF/dubbo/internal/org.apache.dubbo.rpc.filter 文件我是打在一个jar包中,给另外一个spring boot 的jar项目引用的。
这是providerTraceFilter:
`@Activate(group = {CONSUMER, PROVIDER}, value = VALIDATION_KEY, order = 10000) public class ProviderTraceFilter extends ValidationFilter { private Logger logger = LoggerFactory.getLogger(this.getClass());
// 调用过程拦截
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
try {
//获取session信息
initSession(invocation);
return invoker.invoke(invocation);
}catch (RpcException e) {
throw e;
}finally {
}
}
private void initSession(Invocation invocation) {
String sessionId = invocation.getAttachment("sessionId");
String qrCode = invocation.getAttachment("qrCode");
String openId = invocation.getAttachment("openId");
if (null != sessionId) {
MDC.put("sessionId",sessionId);
}
if (null != qrCode){
MDC.put("qrCode", qrCode);
}
if (null != openId){
MDC.put("openId", openId);
}
}
}`
pom.xml
`
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.filter</include>
</includes>
</resource>
</resources>
</build>`
jar包启动报错问题原因找到了:META-INF/dubbo/internal/org.apache.dubbo.rpc.filter,最后 Filter应该大写,应该是org.apache.dubbo.rpc.Filter,但是直接用IDEA开发工具能正常启动原因还不知道……
2021-11-12 22:34:12.069[ERROR][main][[33m[0;39m,[32m[0;39m,[34m[0;39m ][][][] o.s.boot.SpringApplication.reportFailure:826 - Application run failed java.lang.IllegalStateException: No such extension org.apache.dubbo.rpc.Filter by name providerTraceFilter, no related exception was found, please check whether related SPI module is missing. at org.apache.dubbo.common.extension.ExtensionLoader.findException(ExtensionLoader.java:647) at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:654) at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:443) at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:427) at org.apache.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:318) at org.apache.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:259) at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.buildInvokerChain(ProtocolFilterWrapper.java:53) at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:75) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:66) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.config.ServiceConfig.exportLocal(ServiceConfig.java:580) at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:512) at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:371) at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:346) at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:240) at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportService(DubboBootstrap.java:1089) at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$14(DubboBootstrap.java:1076) at java.util.HashMap$Values.forEach(HashMap.java:983) at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1060) at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:885) at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:70) at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:63) at com.alibaba.spring.context.OnceApplicationContextEventListener.onApplicationEvent(OnceApplicationContextEventListener.java:52) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at com.shangjietech.ServerServiceCodeCheck.main(ServerServiceCodeCheck.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) 2021-11-12 22:34:12.071[WARN ][Thread-3][[33m[0;39m,[32m[0;39m,[34m[0;39m ][][][] c.a.n.c.http.HttpClientBeanHolder.shutdown:108 - [HttpClientBeanHolder] Start destroying common HttpClient 2021-11-12 22:34:12.071[WARN ][Thread-16][[33m[0;39m,[32m[0;39m,[34m[0;39m ][][][] c.a.nacos.common.notify.NotifyCenter.shutdown:145 - [NotifyCenter] Start destroying Publisher 2021-11-12 22:34:12.071[WARN ][Thread-16][[33m[0;39m,[32m[0;39m,[34m[0;39m ][][][] c.a.nacos.common.notify.NotifyCenter.shutdown:162 - [NotifyCenter] Destruction of the end 2021-11-12 22:34:12.072[WARN ][Thread-3][[33m[0;39m,[32m[0;39m,[34m[0;39m ][][][] c.a.n.c.http.HttpClientBeanHolder.shutdown:114 - [HttpClientBeanHolder] Destruction of the end
打成的jar包我检查过, META-INF/dubbo/internal/org.apache.dubbo.rpc.filter 文件是存在的。