# Why only one REST wrapper exists and not nested?

**URL:** <https://discuss.elastic.co/t/why-only-one-rest-wrapper-exists-and-not-nested/354719>\
**Category:** Elasticsearch\
**Created:** [March 5, 2024, 10:05am UTC](https://discuss.elastic.co/t/why-only-one-rest-wrapper-exists-and-not-nested/354719 "2024-03-05T10:05:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadLemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badlemon/32/132327_2.png) [@BadLemon](https://discuss.elastic.co/u/BadLemon)\
**Post date:** [March 5, 2024, 10:05am UTC](https://discuss.elastic.co/t/why-only-one-rest-wrapper-exists-and-not-nested/354719/1 "2024-03-05T10:05:54Z")

</div>

Hello everyone,  
Elasticsearch reports a error when I installed ranger elasticsearch plugin and restarted Elasticsearch:  
"Cannot have more than one plugin implementing a REST wrapper".  
Later, I found that there is a class named RangerElasticsearchPlugin in ranger elasticsearch plugin which implements org.elasticsearch.plugins.ActionPlugin, and in the elasticsearch.yml config file, xpack.security.enabled is true. This's what caused the above error.  
So I changed the elasticsearch code in org.elasticsearch.action.ActionModule `<init>` method to make it work well:

```auto
for (ActionPlugin plugin : actionPlugins) {
UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext());
if (newRestWrapper != null) {
logger.debug("Using REST wrapper from plugin " + plugin.getClass().getName());
if (restWrapper != null) {
UnaryOperator<RestHandler> newRestWrapperReference = newRestWrapper;
UnaryOperator<RestHandler> restWrapperReference = restWrapper;
newRestWrapper = (handler) -> newRestWrapperReference.apply(restWrapperReference.apply(handler));
// throw new IllegalArgumentException("Cannot have more than one plugin implementing a REST wrapper");
}
restWrapper = newRestWrapper;
}
}

```

Maybe my usage of ranger elasticsearch plugin is wrong, but I would like to know what the risks are if I change like this, or why only one REST wrapper existed instead of nesting it?

Thanks!

---

<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 2, 2024, 10:06am UTC](https://discuss.elastic.co/t/why-only-one-rest-wrapper-exists-and-not-nested/354719/2 "2024-04-02T10:06:39Z")

</div>

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