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 Callum Lamb <cl...@mintel.com> on 2016/01/14 13:36:02 UTC

Classes in solr_home /lib cannot import from solr/dist

I've got an extension jar that contains a class which extends from

org.apache.solr.handler.dataimport.DataSource

But it only works if it's within the solr/dist folder. However when stored
in the lib/ folder within Solr home. When it tries to load the class it
cannot find it's parent:

Exception in thread "Thread-69" java.lang.NoClassDefFoundError:
org/apache/solr/handler/dataimport/DataSource
        at
org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:374)
        at
org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:102)
Caused by: java.lang.ClassNotFoundException:
org.apache.solr.handler.dataimport.DataSource

The classes in the lib folder don't have access to the class within the
dist folder in their classpath when they are loaded.

I'd like the keep my solr install separate from my configs/plugins/indexes
so I want to avoid putting it into the dist folder unless I absolutely have
to.

Is this by design? Is there some kind of configuration somewhere I can
tweak to get this to work?

Cheers,

Callum L.

-- 

Mintel Group Ltd | 11 Pilgrim Street | London | EC4V 6RN
Registered in England: Number 1475918. | VAT Number: GB 232 9342 72

Contact details for our other offices can be found at 
http://www.mintel.com/office-locations.

This email and any attachments may include content that is confidential, 
privileged 
or otherwise protected under applicable law. Unauthorised disclosure, 
copying, distribution 
or use of the contents is prohibited and may be unlawful. If you have 
received this email in error,
including without appropriate authorisation, then please reply to the 
sender about the error 
and delete this email and any attachments.


Re: Classes in solr_home /lib cannot import from solr/dist

Posted by Shawn Heisey <ap...@elyograg.org>.
On 1/15/2016 5:36 AM, Callum Lamb wrote:
> Good to know Solr already loads them, that removed a bunch of lines from my
> solrconfig.xml.
>
> Having to copy the required jars from dist/ to lib/ isn't ideal but if
> that's the only solution then at least I can stop searching for a solution
> and figure out how best to deal with this limitation.
>
> I assume the reason for this is that the libs in solr.home.home/lib are
> loaded at runtime? I don't know much about how this works in Java but i'm
> guessing Solr can access the classes in the Jars but not the other way
> around?

Classloaders in Java are a complex topic that I do not fully understand.

The contents of the $SOLR_HOME/lib directory are loaded by the main Solr
classloader before any cores are started, and all of the cores that get
started afterwards are able to use those classes.  If the core-level
classloader chooses to load one of the jars a second time, then there
can be problems.

Rather than try and understand all the complexities of class loading, I
find it better to simply place all the jars in the one location that
Solr loads automatically and take the decision away from the individual
cores.  It makes everything easier.

Thanks,
Shawn


Re: Classes in solr_home /lib cannot import from solr/dist

Posted by Callum Lamb <cl...@mintel.com>.
Good to know Solr already loads them, that removed a bunch of lines from my
solrconfig.xml.

Having to copy the required jars from dist/ to lib/ isn't ideal but if
that's the only solution then at least I can stop searching for a solution
and figure out how best to deal with this limitation.

I assume the reason for this is that the libs in solr.home.home/lib are
loaded at runtime? I don't know much about how this works in Java but i'm
guessing Solr can access the classes in the Jars but not the other way
around?

Thanks for your help guys.

On Thu, Jan 14, 2016 at 5:03 PM, Shawn Heisey <ap...@elyograg.org> wrote:

> On 1/14/2016 5:36 AM, Callum Lamb wrote:
> > I've got an extension jar that contains a class which extends from
> >
> > org.apache.solr.handler.dataimport.DataSource
> >
> > But it only works if it's within the solr/dist folder. However when
> stored
> > in the lib/ folder within Solr home. When it tries to load the class it
> > cannot find it's parent:
> >
> > Exception in thread "Thread-69" java.lang.NoClassDefFoundError:
> > org/apache/solr/handler/dataimport/DataSource
> >         at
> >
> org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:374)
> >         at
> >
> org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:102)
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.solr.handler.dataimport.DataSource
> >
> > The classes in the lib folder don't have access to the class within the
> > dist folder in their classpath when they are loaded.
> >
> > I'd like the keep my solr install separate from my
> configs/plugins/indexes
> > so I want to avoid putting it into the dist folder unless I absolutely
> have
> > to.
>
> If you're going to put jars in $SOLR_HOME/lib, then you should *only*
> put jars in that directory, and NOT load jars explicitly.  The <lib>
> directives should not be used in solrconfig.xml when jars are loaded
> from this directory, because Solr will automatically load jars from this
> location and make them available to all cores.
>
> If moving all your extra jars (including things like the dataimport jar)
> to $SOLR_HOME/lib and taking out jar loading in solrconfig.xml doesn't
> help, then depending on the Solr version, you *might* be running into
> SOLR-6188.
>
> https://issues.apache.org/jira/browse/SOLR-6188
>
> You'll want to be sure that you don't the same jar more than once.  This
> is the root of the specific problem that SOLR-6188 solves.  Loading the
> same jar more than once can also happen if the jar is in the lib
> directory AND mentioned on a <lib> config element.
>
> Thanks,
> Shawn
>
>

