Plugin development issue with new "plugin-classloader" jar in 6.2.0


(Simone Scarduzio) #1

Hi guys, is there a way to load lib/plugin-classloader-6.2.0.jar from maven?
For my day to day ES plugin development I have a regular Gradle project that depends on

compile 'org.elasticsearch:elasticsearch:' + esVersion
compile 'org.elasticsearch.plugin:transport-netty4-client:' + esVersion

Until 6.1.x I had no compilation issues, until (after pull request #27881). Which is responsible for creating a new jar in the ES zip distribution (lib/plugin-classloader-6.2.0.jar) which is NOT available as a maven dependency.

As a result, I keep on getting this RUNTIME fatal error:

java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ExtendedPluginsClassLoader

As a proof of concept, I manually added plugin-classloader-6.2.0.jar as a local dependency to my project and everything worked.

Any suggestions?

For reference: my plugin's gradle file for 6.2.0 is here

And my java options in the IntelliJ launcher are:

-Djava.security.policy=/me/elasticsearch-readonlyrest-plugin-5.x/integration-tests/src/test/eshome/plugins/readonlyrest/plugin-security.policy
-Djava.awt.headless=true
-Des.insecure.allow.root=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-Des.path.home=/me/elasticsearch-readonlyrest-plugin-5.x/integration-tests/src/test/eshome
-Dlog4j2.disable.jmx=true
-Xms1g
-Xmx1g
-Djdk.io.permissionsUseCanonicalPath=true
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j.skipJansi=true
-Des.path.conf=config
-Djava.security.manager

(Ryan Ernst) #2

Can you give an example how you are setting up and running tests? Do you use ESIntegTestCases? The plugin classloader was meant to be an implementation detail of the elasticsearch distributions. It theoretically shouldn't affect unit tests because the PluginsService loaded there has the classes already loaded, and when running ./gradlew integTest, we use the actual zip distribution of elasticsearch, which includes the plugin classloader.


(Simone Scarduzio) #3

Hi @rjernst! Thanks for answering,

I'm not running tests, I'm running the whole ES + my plugin code in my IDE so I can set breakpoints into my source code as well as ES source code (loaded in read-only via maven).

It's been very productive to work like this. Especially in conjunction with a local Kibana instance.

This is a guide I wrote for ES 2.0, the principles still apply to what I'm doing now: basically I have a fake ES_HOME in src/main/test/eshome to host the plugin metadata and the plugin code is loaded from the IDE classpath.

And by the way, I don't use the ESIntegTestCase*, I have testcontainers-java running things in a more standardised way. Do you think there's an advantage about buying in the ES testing framework?


(system) #4

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