You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Mohmed Hussain <mo...@gmail.com> on 2015/01/12 20:05:38 UTC

Custom plugin classloader issue

Hi All,
   I am stuck at a strange issue, I have my custom Query Component that has
to load spring application context for some additional runtime filtering of
records.
   I have included my jars as dependency in solrConfig.xml, SOLR is able to
load my plugin but spring appplication fails to load with error.

This is how my solrConfig looks
  <lib path="${solr.solr.home}/mylib/myapp.jar" />

Following is the stack trace, any pointer of what is causing the issue

org.springframework.beans.factory.BeanDefinitionStoreException: IOException
parsing XML document from class path resource
[com/myapp/spring/myapp-spring-master.xml]; nested exception is
java.io.FileNotFoundException: class path resource
[com/myapp/spring/myapp-spring-master.xml] cannot be opened because it does
not exist
        at
com.myapp.spring.MyAppApplicationContextAware.loadApplicationContext(MyAppApplicationContextAware.java:69)
        at
com.myapp.spring.MyAppApplicationContextAware.getApplicationContext(MyAppApplicationContextAware.java:48)
        at
org.apache.solr.handler.component.CustomSecureQueryComponent.authenticateUser(CustomSecureQueryComponent.java:294)
        at
org.apache.solr.handler.component.CustomSecureQueryComponent.doPrefetch(CustomSecureQueryComponent.java:67)


Thanks
-Hussain

Re: Custom plugin classloader issue

Posted by Mohmed Hussain <mo...@gmail.com>.
Thanks Chris, that worked. Loaded my Spring Application context with plugin
class loader. Was trying to resolve this since a day, and you resolved it
in a minute :)

Thanks
-Hussain

On Mon, Jan 12, 2015 at 11:29 AM, Chris Hostetter <ho...@fucit.org>
wrote:

>
> :    I am stuck at a strange issue, I have my custom Query Component that
> has
> : to load spring application context for some additional runtime filtering
> of
> : records.
> :    I have included my jars as dependency in solrConfig.xml, SOLR is able
> to
> : load my plugin but spring appplication fails to load with error.
>
> when you instantiate your Spring context, you have to make it aware of the
> ClassLoader you get from the SolrResourceLoader so that Spring knows where
> to find the resources in your jar.
>
> first google result i found about specifying a classloader when
> instantiating spring...
>
>
> https://stackoverflow.com/questions/5660115/loading-spring-context-with-specific-classloader
>
>
> : This is how my solrConfig looks
> :   <lib path="${solr.solr.home}/mylib/myapp.jar" />
> :
> : Following is the stack trace, any pointer of what is causing the issue
> :
> : org.springframework.beans.factory.BeanDefinitionStoreException:
> IOException
> : parsing XML document from class path resource
> : [com/myapp/spring/myapp-spring-master.xml]; nested exception is
> : java.io.FileNotFoundException: class path resource
> : [com/myapp/spring/myapp-spring-master.xml] cannot be opened because it
> does
> : not exist
> :         at
> :
> com.myapp.spring.MyAppApplicationContextAware.loadApplicationContext(MyAppApplicationContextAware.java:69)
> :         at
> :
> com.myapp.spring.MyAppApplicationContextAware.getApplicationContext(MyAppApplicationContextAware.java:48)
> :         at
> :
> org.apache.solr.handler.component.CustomSecureQueryComponent.authenticateUser(CustomSecureQueryComponent.java:294)
> :         at
> :
> org.apache.solr.handler.component.CustomSecureQueryComponent.doPrefetch(CustomSecureQueryComponent.java:67)
> :
> :
> : Thanks
> : -Hussain
> :
>
> -Hoss
> http://www.lucidworks.com/
>

Re: Custom plugin classloader issue

Posted by Chris Hostetter <ho...@fucit.org>.
:    I am stuck at a strange issue, I have my custom Query Component that has
: to load spring application context for some additional runtime filtering of
: records.
:    I have included my jars as dependency in solrConfig.xml, SOLR is able to
: load my plugin but spring appplication fails to load with error.

when you instantiate your Spring context, you have to make it aware of the 
ClassLoader you get from the SolrResourceLoader so that Spring knows where 
to find the resources in your jar.

first google result i found about specifying a classloader when 
instantiating spring...

https://stackoverflow.com/questions/5660115/loading-spring-context-with-specific-classloader


: This is how my solrConfig looks
:   <lib path="${solr.solr.home}/mylib/myapp.jar" />
: 
: Following is the stack trace, any pointer of what is causing the issue
: 
: org.springframework.beans.factory.BeanDefinitionStoreException: IOException
: parsing XML document from class path resource
: [com/myapp/spring/myapp-spring-master.xml]; nested exception is
: java.io.FileNotFoundException: class path resource
: [com/myapp/spring/myapp-spring-master.xml] cannot be opened because it does
: not exist
:         at
: com.myapp.spring.MyAppApplicationContextAware.loadApplicationContext(MyAppApplicationContextAware.java:69)
:         at
: com.myapp.spring.MyAppApplicationContextAware.getApplicationContext(MyAppApplicationContextAware.java:48)
:         at
: org.apache.solr.handler.component.CustomSecureQueryComponent.authenticateUser(CustomSecureQueryComponent.java:294)
:         at
: org.apache.solr.handler.component.CustomSecureQueryComponent.doPrefetch(CustomSecureQueryComponent.java:67)
: 
: 
: Thanks
: -Hussain
: 

-Hoss
http://www.lucidworks.com/