elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.77k stars 24.69k forks source link

Plugin isolated = false, fails to load elasticsearch lib/jars #17969

Closed ropal closed 8 years ago

ropal commented 8 years ago

Elasticsearch version: ES 2.0.2

JVM version: 1.8

OS version: Windows 8

Description of the problem including expected versus actual behavior:

Around 25 libraries are being shared by elasticsearch and my plugin, therefore those jars are already present in the elasticsearch lib folder. The remaining jars have been placed in my plugin folder. I have set isolated=false. Yet, at runtime classloader doesn't load the elasticsearch lib jars.

Steps to reproduce: 1. 2. 3.

Provide logs (if relevant):

Describe the feature:

clintongormley commented 8 years ago

isolated=false is only for plugins, elasticsearch has a separate classloader. also, isolated=false has been removed in master so I wouldn't rely on it

chindhuhari commented 8 years ago

Hello clintongormley, Even I'm stuck with a similar issue. In that case, if I put all the required jars( i.e. the jars that are shared with elasticsearch as well) in my plugin folder, won't jar hell exception be thrown? How's this kind of a scenario addressed? As of now, I'm getting it to work by placing all the jars in elasticsearch lib/ , but that is something that we do not want to do.

Thanks!

dadoonet commented 8 years ago

When you write a plugin you need to make sure that no single class conflicts with the ones elasticsearch uses.

You "just" have to add in your plugin missing classes (missing jars).

Don't add anything to elasticsearch lib dir.

chindhuhari commented 8 years ago

Hi dadoonet, I tried that as well, that's when I found this strange issue of ClassDefNotFound Java Exception, though I have the right version of that class present in the plugin folder. It was able to see all the classes in the elasticsearch lib/ folder. Then, I tried printing all the classes that's getting loaded by the classloader, in that this class(for which the exception was thrown) was listed, yet I got that error, I found that strange. So, I thought I am missing something.

Thanks!

dadoonet commented 8 years ago

May be you can provide more info about the class? Traces might help as well.

chindhuhari commented 8 years ago

The following is the jar(in the sysout result) which contains the class for which NoClassDefFoundError was thrown, as seen it's there in the plugins folder in elasticsearch :

class name java.net.FactoryURLClassLoader Classpath : /C:/ES_BINARY/elasticsearch-2.0.2/plugins/crawl-plugin/apache-nutch-1.10.jar

The following is the exception that was thrown at runtime :

   java.lang.NoClassDefFoundError: Could not initialize class org.apache.nutch.crawl.Injector
   at <package>.Crawler.inject(Crawler.java:186)
   at <package>.CrawlRestAction.crawl(CrawlRestAction.java:120)
   at <package>.CrawlRestAction.handleRequest(CrawlRestAction.java:76)
   at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:54)
   at org.elasticsearch.rest.RestController.executeHandler(RestController.java:207)
   at org.elasticsearch.rest.RestController$RestHandlerFilter.process(RestController.java:281)
   at org.elasticsearch.rest.RestController$ControllerFilterChain.continueProcessing(RestController.java:262)
   at org.elasticsearch.rest.RestController$ControllerFilterChain.continueProcessing(RestController.java:265)
   at org.elasticsearch.rest.RestController$ControllerFilterChain.continueProcessing(RestController.java
rjernst commented 8 years ago

@chindhuhari Can you please provide some more info: