# How to load native script with 2.1?

**URL:** <https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077>\
**Category:** Elasticsearch\
**Created:** [December 28, 2015, 9:47pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077 "2015-12-28T21:47:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Chambers1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_chambers1/32/43254_2.png) [@Matt\_Chambers1](https://discuss.elastic.co/u/Matt_Chambers1)\
**Post date:** [December 28, 2015, 9:47pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077/1 "2015-12-28T21:47:53Z")

</div>

Hi everyone,

I'm upgrading from Elastic 1.7.3 to 2.1.1 and I think this is the final thing I need to fix. In 1.7 when I needed to load a native script I'd put it in my config like so:

script.native.nameOfScript.type=fully qualified class name

That doesn't see to be working anymore. I simply get a script not found.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 28, 2015, 10:28pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077/2 "2015-12-28T22:28:19Z")

</div>

The simplest way to load a native script is with a plugin. You can look at [jvm-example](https://github.com/elastic/elasticsearch/tree/2.1/plugins/jvm-example) in the source for a basic example. You make a plugin with the `onModule(ScriptModule module)` method and use the `module` reference to register your `NativeScriptFactory`.

I'm sorry for the loss of the old way. I think it was a casualty of classpath isolation for plugins but it was before I was paying close attention to that.

---

<div class="post-metadata">

**Author:** ![Matt\_Chambers1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_chambers1/32/43254_2.png) [@Matt\_Chambers1](https://discuss.elastic.co/u/Matt_Chambers1)\
**Post date:** [December 28, 2015, 10:34pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077/3 "2015-12-28T22:34:38Z")

</div>

Dang, this is from an app with an embedded elastic client, so the plugins are already in the jar. Not sure that makes a difference. I'm just trying to run unit tests now.

I made a plugin, but onModule(ScriptModule module) never seems to get called.

---

<div class="post-metadata">

**Author:** ![Matt\_Chambers1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_chambers1/32/43254_2.png) [@Matt\_Chambers1](https://discuss.elastic.co/u/Matt_Chambers1)\
**Post date:** [December 28, 2015, 11:07pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077/4 "2015-12-28T23:07:07Z")

</div>

So there is no way to load a plugin class manually? Can I get a reference to this scriptModule reference somehow and call onModule manually?

---

<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 5, 2017, 11:28pm UTC](https://discuss.elastic.co/t/how-to-load-native-script-with-2-1/38077/5 "2017-07-05T23:28:14Z")

</div>