-- 

Mintel Group Ltd | 11 Pilgrim Street | London | EC4V 6RN
Registered in England: Number 1475918. | VAT Number: GB 232 9342 72

Contact details for our other offices can be found at 
http://www.mintel.com/office-locations.

This email and any attachments may include content that is confidential, 
privileged 
or otherwise protected under applicable law. Unauthorised disclosure, 
copying, distribution 
or use of the contents is prohibited and may be unlawful. If you have 
received this email in error,
including without appropriate authorisation, then please reply to the 
sender about the error 
and delete this email and any attachments.


Re: Classes in solr_home /lib cannot import from solr/dist

Posted by Shawn Heisey <ap...@elyograg.org>.
On 1/14/2016 5:36 AM, Callum Lamb wrote:
> I've got an extension jar that contains a class which extends from
>
> org.apache.solr.handler.dataimport.DataSource
>
> But it only works if it's within the solr/dist folder. However when stored
> in the lib/ folder within Solr home. When it tries to load the class it
> cannot find it's parent:
>
> Exception in thread "Thread-69" java.lang.NoClassDefFoundError:
> org/apache/solr/handler/dataimport/DataSource
>         at
> org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:374)
>         at
> org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:102)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.solr.handler.dataimport.DataSource
>
> The classes in the lib folder don't have access to the class within the
> dist folder in their classpath when they are loaded.
>
> I'd like the keep my solr install separate from my configs/plugins/indexes
> so I want to avoid putting it into the dist folder unless I absolutely have
> to.

If you're going to put jars in $SOLR_HOME/lib, then you should *only*
put jars in that directory, and NOT load jars explicitly.  The <lib>
directives should not be used in solrconfig.xml when jars are loaded
from this directory, because Solr will automatically load jars from this
location and make them available to all cores.

If moving all your extra jars (including things like the dataimport jar)
to $SOLR_HOME/lib and taking out jar loading in solrconfig.xml doesn't
help, then depending on the Solr version, you *might* be running into
SOLR-6188.

https://issues.apache.org/jira/browse/SOLR-6188

You'll want to be sure that you don't the same jar more than once.  This
is the root of the specific problem that SOLR-6188 solves.  Loading the
same jar more than once can also happen if the jar is in the lib
directory AND mentioned on a <lib> config element.

Thanks,
Shawn


Re: Classes in solr_home /lib cannot import from solr/dist

Posted by Callum Lamb <cl...@mintel.com>.
That's what I did:

My solrconfig.xml has the following (i've hardcoded the version numbers for
now to get regexes out of the picture):

<lib path="${solr.install.dir}/dist/solr-dataimporthandler-5.4.0.jar" />
<lib path="${solr.solr.home}/lib/ZKFileDataSource.jar" />

No warning's whatsoever for not finding the jars. And the jars themselves
are in the right order (the second depends on the first).

If i move the data import handler jar to the ${solr.solr.home}/lib/ folder
then everything works. This implies that the solr-dataimporthandler jar
isn't being included properly but I've checked so many times that it's
correct. I can do a full absolute path without the use of solr.install.dir
and solr.solr.home and it still does not work.

The permissions and ownership on the jar files are identical for the 2
jars, if it can load one then it should be able to load the other.




On Thu, Jan 14, 2016 at 2:19 PM, sara hajili <ha...@gmail.com> wrote:

