Could not find or load main class org.elasticsearch.tools.launchers.JavaVersionChecker

I'm using CentOS and have downloaded Elasticsearch 6.2.1. I created a new user "elastic" and when I run ./bin/elasticsearch I get the error:

Could not find or load main class org.elasticsearch.tools.launchers.JavaVersionChecker

I placed this user in the "wheel" group, since I'm led to understand that this group has admin privileges without acting as root. If I try it with "sudo ./bin/elasticsearch" I get:

[2018-02-15T17:42:39,776][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.1.jar:6.2.1]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.2.1.jar:6.2.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[elasticsearch-6.2.1.jar:6.2.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.2.1.jar:6.2.1]

I searched a bit and saw that it this error can be due to the java version, but it seems to be up to date:

[elastic@sandbox-hdp elasticsearch-6.1.1]$ sudo update-alternatives --config java

There are 3 programs which provide 'java'.

Selection Command

1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
*+ 2 /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
3 /usr/lib/jvm/jre-1.5.0-gcj/bin/java

Any suggestions?

I hate to bump a thread but I'm unable to get this to work and I'm not sure what else I can do. I know these errors are often configuration-based and can be a hassle to troubleshoot, but I need to get this working. Does anyone have any suggestions? This is on a Hortonworks HDP VM, so I don't know the ins and outs of how they've configured java on this system. Any assistance would be appreciated.

The message here is clear:

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

This is because you are executing the startup script as root. Let us not do that to avoid this problem.

Next, would you please move your Elasticsearch installation off of / and put it in /home/elastic/? If this still causes trouble, would you execute:

$ bash -x /home/elastic/elasticsearch-6.2.1/bin/elasticsearch

and we will start debugging from there.

1 Like

Thank you for the assistance, jasontedor...it appears to be working. At least, I think so...sorry this is for a course and I'm still getting familiar with elasticsearch. The output so far (when I run the elasticsearch command) is as follows:

[2018-02-17T22:03:39,314][INFO ][o.e.n.Node ] [] initializing ...
[2018-02-17T22:03:39,396][INFO ][o.e.e.NodeEnvironment ] [LSVW6GD] using [1] data paths, mounts [[/ (overlay)]], net usable_space [19.8gb], net total_space [42.6gb], types [overlay]
[2018-02-17T22:03:39,397][INFO ][o.e.e.NodeEnvironment ] [LSVW6GD] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-02-17T22:03:39,400][INFO ][o.e.n.Node ] node name [LSVW6GD] derived from node ID [LSVW6GD2RUm2Cdo0B6p1eA]; set [node.name] to override
[2018-02-17T22:03:39,400][INFO ][o.e.n.Node ] version[6.2.1], pid[2532], build[7299dc3/2018-02-07T19:34:26.990113Z], OS[Linux/4.4.114-1.el7.elrepo.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_161/25.161-b14]
[2018-02-17T22:03:39,401][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.KDEQJoCy, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/home/elastic3/elasticsearch-6.2.1, -Des.path.conf=/home/elastic3/elasticsearch-6.2.1/config]
[2018-02-17T22:03:40,111][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [aggs-matrix-stats]
[2018-02-17T22:03:40,111][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [analysis-common]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [ingest-common]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [lang-expression]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [lang-mustache]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [lang-painless]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [mapper-extras]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [parent-join]
[2018-02-17T22:03:40,112][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [percolator]
[2018-02-17T22:03:40,113][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [rank-eval]
[2018-02-17T22:03:40,113][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [reindex]
[2018-02-17T22:03:40,113][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [repository-url]
[2018-02-17T22:03:40,113][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [transport-netty4]
[2018-02-17T22:03:40,113][INFO ][o.e.p.PluginsService ] [LSVW6GD] loaded module [tribe]
[2018-02-17T22:03:40,114][INFO ][o.e.p.PluginsService ] [LSVW6GD] no plugins loaded
[2018-02-17T22:03:43,037][INFO ][o.e.d.DiscoveryModule ] [LSVW6GD] using discovery type [zen]
[2018-02-17T22:03:43,638][INFO ][o.e.n.Node ] initialized
[2018-02-17T22:03:43,638][INFO ][o.e.n.Node ] [LSVW6GD] starting ...
[2018-02-17T22:03:43,861][INFO ][o.e.t.TransportService ] [LSVW6GD] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2018-02-17T22:03:43,874][WARN ][o.e.b.BootstrapChecks ] [LSVW6GD] max number of threads [1024] for user [elastic] is too low, increase to at least [4096]
[2018-02-17T22:03:43,875][WARN ][o.e.b.BootstrapChecks ] [LSVW6GD] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-02-17T22:03:46,965][INFO ][o.e.c.s.MasterService ] [LSVW6GD] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {LSVW6GD}{LSVW6GD2RUm2Cdo0B6p1eA}{d7nLDjVWQLCktRTN62E_aQ}{127.0.0.1}{127.0.0.1:9300}
[2018-02-17T22:03:46,970][INFO ][o.e.c.s.ClusterApplierService] [LSVW6GD] new_master {LSVW6GD}{LSVW6GD2RUm2Cdo0B6p1eA}{d7nLDjVWQLCktRTN62E_aQ}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {LSVW6GD}{LSVW6GD2RUm2Cdo0B6p1eA}{d7nLDjVWQLCktRTN62E_aQ}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-02-17T22:03:46,994][INFO ][o.e.h.n.Netty4HttpServerTransport] [LSVW6GD] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
[2018-02-17T22:03:46,994][INFO ][o.e.n.Node ] [LSVW6GD] started
[2018-02-17T22:03:47,008][INFO ][o.e.g.GatewayService ] [LSVW6GD] recovered [0] indices into cluster_state

Yup, that looks good, your node is running! I am happy to have helped. Best wishes.

1 Like

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