Java classloader not able to load - Error: Could not find or load main class

I've been following both the short and long version of the documentation in installing Shield. However, I can't seem to be able to add any users as I'm getting the below error.

Error: Could not find or load main class org.elasticsearch.shield.authc.esusers.tool.ESUsersTool

Below are the exact steps I took in installing Shield

  1. Created .profile file in home which included export ES_JAVA_OPTS="-Des.path.conf=/etc/elasticsearch"
  2. Ran source .profile and verified the path by running echo $ES_JAVA_OPTS
  3. Ran brew info elasticsearch and identified the ES home directory
  4. In ES home, installed both the license and shield with commands bin/plugin -i elasticsearch/license/latest followed by bin/plugin -i elasticsearch/shield/latest
  5. Restarted ES by first running brew info elasticsearch to get the commands to unload and reload ES
  6. Opened localhost:9200 on my browser, authentication required
  7. Ran bin/shield/esusers useradd admin -r admin to add and admin.

This was where I'm getting the mentioned error. Repeated this steps couple of times both on my Mac and Ubuntu. Not too sure where the problem is as my technical knowledge is quite limited plus there seem to be no such post about this particular error anywhere on google.

Are you using homebrew on both mac and linux? I'm guessing these installations put the libraries in a different location than the scripts expect.

Yes. I installed with Homebrew on my Mac and with Linuxbrew on Ubuntu. Any idea on how I can figure out exactly where those libraries are installed ??

Is there a reason to use linuxbrew over the official elasticsearch debian repositories? I think you've got the installation steps correct to work with those packages on linux and on Mac, you could use the tar/zip file.

The best guess I have to help with the homebrew stuff is to look at the formula for elasticsearch

Nope, no particular reason actually.

Just that early on, I was told that Homebrew makes installation much more easier. Thus, I just try to use Homebrew whenever possible. Didn't know that there would be inconsistency in installation.

I will try to study the ES formula and see if I can somewhat figure out where the libraries are located.

Thanks !!

Thanks jaymode !!

I manage to solve this problem, thus able to configure elasticserch and kibana with the shield plugin.

Linuxbrew was definitely the one messing up with the installations here. Stupid me for using that in Ubuntu.

So, what I did was uninstall the whole thing and install back elasticsearch & kibana using the apt-get command. From there it was all smooth sailing, referring to the documentation and some tutorials to get Shield running.

1 Like

For me using Homebrew on Mac, the Shield plugins got installed in /usr/local/var/lib/elasticsearch/plugins, so I had to tweak the ES_CLASSPATH as follows:


Thanks a lot man !!

I figured that just as Linuxbrew, it was Homebrew messing up the installation on Mac. Could not figure out the classpath so I just dropped it.

This will be useful for future references.

Thanks again !!

If Shield plugins got installed in using Homebrew on Mac. Is not recommended to hack it by change ES_CLASSPATH. You should to do as follows:

ln -s /usr/local/var/lib/elasticsearch/plugins/shield /usr/local/Cellar/elasticsearch/2.1.0_1/libexec/plugins