# java.lang.ClassNotFoundException: org.bouncycastle.operator.OperatorCreationException

**URL:** <https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [March 6, 2019, 2:27pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133 "2019-03-06T14:27:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 6, 2019, 2:27pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/1 "2019-03-06T14:27:57Z")

</div>

I wanted to try out X-Pack and when i run my spring application after adding the dependencies, I am getting the following error

```auto
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException
	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_172]
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_172]
	at java.lang.Class.getConstructors(Class.java:1651) ~[na:1.8.0_172]
	at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:426) ~[elasticsearch-6.1.2.jar:6.1.2]
	at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:105) ~[elasticsearch-6.1.2.jar:6.1.2]
	at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:103) ~[elasticsearch-6.1.2.jar:6.1.2]
	at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:128) ~[elasticsearch-6.1.2.jar:6.1.2]
	at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:262) ~[elasticsearch-6.1.2.jar:6.1.2]
	at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128) ~[transport-6.1.2.jar:6.1.2]
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:58) ~[x-pack-transport-6.1.2.jar:6.1.2]
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:53) ~[x-pack-transport-6.1.2.jar:6.1.2]
	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:49) ~[x-pack-transport-6.1.2.jar:6.1.2]

```

Elasticsearch version - 6.1.2  
Transport client version - 6.1.2  
X-Pack transport client version - 6.1.2

here is the dependencies and repo i added in my pom as per [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/setup-xpack-client.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/setup-xpack-client.html)

```auto
<repositories>
        <!-- add the elasticsearch repo -->
        <repository>
            <id>elasticsearch-releases</id>
            <url>https://artifacts.elastic.co/maven</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>x-pack-transport</artifactId>
                <version>6.1.2</version>
                <scope>system</scope>
                <systemPath> /path/to/x-pack-transport.jar</systemPath>
    </dependency>
            <dependency>
                <groupId>org.elasticsearch.plugin</groupId>
                <artifactId>x-pack-api</artifactId>
                <version>6.1.2</version>
                <scope>system</scope>
                <systemPath> /path/to/x-pack-api.jar</systemPath>
            </dependency>
            <dependency>
            <groupId>com.unboundid</groupId>
            <artifactId>unboundid-ldapsdk</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>1.58</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk15on</artifactId>
            <version>1.58</version>
        </dependency>

```

I am unable to tag this to X-Pack directly, hence had to tag it to elasticsearch

---

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 6, 2019, 2:42pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/2 "2019-03-06T14:42:21Z")

</div>

someone please help

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 6, 2019, 2:42pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/3 "2019-03-06T14:42:49Z")

</div>

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 6, 2019, 2:55pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/4 "2019-03-06T14:55:05Z")

</div>

I tried to format a bit you post as it was looking weird and was really readable. Please for your next post, make sure that it's correctly formatted (use the preview window to check).

Some thoughts:

- Why did you manually add bouncycastle lib?
- What is your Java version.

But more than this, don't use the transport client but the rest client. The transport client will be removed in the future.

---

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 6, 2019, 5:08pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/5 "2019-03-06T17:08:44Z")

</div>

Apologies. I will make sure that I follow the guidelines next time.

- Why did you manually add bouncycastle lib?  
Initially when I ran my application, I got the below error

