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 adfel70 <ad...@gmail.com> on 2015/05/27 09:45:49 UTC

Native library of plugin is loaded for every core

Hi guys, need your help:
I added a custom plugins to Solr, to support my applicative needs (one index
handler and 2 search components), all of them access a native library using
JNI. The native library wrapper class loads the library using the regular
pattern:

public class YWrapper{
	static{
		System.loadLibrary("YJNI");
	}
	...
}


Basically things are working great, but when I try to create another
collection, an exception is being thrown:
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:Error
CREATing SolrCore 'anotherColl_shard1_replica1': Unable to create core
[anotherColl_shard1_replica1] caused by: Native Library
/...path_to_library/LibY.so already loaded in another classloader

I guess that this happens because every core has its own class loader. Is
that right? Is there any way to define my plugin (my jar file) as a shared
library, so it would only be loaded once when the process starts, and not on
every core instantiation?



--
View this message in context: http://lucene.472066.n3.nabble.com/Native-library-of-plugin-is-loaded-for-every-core-tp4207996.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Native library of plugin is loaded for every core

Posted by adfel70 <ad...@gmail.com>.
Works as expected :)
Thanks guys!



--
View this message in context: http://lucene.472066.n3.nabble.com/Native-library-of-plugin-is-loaded-for-every-core-tp4207996p4208372.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Native library of plugin is loaded for every core

Posted by Upayavira <uv...@odoko.co.uk>.
In your solr home directory, create a lib directory, and put your jar
there. Then you wont have to declare it in solrconfig.xml. That's what
Alan is suggesting.

Upayavira

On Wed, May 27, 2015, at 09:39 AM, adfel70 wrote:
> Hi Alan, thanks for the reply.
> I am not sure what did you mean. Currently it is loaded from
> solrconfig.xml
> <lib dir ="/path_to_plug_dir/", regex="*.jar" />
> 
> Is there any other way?
> 
> 
> 
> 
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Native-library-of-plugin-is-loaded-for-every-core-tp4207996p4208004.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Native library of plugin is loaded for every core

Posted by adfel70 <ad...@gmail.com>.
Hi Alan, thanks for the reply.
I am not sure what did you mean. Currently it is loaded from solrconfig.xml
<lib dir ="/path_to_plug_dir/", regex="*.jar" />

Is there any other way?




--
View this message in context: http://lucene.472066.n3.nabble.com/Native-library-of-plugin-is-loaded-for-every-core-tp4207996p4208004.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Native library of plugin is loaded for every core

Posted by Alan Woodward <al...@flax.co.uk>.
Does it work if you load it via the solr home /lib directory, rather than from the /lib directory of each individual core?

Alan Woodward
www.flax.co.uk


On 27 May 2015, at 08:45, adfel70 wrote:

> Hi guys, need your help:
> I added a custom plugins to Solr, to support my applicative needs (one index
> handler and 2 search components), all of them access a native library using
> JNI. The native library wrapper class loads the library using the regular
> pattern:
> 
> public class YWrapper{
> 	static{
> 		System.loadLibrary("YJNI");
> 	}
> 	...
> }
> 
> 
> Basically things are working great, but when I try to create another
> collection, an exception is being thrown:
> org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:Error
> CREATing SolrCore 'anotherColl_shard1_replica1': Unable to create core
> [anotherColl_shard1_replica1] caused by: Native Library
> /...path_to_library/LibY.so already loaded in another classloader
> 
> I guess that this happens because every core has its own class loader. Is
> that right? Is there any way to define my plugin (my jar file) as a shared
> library, so it would only be loaded once when the process starts, and not on
> every core instantiation?
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Native-library-of-plugin-is-loaded-for-every-core-tp4207996.html
> Sent from the Solr - User mailing list archive at Nabble.com.