Liferay7.1GA4防病毒实现java.lang.ClassNotFoundException

Liferay7.1GA4防病毒实现java.lang.ClassNotFoundException,liferay,classloader,classnotfoundexception,antivirus,Liferay,Classloader,Classnotfoundexception,Antivirus,正如实现文件上传防病毒的文档中所述,我们开发了一个实现com.liferay.document.library.kernel.antivirus.AntivirusScanner的防病毒类,并在portal-ext.properties中添加了以下属性 dl.store.antivirus.enabled=true dl.store.antivirus.impl=it.antivirus.scanner.CustomAntivirusScanner 但当我们启动门户时,会出现以下错误: 202

正如实现文件上传防病毒的文档中所述,我们开发了一个实现com.liferay.document.library.kernel.antivirus.AntivirusScanner的防病毒类,并在portal-ext.properties中添加了以下属性

dl.store.antivirus.enabled=true
dl.store.antivirus.impl=it.antivirus.scanner.CustomAntivirusScanner
但当我们启动门户时,会出现以下错误:

2021-04-16 15:26:29.356 ERROR [Portal Spring Init Thread][InstancePool:114] Unable to load it.antivirus.scanner.CustomAntivirusScanner with the portal class loader or the current context class loader
java.lang.ClassNotFoundException: it.antivirus.scanner.CustomAntivirusScanner
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1138)
    at com.liferay.portal.kernel.util.InstancePool.get(InstancePool.java:68)
    at com.liferay.portal.kernel.util.InstancePool.get(InstancePool.java:33)
    at com.liferay.portlet.documentlibrary.antivirus.AntivirusScannerImpl.<init>(AntivirusScannerImpl.java:29)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1092)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1044)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
    at com.liferay.portal.spring.bean.LiferayBeanFactory.populateBean(LiferayBeanFactory.java:154)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at com.liferay.portal.spring.context.PortalContextLoaderListener.lambda$contextInitialized$0(PortalContextLoaderListener.java:278)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)
还是在bnd.bnd

Bundle-Name: CustomAntivirusScanner
Bundle-SymbolicName: it.antivirus.scanner
Bundle-Version: 1.0.0

非常感谢您的帮助。

快速浏览一下,InstancePool(或防病毒配置/加载程序)似乎不支持OSGi,需要类位于门户类加载程序中。。。但我可能错过了什么,只是很快检查了一下。如果您成功地编写了一个bundleactivator,将您的实现放在InstancePool中,您可能会很幸运。@OlafKock我们刚刚尝试制作一个bundle activator模块,将CustomAntivirus类的一个实例放入InstancePool中,但在初始检查后调用activator start函数,在INFO[main][ModuleFrameworkImpl:1326]启动初始捆绑包后,该错误立即出现。您对如何将该类放入门户类装入器有何建议,
Bundle-Name: CustomAntivirusScanner
Bundle-SymbolicName: it.antivirus.scanner
Bundle-Version: 1.0.0