I searched online and implemented the solution given in `[this topic](https://discuss.elastic.co/t/unable-to-create-prebuiltxpacktransportclient-client-x-pack/135384) . I ran the application after making the above change, now I am getting bouncycastle error

- What is your Java version.  
1.8

Yes, I plan to move to rest client in next couple of months.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 6, 2019, 6:01pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/6 "2019-03-06T18:01:41Z")

</div>

I don't think it's still needed. Unsure though as you are using an old version. You should really move to 6.6.1 Rest Client instead.

---

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 7, 2019, 4:52am UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/7 "2019-03-07T04:52:20Z")

</div>

Moving to 6.6.1 and Rest Client is a big change and I can't afford to do it right now. Can you please suggest me a fix with out a version upgrade?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 7, 2019, 7:44am UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/8 "2019-03-07T07:44:58Z")

</div>

I just did. Don't add the other jars than the one recommended in documentation.  
If it does not work, then run:

```
mvn dependency:tree
```

---

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 7, 2019, 10:13am UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/9 "2019-03-07T10:13:53Z")

</div>

I am getting the same error even after removing unnecessary dependencies. Please note that when i compile, I don't see any errors and application compiles successfully. Getting this error only when i run the application

```
    Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_172]
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_172]
    	at java.lang.Class.getConstructors(Class.java:1651) ~[na:1.8.0_172]
    	at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:426) ~[elasticsearch-6.1.2.jar:6.1.2]
    	at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:105) ~[elasticsearch-6.1.2.jar:6.1.2]
    	at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:103) ~[elasticsearch-6.1.2.jar:6.1.2]
    	at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:128) ~[elasticsearch-6.1.2.jar:6.1.2]
    	at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:262) ~[elasticsearch-6.1.2.jar:6.1.2]
    	at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128) ~[transport-6.1.2.jar:6.1.2]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:58) ~[x-pack-transport-6.1.2.jar:6.1.2]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:53) ~[x-pack-transport-6.1.2.jar:6.1.2]
    	at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:49) ~[x-pack-transport-6.1.2.jar:6.1.2]

```

Here is the pom file now

```
<repositories>
        <!-- add the elasticsearch repo -->
        <repository>
            <id>elasticsearch-releases</id>
            <url>https://artifacts.elastic.co/maven</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>x-pack-transport</artifactId>
                <version>6.1.2</version>
                <scope>system</scope>
                <systemPath> /path/to/x-pack-transport.jar</systemPath>
    </dependency>
            <dependency>
                <groupId>org.elasticsearch.plugin</groupId>
                <artifactId>x-pack-api</artifactId>
                <version>6.1.2</version>
                <scope>system</scope>
                <systemPath> /path/to/x-pack-api.jar</systemPath>
            </dependency>
           <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>6.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.1.2</version>
        </dependency>

```

I ran mvn dependency:tree and here is the output

```
[INFO] +- org.elasticsearch.client:transport:jar:6.1.2:compile
[INFO] | +- org.elasticsearch.plugin:transport-netty4-client:jar:6.1.2:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.13.Final:compile
[INFO] | | +- io.netty:netty-codec:jar:4.1.13.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.13.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.13.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.13.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.13.Final:compile
[INFO] | | \- io.netty:netty-transport:jar:4.1.13.Final:compile
[INFO] | +- org.elasticsearch.plugin:reindex-client:jar:6.1.2:compile
[INFO] | | \- org.elasticsearch.client:elasticsearch-rest-client:jar:6.1.2:compile
[INFO] | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] | | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.5:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | +- org.elasticsearch.plugin:lang-mustache-client:jar:6.1.2:compile
[INFO] | | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
[INFO] | +- org.elasticsearch.plugin:percolator-client:jar:6.1.2:compile
[INFO] | \- org.elasticsearch.plugin:parent-join-client:jar:6.1.2:compile
[INFO] +- org.elasticsearch.client:x-pack-transport:jar:6.1.2:system
[INFO] +- org.elasticsearch.plugin:x-pack-api:jar:6.1.2:system
[INFO] +- org.elasticsearch:elasticsearch:jar:6.1.2:compile
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 7, 2019, 12:10pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/10 "2019-03-07T12:10:36Z")

</div>

Is it the full output of mvn command?

---

<div class="post-metadata">

**Author:** ![avinash\_07](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avinash\_07](https://discuss.elastic.co/u/avinash_07)\
**Post date:** [March 8, 2019, 6:41pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/11 "2019-03-08T18:41:39Z")

</div>

I removed the systempath and scope tags from the pom and tried again. It worked 🙂

I thought we need to manually download the jar and specify the path as it isn't available in maven repository. Turns out that the jars are being fetched from es repo.

---

<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:** [April 5, 2019, 6:41pm UTC](https://discuss.elastic.co/t/java-lang-classnotfoundexception-org-bouncycastle-operator-operatorcreationexception/171133/12 "2019-04-05T18:41:45Z")

</div>

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