Elasticsearch: Unable to run elasticsearch - Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.Version 1.0.0

Created on 13 Feb 2014  路  33Comments  路  Source: elastic/elasticsearch

I got an error using elasticsearch 1.0.0 ( with version 0.90.x without any problem).

[root@logger01 /Software/bin]# Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/bootstrap/Elasticsearch
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.bootstrap.Elasticsearch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit.

OS FreeBSD 10.0 x64

java -version:

java -version
openjdk version "1.6.0_32"
OpenJDK Runtime Environment (build 1.6.0_32-b30)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

thanks for any help.
Stefan

>non-issue

Most helpful comment

This is just for someone who has spent hours finding the solution (like me). I got this issue today when trying to run elasticsearch 1.7.6 with Java 1.8.

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.Version
    at org.elasticsearch.bootstrap.Bootstrap.buildErrorMessage(Bootstrap.java:293)
    at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:280)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)

The error was a bit misleading so I tried running the org.elasticsearch.Version directly to understand why it could not be initialized, and I got the next error. My command for running it directly (while I was in the lib of elasticsearch folder):

java -verbose:class -cp elasticsearch-1.7.6.jar:lucene-core-4.10.4.jar org.elasticsearch.Version

Error:

java.lang.NoSuchFieldError: LUCENE_3_6
    at org.elasticsearch.Version.<clinit>(Version.java:43)

Ok, it did not make any sense to me because LUCENE_3_6 was definitely defined in the lucene-core-4.10.4.jar. After hours of searching for solution, I found a post saying that if multiple jars are loaded at the same time, it could cause the issue. Because there was only 1 lucene-core*.jar in lib, I did not think this is the case. But when I ran the jar file again with the -verbose:class option, I could clearly see that another JAR from a newer version of lucene was loaded (it was in /Library/Java/Extensions/ for some reason). I removed it and I could run elasticsearch now.

What did I learn? The option -verbose:class is extremely useful :)

All 33 comments

is there a possibility, that you have a 0.90 and 1.0 installation mixed up somehow? The startup script seems to be 1.0, but the resources cannot be found it seems...

How did you install elasticsearch?

I dont have a lot of freebsd experience so I definately need your help here :-)

Thanks!

Hi Alex,
I found the following interesting things.
This is the original command from FreeBSD elasticsearch startup script.

