Message Boards

[LF7.1GA4] Antivirus java.lang.ClassNotFoundException

Tinfo Tinfo, modified 3 Years ago.

[LF7.1GA4] Antivirus java.lang.ClassNotFoundException

New Member Posts: 14 Join Date: 5/14/20 Recent Posts

Hello,

as stated in the documentation https://docs.liferay.com/ce/portal/7.1-latest/propertiesdoc/portal.properties.html to implement an antivirus for file upload we developed an antivirus class that implements com.liferay.document.library.kernel.antivirus.AntivirusScanner and we added the following property in the portal-ext.properties

dl.store.antivirus.enabled=true
dl.store.antivirus.impl=it.antivirus.scanner.CustomAntivirusScanner

but when we start the portal we get the following error:

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)

maybe we are missing something in the @Component definition?

@Component(
	immediate = true,
	service = AntivirusScanner.class
)

or in the bnd.bnd?

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

Any help is appreciated, thanks.