How to write es plugin with spring framework


(易天明) #1

I'm writing a analyze plugin, it reads keywords from database, and synchronize new words every several minutes.
I use spring framework as a dependency.
My test program runs fine. But when I install my plugin into elasticsearch, it runs into error:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.jiurong.search.plugin.AppConfig]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/context/annotation/AutoProxyRegistrar.class] cannot be opened because it does not exist at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:548) ~[?:?_]
It seems when spring use some of it's classloader to load class, the class is not on the classpath. Is there some way I can use spring framework in a es plugin?


(易天明) #2

Spring framework use classloader to load classes and some resources. Override it's default classloader to plugin classloader, and run it's code inside AccessController.doPrivilige method, it will work.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.