/usr/local/openjdk6/bin/java -Des.pidfile=/var/run/elasticsearch.pid -server -Xms16g -Xmx16g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.config=/usr/local/etc/elasticsearch/elasticsearch.yml -cp /usr/local/lib/elasticsearch/elasticsearch-0.90.11.jar:/usr/local/lib/elasticsearch/*:/usr/local/lib/elasticsearch/sigar/* org.elasticsearch.bootstrap.ElasticSearch

I'm testing the following:
Delete all the files in "/usr/local/lib/elasticsearch" and copy the v1.0.0 files there.
It did, by the way with all .090.x versions without problem.

Changed "elasticsearch-0.90.11.jar" to "elasticsearch-1.0.0.jar" and start the command new,
but i get directly this ClassNotFoundException.

However i can v1.0.0 with the original startup-scrip from elasticsearch distribution start.
This ist the start command from this script.

/usr/local/openjdk6/bin/java -Xms256m -Xmx1g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.foreground=yes -Des.path.home=/Software/elasticsearch-1.0.0 -cp :/Software/elasticsearch-1.0.0/lib/elasticsearch-1.0.0.jar:/Software/elasticsearch-1.0.0/lib/*:/Software/elasticsearch-1.0.0/lib/sigar/* org.elasticsearch.bootstrap.Elasticsearch

Wondering why wants to start v1.0.0 not with the original startup-script FreeBSD in "/usr/local/lib/elasticsearch"?

We renamed ElasticSearch.java to Elasticsearch.java in 1.0 that is why it's not finding the class

Thanks Simon for the fast reply. But where do i change what?

OK found it.
Thanks for any help here.
Stefan

cool! I will close this! thanks for the feedback

I am getting same error, installed es version is 1.2.0 and included jar dependency version is 1.2.2

Have you tried the fix above?

I tried above solution but it didn't worked. I am using sun jdk with ubuntu 14.04 version, there was no elasticsearch-1.0.0.jar in my installation

is there a patch or script to fix above problem?

Solved, thanks. But new error came, Could not initialize class org.elasticsearch.Version :(

@blikenoother if you found a solution, please describe it

java -version

java version "1.6.0_28"
OpenJDK Runtime Environment (IcedTea6 1.13.0pre) (rhel-1.66.1.13.0.el6-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit.

@jiajie999 you need java 7

@clintongormley Thanks!

+1 had the same issue. Maybe this should be stressed out in the installation page as an explicit dependency (I think it's mentioned somewhere else though).

+1 Same issue as @jiajie999 here. Only java 6 (1.6.0_26) installed and Elasticsearch-1.3.2 installation gives the cryptic message. [Exception in thread "main" java.lang.UnsupportedClassVersionError: .... Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit.]

Is there a legacy package that works with java 6 ?

@Aardvark71 the last version that worked with java6 was 1.1 afaik. Where do you even get these ancient JVMs what keeps you from updateing to a JVM that is actually still supported by the vendors?

@s1monw Thanks for the info. And regarding where we get these ancient JVMs: The kind of environment where one is also forced to still use IE8 and so on.. >> corporate enviroment

Did a first time install of elasticsearch (elasticsearch-1.3.2-1.noarch) via yum on a CentOS6.5 server. And ran into "Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit." yum install java-1.7.0-openjdk.x86_64 fixed that issue.
Please consider adding a dependency (=> java-1.7.0-openjdk) in the rpm.

Guys !!

We are using pentaho 5.0.1 which internally uses java 1.7 . We are trying to connect to Elastic Search server 1.4 which is a local server we are using for testing. Previously we used to connect to 0.19 using a es_0.19_patch file. But after upgradation we are unable to connect to the es server. Can you please let us know where can we find a patch file to connect to ES 1.4 server. Please help us to achieve this.
Any help is highly appreciated.

@committedoutlook9407135094 I answered in #9115. You should open an issue in Pentaho project.

Okay so what is the issue here?
I have installed on 16.10x64 with apt-get install elasticsearch and I have Java 1.0.0_111

Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/common/jackson/dataformat/yaml/snakeyaml/error/YAMLException
        at org.elasticsearch.common.jackson.dataformat.yaml.YAMLFactory._createParser(YAMLFactory.java:426)
        at org.elasticsearch.common.jackson.dataformat.yaml.YAMLFactory.createParser(YAMLFactory.java:327)
        at org.elasticsearch.common.xcontent.yaml.YamlXContent.createParser(YamlXContent.java:90)
        at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:45)
        at org.elasticsearch.common.settings.loader.YamlSettingsLoader.load(YamlSettingsLoader.java:46)
        at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:982)
        at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromUrl(ImmutableSettings.java:969)
        at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:110)
        at org.elasticsearch.bootstrap.Bootstrap.initialSettings(Bootstrap.java:144)
        at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:215)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.error.YAMLException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 11 more

@d4rkd0s I'm not sure what your issue is though I don't suspect any java with 1.0.0 in the version number is going to help you. Also this issue is long dead. I think you'd be better of asking on discuss.elastic.co.

I found out my issue was with Debian see more info here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=829078

I resolved it by simply using 16.04 Ubuntu instead of 16.10. Also there was talk of skipping downstream and going right to upstream from Elasticsearch and downloading from there to prevent this issue/bug.

All I know is its YAML and Debian, something with that.

Turns out this is a problem with the Elasticsearch package provided by Debian, not the official Elasticsearch debian package provided by us.

After upgrade to 5.5.0 i have this problem.
What helped me : Uninstall openjdk9 install openjdk8
Symlink config : ln -s /etc/elasticsearch /usr/share/elasticsearch/config
Correcting rights :

chmod g+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/logging.yml
chmod g+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml

@clintongormley This is a not-so-funny way of looking at the Debian distribution. In reality, the official Debian packages are always the ones which are part of the distribution. I appreciate it when young projects provide their own .deb packages until the project eventually gets included in the distribution, but this is not the case here. The package is part of the official distribution and is broken. This is a problem that should be resolved rather than ignored. You can either ask the Debian project to remove it from the distribution, or you can help the maintainer fix the problems. I also want to point out that the Elasticsearch website itself suggests to download the software via APT and it's not stressed enough that it shouldn't be done with the official distribution source but rather with another repository.

=> Can someone reopen this issue please ? The goal is to talk with the Debian project to either ask them to remove the broken package or to help them fix it.

And another lame failure :

Package: elasticsearch
Version: 5.6.3
Source: elasticsearch
Maintainer: Elasticsearch Team [email protected]
Depends: libc6, adduser, bash

Did you forget to depend on default-jre here ?

Did you forget to depend on default-jre here ?

No, this is a deliberate choice (otherwise users that want the Oracle JDK would be having our package install an OpenJDK package that they do not want).

You can either ask the Debian project to remove it from the distribution, or you can help the maintainer fix the problems.

Sorry, I can appreciate this perspective but we are not going to take responsibility for downstream, there's simply too many and it's too difficult to draw a line for which we should and which we should not.

This is just for someone who has spent hours finding the solution (like me). I got this issue today when trying to run elasticsearch 1.7.6 with Java 1.8.

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.Version
    at org.elasticsearch.bootstrap.Bootstrap.buildErrorMessage(Bootstrap.java:293)
    at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:280)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)

The error was a bit misleading so I tried running the org.elasticsearch.Version directly to understand why it could not be initialized, and I got the next error. My command for running it directly (while I was in the lib of elasticsearch folder):

java -verbose:class -cp elasticsearch-1.7.6.jar:lucene-core-4.10.4.jar org.elasticsearch.Version

Error:

java.lang.NoSuchFieldError: LUCENE_3_6
    at org.elasticsearch.Version.<clinit>(Version.java:43)

Ok, it did not make any sense to me because LUCENE_3_6 was definitely defined in the lucene-core-4.10.4.jar. After hours of searching for solution, I found a post saying that if multiple jars are loaded at the same time, it could cause the issue. Because there was only 1 lucene-core*.jar in lib, I did not think this is the case. But when I ran the jar file again with the -verbose:class option, I could clearly see that another JAR from a newer version of lucene was loaded (it was in /Library/Java/Extensions/ for some reason). I removed it and I could run elasticsearch now.

What did I learn? The option -verbose:class is extremely useful :)

C:Program FilesElasticstackelasticsearch-7.9.0bin>elasticsearch.bat
Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
output:
[0.003s][error][logging] Error opening log file 'logs/gc.log': Permission denied
[0.003s][error][logging] Initialization of output 'file=logs/gc.log' using options 'filecount=32,filesize=64m' failed.
error:
Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m', see error log for details.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:126)
at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88)
at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:137)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:95)

what to do with it? already set system variables and path

Sorry, I can appreciate this perspective but we are not going to take responsibility for downstream, there's simply too many and it's too difficult to draw a line for which we should and which we should not.

IMO, there are only a handful distributions that matter, and Debian is one of them. I think contacting the package author/maintainer to kindly ask him to remove it because it's broken is not some immense amount of work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clintongormley picture clintongormley  路  3Comments

makeyang picture makeyang  路  3Comments

clintongormley picture clintongormley  路  3Comments

rpalsaxena picture rpalsaxena  路  3Comments

malpani picture malpani  路  3Comments