> hi Callum.
> you can create a directory for your jar file any where,and u must set jar
> file location in <lib> tag in solrConfig.xml
> and be carefull that add your lib location at the end of the solr config
> default <lib> tag,
> because some times your jar need class that at first solr must be load own
> class after that load your jar to don't face a class not found exception.
>
>
> On Thu, Jan 14, 2016 at 4:36 AM, Callum Lamb <cl...@mintel.com> wrote:
>
> > I've got an extension jar that contains a class which extends from
> >
> > org.apache.solr.handler.dataimport.DataSource
> >
> > But it only works if it's within the solr/dist folder. However when
> stored
> > in the lib/ folder within Solr home. When it tries to load the class it
> > cannot find it's parent:
> >
> > Exception in thread "Thread-69" java.lang.NoClassDefFoundError:
> > org/apache/solr/handler/dataimport/DataSource
> >         at
> >
> >
> org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:374)
> >         at
> >
> >
> org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:102)
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.solr.handler.dataimport.DataSource
> >
> > The classes in the lib folder don't have access to the class within the
> > dist folder in their classpath when they are loaded.
> >
> > I'd like the keep my solr install separate from my
> configs/plugins/indexes
> > so I want to avoid putting it into the dist folder unless I absolutely
> have
> > to.
> >
> > Is this by design? Is there some kind of configuration somewhere I can
> > tweak to get this to work?
> >
> > Cheers,
> >
> > Callum L.
> >
> > --
> >
> > Mintel Group Ltd | 11 Pilgrim Street | London | EC4V 6RN
> > Registered in England: Number 1475918. | VAT Number: GB 232 9342 72
> >
> > Contact details for our other offices can be found at
> > http://www.mintel.com/office-locations.
> >
> > This email and any attachments may include content that is confidential,
> > privileged
> > or otherwise protected under applicable law. Unauthorised disclosure,
> > copying, distribution
> > or use of the contents is prohibited and may be unlawful. If you have
> > received this email in error,
> > including without appropriate authorisation, then please reply to the
> > sender about the error
> > and delete this email and any attachments.
> >
> >
>

-- 

Mintel Group Ltd | 11 Pilgrim Street | London | EC4V 6RN
Registered in England: Number 1475918. | VAT Number: GB 232 9342 72

Contact details for our other offices can be found at 
http://www.mintel.com/office-locations.

This email and any attachments may include content that is confidential, 
privileged 
or otherwise protected under applicable law. Unauthorised disclosure, 
copying, distribution 
or use of the contents is prohibited and may be unlawful. If you have 
received this email in error,
including without appropriate authorisation, then please reply to the 
sender about the error 
and delete this email and any attachments.


Re: Classes in solr_home /lib cannot import from solr/dist

Posted by sara hajili <ha...@gmail.com>.
hi Callum.
you can create a directory for your jar file any where,and u must set jar
file location in <lib> tag in solrConfig.xml
and be carefull that add your lib location at the end of the solr config
default <lib> tag,
because some times your jar need class that at first solr must be load own
class after that load your jar to don't face a class not found exception.


On Thu, Jan 14, 2016 at 4:36 AM, Callum Lamb <cl...@mintel.com> wrote:

> I've got an extension jar that contains a class which extends from
>
> org.apache.solr.handler.dataimport.DataSource
>
> But it only works if it's within the solr/dist folder. However when stored
> in the lib/ folder within Solr home. When it tries to load the class it
> cannot find it's parent:
>
> Exception in thread "Thread-69" java.lang.NoClassDefFoundError:
> org/apache/solr/handler/dataimport/DataSource
>         at
>
> org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:374)
>         at
>
> org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:102)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.solr.handler.dataimport.DataSource
>
> The classes in the lib folder don't have access to the class within the
> dist folder in their classpath when they are loaded.
>
> I'd like the keep my solr install separate from my configs/plugins/indexes
> so I want to avoid putting it into the dist folder unless I absolutely have
> to.
>
> Is this by design? Is there some kind of configuration somewhere I can
> tweak to get this to work?
>
> Cheers,
>
> Callum L.
>
> --
>
> Mintel Group Ltd | 11 Pilgrim Street | London | EC4V 6RN
> Registered in England: Number 1475918. | VAT Number: GB 232 9342 72
>
> Contact details for our other offices can be found at
> http://www.mintel.com/office-locations.
>
> This email and any attachments may include content that is confidential,
> privileged
> or otherwise protected under applicable law. Unauthorised disclosure,
> copying, distribution
> or use of the contents is prohibited and may be unlawful. If you have
> received this email in error,
> including without appropriate authorisation, then please reply to the
> sender about the error
> and delete this email and any attachments.
>
>