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 bbarani <bb...@gmail.com> on 2013/05/30 00:27:11 UTC
java.lang.IllegalAccessError when invoking protected method from
another class in the same package path but different jar.
Hi,
I am overriding the query component and creating a custom component. I am
using _responseDocs from org.apache.solr.handler.component.ResponseBuilder
to get the values. I have my component in same package
(org.apache.solr.handler.component) to access the _responseDocs value.
Everything works fine when I run the test for this component but I am
getting the below error when I package the custom component in a jar and
place it in lib directory (inside solr/lib - using basic jetty
configuration).
I assume this is due to the fact that different class loaders load different
class at runtime. Is there a way to resolve this?
<str name="msg">java.lang.IllegalAccessError: tried to access field
org.apache.solr.handler.component.ResponseBuilder._responseDocs from class
org.apache.solr.handler.component.WPFastDistributedQueryComponent</str><str
name="trace">java.lang.RuntimeException: java.lang.IllegalAccessError: tried
to access field
org.apache.solr.handler.component.ResponseBuilder._responseDocs from class
org.apache.solr.handler.component.CustomComponent
at
org.apache.solr.servlet.SolrDispatchFilter.sendError(SolrDispatchFilter.java:670)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:380)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155)
at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at
org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalAccessError: tried to access field
org.apache.solr.handler.component.ResponseBuilder._responseDocs from class
org.apache.solr.handler.component.WPFastDistributedQueryComponent
at
org.apache.solr.handler.component.WPFastDistributedQueryComponent.handleResponses(WPFastDistributedQueryComponent.java:131)
at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:311)
at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1816)
at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:656)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:359)
... 26 more
--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-IllegalAccessError-when-invoking-protected-method-from-another-class-in-the-same-package-p-tp4066904.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: java.lang.IllegalAccessError when invoking protected method
from another class in the same package path but different jar.
Posted by bbarani <bb...@gmail.com>.
Hoss, thanks a lot for the explanation.
We override most of the methods of query
component(prepare,handleResponses,finishStage etc..) to incorporate custom
logic and we set the _responseDocs values based on custom logic (after
filtering out few data) and then we call the parent(super) method(query
component) with the modified responsedocs. Thats the main reason we are
using the _responsedocs variable as is..
--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-IllegalAccessError-when-invoking-protected-method-from-another-class-in-the-same-package-p-tp4066904p4067086.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: java.lang.IllegalAccessError when invoking protected method from
another class in the same package path but different jar.
Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: java.lang.IllegalAccessError when invoking protected method from
: another class in the same package path but different jar.
...
: I am overriding the query component and creating a custom component. I am
: using _responseDocs from org.apache.solr.handler.component.ResponseBuilder
: to get the values. I have my component in same package
_responseDocs is not "protected" it is "package-private" which is why you
can't access it from a subclass in another *runtime* pacakge. Even if
you put your custom component in the same org.apache.solr... package
namespace, the runtime package is determined by the ClassLoader combined
with the source package...
http://www.cooljeff.co.uk/2009/05/03/the-subtleties-of-overriding-package-private-methods/
...this is helpful to ensure plugins don't attempt to do tihngs they
shouldn't.
In general, the ResponseBuilder class internals aren't very friendly in
terms of allowing custom components to interact with the intermediate
results of other built in components -- it's primarily designed arround
letting other internal Solr components share data with eachother in
(hopefully) well tested ways. Note that there is even a specific comment
one line directly above the declaration of _responseDocs that alludes to
it and several other variables being deliberately package-private...
/* private... components that don't own these shouldn't use them */
SolrDocumentList _responseDocs;
StatsInfo _statsInfo;
TermsComponent.TermsHelper _termsHelper;
SimpleOrderedMap<List<NamedList<Object>>> _pivots;
If you want access to the SolrDocumentList containing the query results,
the only safe way/time to do that is by fetching it out of the response
(ResponseBuilder.rsp) after the QueryComponent has put it there in it's
finishStage -- untill then ResponseBuilder._responseDocs may not be
correct (ie: distribute search, grouped search, etc...)
-Hoss
Re: java.lang.IllegalAccessError when invoking protected method
from another class in the same package path but different jar.
Posted by bbarani <bb...@gmail.com>.
My assumptions were right :)!!!!
I was able to fix this error by copying all my custom jar inside
webapp/web-inf/lib directory and everything started working !!!!
--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-IllegalAccessError-when-invoking-protected-method-from-another-class-in-the-same-package-p-tp4066904p4066906.html
Sent from the Solr - User mailing list archive at Nabble.com.