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

**URL:** <https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [July 7, 2015, 7:13am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016 "2015-07-07T07:13:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChickenWing24](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@ChickenWing24](https://discuss.elastic.co/u/ChickenWing24)\
**Post date:** [July 7, 2015, 7:13am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/1 "2015-07-07T07:13:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [July 7, 2015, 11:39am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/2 "2015-07-07T11:39:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChickenWing24](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@ChickenWing24](https://discuss.elastic.co/u/ChickenWing24)\
**Post date:** [July 7, 2015, 1:03pm UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/3 "2015-07-07T13:03:03Z")

</div>

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 ??

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [July 7, 2015, 1:22pm UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/4 "2015-07-07T13:22:11Z")

</div>

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 [https://github.com/Homebrew/homebrew/blob/master/Library/Formula/elasticsearch.rb](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/elasticsearch.rb)

---

<div class="post-metadata">

**Author:** ![ChickenWing24](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@ChickenWing24](https://discuss.elastic.co/u/ChickenWing24)\
**Post date:** [July 8, 2015, 2:27am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/5 "2015-07-08T02:27:44Z")

</div>

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 !!

---

<div class="post-metadata">

**Author:** ![ChickenWing24](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@ChickenWing24](https://discuss.elastic.co/u/ChickenWing24)\
**Post date:** [July 10, 2015, 4:04am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/6 "2015-07-10T04:04:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loren/32/44942_2.png) [@loren](https://discuss.elastic.co/u/loren)\
**Post date:** [July 27, 2015, 10:26pm UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/7 "2015-07-27T22:26:41Z")

</div>

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:

```auto
ES_CLASSPATH="$ES_CLASSPATH:/usr/local/var/lib/elasticsearch/plugins/shield/*"

```

---

<div class="post-metadata">

**Author:** ![ChickenWing24](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@ChickenWing24](https://discuss.elastic.co/u/ChickenWing24)\
**Post date:** [July 28, 2015, 2:09am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/8 "2015-07-28T02:09:44Z")

</div>

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 !!

---

<div class="post-metadata">

**Author:** ![yuez](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yuez](https://discuss.elastic.co/u/yuez)\
**Post date:** [August 3, 2016, 4:36am UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/9 "2016-08-03T04:36:14Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:42pm UTC](https://discuss.elastic.co/t/java-classloader-not-able-to-load-error-could-not-find-or-load-main-class/25016/10 "2017-07-06T13:42:33Z")

</div>


