IllegalStateException:无法自省类

问题描述

我正在尝试在我的SpringBoot应用程序上实现扩展功能,该应用程序应该使用@ComponentScan扫描类路径中存在的单独jar中的bean定义。

@ComponentScan如下图

@ComponentScan({"com.myapp.rest","com.mycompany.search.rest"})

在外部jar ESExt.jar中将存在“ com.mycompany.search.rest”软件包的地方

我在WebSphere Liberty Server的server.xml文件添加了以下配置,以包括用于进行类路径扫描的外部文件

<library id="extention" apiTypeVisibility="+third-party,-api">
  <fileset dir="${server.config.dir}/ext" includes="*.jar" scanInterval="5s" />
</library>

<webApplication id="Myapp" location="Myapp.war" type="war" name="Myapp" contextRoot="/resources">
    <classloader commonLibraryRef="extention" />
</webApplication>

当我在WebSphere Liberty Server中部署应用程序时,它抛出以下异常

[28/9/20 13:43:04:878 IST] 0000002a com.ibm.ws.logging.internal.impl.IncidentImpl                I FFDC1015I: An FFDC Incident has been created: "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storeResource': Lookup method resolution Failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.mycompany.search.rest.StoreResource] from ClassLoader [com.ibm.ws.classloading.internal.AppClassLoader@7a84a757] com.ibm.ws.webcontainer.osgi.DynamicVirtualHost startWebApp" at ffdc_20.09.28_13.43.04.0.log

以下是jar -tf ESExt.jar

输出
meta-inf/
meta-inf/MANIFEST.MF
com/
com/mycompany/
com/mycompany/search/
com/mycompany/search/rest/
com/mycompany/search/rest/StoreResource.class

此异常IllegalStateException: Failed to introspect Class意味着什么?我什至在互联网上都找不到任何东西。

解决方法

通过如下更改server.xml来解决它

<library id="extension">
    <fileset dir="${server.config.dir}/ext" includes="*.jar" scanInterval="5s" />
</library>
    
<webApplication id="Myapp" location="Myapp.war" type="war" name="Myapp" contextRoot="/resources">
    <classloader commonLibraryRef="extension" delegation="parentFirst"/>
</webApplication>