java.lang.NoClassDefFoundError: org/objectweb/asm/commons/Method while starting ElasticSearch

Hi,

I am using Elasticsearch 6.5.4. I am using network location to store the ES setup and run elasticsearch.bat directly from there.
I have written a Java program to start ES and put a pipeline definition (via REST). it retries starting ES if first ES start gets failed.
When I start ES, sometimes, I get the following error. My program then retries to start it again. Second time, it works correctly.

[2019-03-06T13:34:19,784][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] fatal error in thread [elasticsearch[PC-***][management][T#1]], exiting
java.lang.NoClassDefFoundError: org/objectweb/asm/commons/Method
at org.elasticsearch.painless.ScriptClassInfo.(ScriptClassInfo.java:79) ~[?:?]
at org.elasticsearch.painless.Compiler.compile(Compiler.java:222) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine$5.run(PainlessScriptEngine.java:423) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine$5.run(PainlessScriptEngine.java:419) ~[?:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_181]
at org.elasticsearch.painless.PainlessScriptEngine.compile(PainlessScriptEngine.java:419) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine.compile(PainlessScriptEngine.java:170) ~[?:?]
at org.elasticsearch.script.ScriptService.compile(ScriptService.java:334) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.common.ScriptProcessor$Factory.create(ScriptProcessor.java:148) ~[?:?]
at org.elasticsearch.ingest.common.ScriptProcessor$Factory.create(ScriptProcessor.java:90) ~[?:?]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessor(ConfigurationUtils.java:402) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessor(ConfigurationUtils.java:372) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessorConfigs(ConfigurationUtils.java:316) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.Pipeline.create(Pipeline.java:73) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.IngestService.validatePipeline(IngestService.java:361) ~[elasticsearch-6.5.4.jar:6.5.4]

Please help.

Any update here please.
Please note that NoClassDefFound error occurs randomly for different-2 classes. Also, it is coming when I run ES from my local machine (not only network location).

That's not a standard way to run elasticsearch I'm afraid.
May be share exactly (code) what you are doing...

Why are you doing that BTW?

The reason of doing it as we have a server which needs to fork out the elastic search on its own.
I simply use Java ProcessBuilder to run elasticsearch.bat. It runs perfectly almost every time. Above issue occurs rarely but I am not getting why would it occur?

The question is: why do you need this?

Above issue occurs rarely but I am not getting why would it occur?

No idea. Something is not available when it runs but I don't really know how you are doing what you described.

  1. We do this as we do not want any manual intervention by customer even to setup a service.
  2. Consider it like a script which just invokes elasticsearch.bat separately. I am confused why ES would throw the NoClassDefFound error as whole setup/files are available to it. One thing is common in all the stacktraces that it originates from below line and ES gets crashed after this error. One thing to note that filebeat is also running at the same time and is continuously pushing the data to ES.

at org.elasticsearch.ingest.Pipeline.create(Pipeline.java:73) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.IngestService.validatePipeline(IngestService.java:361) ~[elasticsearch-6.5.4.jar:6.5.4]

  1. Ok. Would be better maybe to start a Docker image instead but I understand it can be an issue.

  2. I understood that but I cannot tell where the issue is without seeing what you are exactly doing (the whole code). There's more likely something wrong.
    But you can always look at what this project is doing to launch elasticsearch from a Java class.

That might help you.

I am also using almost the same way to start/fork the ES instance, though I am not using maven.
I am launching:
elasticsearch.bat -d -p <pid_file_path> with important settings set in elasticsearch.yml file

There's nothing I can do I'm afraid.
If you find out the problem, please share here where the problem was coming from.

I can't see the code so I can just suspect that not all the files (librairies) are fully available on disk when the process starts. May be a write delay on Windows machine? Just try to add a pause before starting to see if it's getting better.

I will check further, but there is one strange thing.
After ES is started successfully, my Java code fire URL/_ingest/pipeline/ REST call to ES to populate the various pipelines.
In one of the case where error occurred, first above REST call was successful but while putting second pipeline, following error occurred (in ES logs) and ES gets crashed. If it was some lib missing issue, first pipeline call would have been failed too.

[2019-03-06T13:34:19,784][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] fatal error in thread [elasticsearch[PC-***][management][T#1]], exiting
java.lang.NoClassDefFoundError: org/objectweb/asm/commons/Method
at org.elasticsearch.painless.ScriptClassInfo.(ScriptClassInfo.java:79) ~[?:?]
at org.elasticsearch.painless.Compiler.compile(Compiler.java:222) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine$5.run(PainlessScriptEngine.java:423) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine$5.run(PainlessScriptEngine.java:419) ~[?:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_181]
at org.elasticsearch.painless.PainlessScriptEngine.compile(PainlessScriptEngine.java:419) ~[?:?]
at org.elasticsearch.painless.PainlessScriptEngine.compile(PainlessScriptEngine.java:170) ~[?:?]
at org.elasticsearch.script.ScriptService.compile(ScriptService.java:334) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.common.ScriptProcessor$Factory.create(ScriptProcessor.java:148) ~[?:?]
at org.elasticsearch.ingest.common.ScriptProcessor$Factory.create(ScriptProcessor.java:90) ~[?:?]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessor(ConfigurationUtils.java:402) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessor(ConfigurationUtils.java:372) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.ConfigurationUtils.readProcessorConfigs(ConfigurationUtils.java:316) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.Pipeline.create(Pipeline.java:73) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.IngestService.validatePipeline(IngestService.java:361) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.ingest.IngestService.putPipeline(IngestService.java:215) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.action.ingest.PutPipelineTransportAction$1.onResponse(PutPipelineTransportAction.java:86) ~[elasticsearch-6.5.4.jar:6.5.4]
at org.elasticsearch.action.ingest.PutPipelineTransportAction$1.onResponse(PutPipelineTransportAction.java:78) ~[elasticsearch-6.5.4.jar:6.5.4]

Does the 1st pipeline use a Script processor or only the second one?

This is interesting. Only second pipeline def has script mentioned:
"processors" : [
{
"set": {
"field": "index_name",
"value":"log_abc"
}
},
{
"script": {
"source": "ctx._index = ctx.index_name"
}
}
]

can this be the reason? Still, why NoClassDefFoundError? Is there any workaround for this?

can this be the reason?

Yes. This is a reason.
That's sad that I had to guess because you still don't share all the information.

Is there any workaround for this?

May be.

Let me share for the last time this:

So if you need further help, please share on GitHub a project which reproduces your problem.

Thank you David. I will further check in this direction.

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