# PainlessExtension Custom Plugin is not loading

**URL:** <https://discuss.elastic.co/t/painlessextension-custom-plugin-is-not-loading/168744>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [February 17, 2019, 6:01pm UTC](https://discuss.elastic.co/t/painlessextension-custom-plugin-is-not-loading/168744 "2019-02-17T18:01:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajendra\_gj](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rajendra\_gj](https://discuss.elastic.co/u/rajendra_gj)\
**Post date:** [February 17, 2019, 6:01pm UTC](https://discuss.elastic.co/t/painlessextension-custom-plugin-is-not-loading/168744/1 "2019-02-17T18:01:48Z")

</div>

Hi Team,

I am writing a custom painless plugin to perform few custom calculations.  
I have referred this example and created one ([https://github.com/elastic/elasticsearch/tree/master/plugins/examples/painless-whitelist](https://github.com/elastic/elasticsearch/tree/master/plugins/examples/painless-whitelist)).

I have installed the plugin into elastic search folder directly with respective plugin-description file.

In the log i can see plugin loaded  
[2019-02-17T11:47:20,146][INFO][o.e.p.PluginsService] [QxGCpoN] loaded plugin [whitelist-maven]

But the class i created extending PainlessExtension is not loaded(Kept a log in static block to verify).  
When i try to use the class i get the below error.

"script": " double value = params.a \* params.b / \_score;\n double value1 = value \* 2;\n String first\_nm = doc['first\_nm'].toString();\n double value2 = Math.log(first\_nm.length());\n def e = new ExampleWhitelistedClass(2,3);\n int x = e.publicMember + e.getPrivateMemberAccessor\n return x + value2 / \_score;",  
"lang": "painless",  
"caused\_by": {  
"type": "illegal\_argument\_exception",  
"reason": "invalid sequence of tokens near ['ExampleWhitelistedClass'].",  
"caused\_by": {  
"type": "no\_viable\_alt\_exception",  
"reason": null  
}  
}

I am using elastic search version 6.6.0  
Can you please check and let me know what am i doing wrong.

Script :

POST \_scripts/first\_script  
{  
"script": {  
"lang": "painless",  
"source": """  
double value = params.a \* params.b / \_score;  
double value1 = value \* 2;  
String first\_nm = doc['first\_nm'].toString();  
double value2 = Math.log(first\_nm.length());  
def e = new ExampleWhitelistedClass(2,3);  
int x = e.publicMember + e.getPrivateMemberAccessor  
return x + value2 / \_score;  
"""  
}  
}

Query:  
{  
"query": {  
"function\_score": {  
"query": {  
"match": {  
"full\_text": {  
"query": "Rajendra",  
"fuzziness": "AUTO"  
}  
}  
},  
"script\_score": {  
"script": {

```
      "id": "first_script", 
      "params": {
        "a": 3,
        "b": 1.2
      }
    }
  }
}

```

}  
}

---

<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:** [March 17, 2019, 6:01pm UTC](https://discuss.elastic.co/t/painlessextension-custom-plugin-is-not-loading/168744/2 "2019-03-17T18:01:58Z")

</div>

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