# org.elasticsearch.xpack.notification.email.Account$1.run(Account.java:55) should cast to CommandMap not javax.activation.MailcapCommandMap

**URL:** <https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877>\
**Category:** Elasticsearch\
**Created:** [March 20, 2018, 11:27pm UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877 "2018-03-20T23:27:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sits](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sits](https://discuss.elastic.co/u/sits)\
**Post date:** [March 20, 2018, 11:27pm UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/1 "2018-03-20T23:27:03Z")

</div>

Hoping this is the right place to report this. I'm basically requesting on the offending line below to cast to CommandMap (the interface) rather than the concrete class MailcapCommandMap as our app uses a custom ComandMap.

Kibana version: 5.5.0  
Elasticsearch version: 5.5.0  
Server OS version: Linux 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86\_64 x86\_64 x86\_64 GNU/Linux  
Browser version: Chrome  
Browser OS version: Linux

Description of the problem including expected versus actual behavior:

When ES cluster was in a bad state (single master in test cluster was in heavy GC loop) the transport client could not initialise XPackPlugin due to an incorrect cast in the X-PACK code. We have registered a custom CommandMap called UnmodifiableMailcapCommandMap as can be seen in the logs below.

Steps to reproduce:

Get cluster into bad state.  
Install a custom CommandMap into the JVM.  
Try to connect with transport client and X-PACK.  
Errors in browser console (if relevant):

Provide logs and/or server output (if relevant):

java.lang.ExceptionInInitializerError: null  
at org.elasticsearch.xpack.XPackPlugin.(XPackPlugin.java:183) ~[x-pack-api-5.5.0.jar:5.5.0]  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0\_92]  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0\_92]  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0\_92]  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0\_92]  
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:423) ~[elasticsearch-5.5.0.jar:5.5.0]  
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:103) ~[elasticsearch-5.5.0.jar:5.5.0]  
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:101) ~[elasticsearch-5.5.0.jar:5.5.0]  
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126) ~[elasticsearch-5.5.0.jar:5.5.0]  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:265) ~[elasticsearch-5.5.0.jar:5.5.0]  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:130) ~[transport-5.5.0.jar:5.5.0]  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:55) ~[x-pack-transport-5.5.0.jar:5.5.0]  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:50) ~[x-pack-transport-5.5.0.jar:5.5.0]  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:46) ~[x-pack-transport-5.5.0.jar:5.5.0]  
...  
Caused by: java.lang.ClassCastException: com.xxxx.xxxx.UnmodifiableMailcapCommandMap cannot be cast to javax.activation.MailcapCommandMap  
at org.elasticsearch.xpack.notification.email.Account$1.run(Account.java:55) ~[x-pack-api-5.5.0.jar:5.5.0]  
at org.elasticsearch.xpack.notification.email.Account$1.run(Account.java:51) ~[x-pack-api-5.5.0.jar:5.5.0]  
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0\_92]  
at org.elasticsearch.xpack.notification.email.Account.(Account.java:51) ~[x-pack-api-5.5.0.jar:5.5.0]  
... 35 more

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 21, 2018, 5:42pm UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/2 "2018-03-21T17:42:53Z")

</div>

Hey,

indeed this is something we do not cater for currently. From Elasticsearch 6.2 onwards we do load a different Plugin, but as this code is in a static code block we might load it anyway.

I will investigate and report back. Thanks for bringing this up!

--Alex

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 22, 2018, 1:04pm UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/3 "2018-03-22T13:04:14Z")

</div>

So I tested this up to 6.2, and this is the first version where this is fixed and I did not get an error back, once I set a custom mailcap and then created a client.

May I ask you to test that one and see if that works for you as well?

---

<div class="post-metadata">

**Author:** ![sits](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sits](https://discuss.elastic.co/u/sits)\
**Post date:** [March 23, 2018, 12:52am UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/4 "2018-03-23T00:52:25Z")

</div>

Thanks.. that's good to hear it is fixed in 6.2. We are stuck on 5.5.0 for now but we'll be upgrading hopefully in around 4 months.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 23, 2018, 1:09am UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/5 "2018-03-23T01:09:33Z")

</div>

I'd still be super happy, if you could give it a quick test (to make sure I didnt create an artificial test), but of course a few things need to be fixed before you compile.

Can you either create the transport client before you configure the mailcap or temporarily change it back to the original one as a current workaround? You should not have any problems during runtime, it is really only about the initialization I think.

--Alex

---

<div class="post-metadata">

**Author:** ![sits](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sits](https://discuss.elastic.co/u/sits)\
**Post date:** [March 23, 2018, 1:30am UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/6 "2018-03-23T01:30:51Z")

</div>

I wish we could do a quick test, but our application is gigantic with many dependencies that make this non-trivial I'm afraid. The way the product starts up all the utilities are initialised (like the custom mailcap) before a transport client is created.

I appreciate your help here. The issue only happens when the cluster was down but I thought it was worth reporting. I can't see the code of course but hopefully doing a search for any explicit cast on (MailcapCommandMap) is not present anywhere now?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 23, 2018, 10:48am UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/7 "2018-03-23T10:48:19Z")

</div>

even simpler: the client from 6.2 onwards does not contain that class (and that code) anymore

---

<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 20, 2018, 10:48am UTC](https://discuss.elastic.co/t/org-elasticsearch-xpack-notification-email-account-1-run-account-java-55-should-cast-to-commandmap-not-javax-activation-mailcapcommandmap/124877/8 "2018-04-20T10:48:24Z")

</div>

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