# Plugin initialization order

**URL:** <https://discuss.elastic.co/t/plugin-initialization-order/13564>\
**Category:** Elasticsearch\
**Created:** [September 12, 2013, 12:57am UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564 "2013-09-12T00:57:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [September 12, 2013, 12:57am UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564/1 "2013-09-12T00:57:51Z")

</div>

I saw a post about this subject sometime in the past year, but I cannot  
find it.

I created a new type of TransportNodesOperationAction and tried to inject  
the AnalysisService into the constructor. Upon startup I received a  
"Initialization Failed" exception, so I am assuming that the  
AnalysisService does not get initialized until after the plugins are  
loaded. I have no other issues with other services,  
including IndicesAnalysisService, but AnalysisService is what I am after.

Before I dig deeper into the code, especially the Guice injections, can  
someone confirm this issue is true? The only locations in the code that I  
can see AnalysisService injected into is  
RobinEngine, MapperService, IndexQueryParserService, and  
InternalIndexService. No Actions of any kind.

Cheers,

Ivan

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 12, 2013, 7:24am UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564/2 "2013-09-12T07:24:05Z")

</div>

Without seeing the exception stack trace, I'm unable to shed some light on  
the cause.

You can instantiate an AnalysisService if you have an Index, there is a  
constructor with a single parameter.

Another approach for Guice-based instantiation is to use an Injector with a  
ModuleBuilder so you can pack the required instances for dependency  
resolution, an example is in IndexQueryParserModuleTests

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [September 12, 2013, 3:13pm UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564/3 "2013-09-12T15:13:24Z")

</div>

Responses inline.

On Thu, Sep 12, 2013 at 12:24 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> Without seeing the exception stack trace, I'm unable to shed some light on  
> the cause.

I do not have the code in front of me now, but there was no real stack  
trace. Just "Initialization Failed" along with various instance variables  
that have no been initialized, so obviously the AnalysisService has not  
been initialized. Now I remember that there was another mailing list post  
about someone trying to override an analysis component definition via a  
plugin, but the initialization of the AnalysisModule happened after the  
plugin, so the new defaults were overridden by the true defaults. Once  
again, I cannot find the post.

> You can instantiate an AnalysisService if you have an Index, there is a  
> constructor with a single parameter.

I do this exact step on the client side so that I can pre-analyze terms for  
span queries that do not analyze terms. I am more worried about  
initializing something before its time because of other dependencies.

> Another approach for Guice-based instantiation is to use an Injector with  
> a ModuleBuilder so you can pack the required instances for dependency  
> resolution, an example is in IndexQueryParserModuleTests

Ultimately, the lack of the AnalysisService is not a show-stopper since I  
can create my own registry of token filter factories as statics at the JVM  
level. Not much memory needed for a few objects and my access patterns  
would be simplified. Still thinking about which Action type to use, but  
that's another posting.

Cheers,

Ivan

> Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [September 16, 2013, 4:38pm UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564/4 "2013-09-16T16:38:59Z")

</div>

Finally had a chance to revisit the exception. As I stated before, there  
was no real stack trace:

> <https://gist.github.com/brusic/fd4637dcba2e1185edb2>

My own code might have an ordering issue since the onModule methods have no  
explicit ordering:

public void onModule(ActionModule module) {  
module.registerAction(...);  
}

public void onModule(AnalysisModule module) {  
module.addTokenFilter(...);  
}

The action registered in the ActionModule is the one that should have the  
injected AnalysisService. Ideally, this AnalysisService should have access  
to the token filters added to the AnalysisModule, but have so one startup  
is not essential. Going to simply write my own token fitler registry.

Cheers,

Ivan

On Thu, Sep 12, 2013 at 12:24 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) \<  
[joergprante@gmail.com](mailto:joergprante@gmail.com)\> wrote:

> Without seeing the exception stack trace, I'm unable to shed some light on  
> the cause.
> 
> You can instantiate an AnalysisService if you have an Index, there is a  
> constructor with a single parameter.
> 
> Another approach for Guice-based instantiation is to use an Injector with  
> a ModuleBuilder so you can pack the required instances for dependency  
> resolution, an example is in IndexQueryParserModuleTests
> 
> Jörg
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:16am UTC](https://discuss.elastic.co/t/plugin-initialization-order/13564/5 "2017-07-06T02:16:16Z")

</div>


