Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with Solr 3.6.0, 3.6.1, and 4.0 #2

Closed
nolanlawson opened this issue Jan 18, 2013 · 5 comments
Closed

Incompatibility with Solr 3.6.0, 3.6.1, and 4.0 #2

nolanlawson opened this issue Jan 18, 2013 · 5 comments
Labels

Comments

@nolanlawson
Copy link
Member

This may turn into a super-bug, but let's hope not.

First off, there is a problem accessing the queryFields private variable, which was fixed by this commit. Other problems abound, though, as detailed in these WordPress comments.

First off, there's this guy:

SEVERE: java.lang.IllegalAccessError: class org.apache.solr.search.SynonymExpand
ingExtendedDismaxQParser cannot access its superclass org.apache.solr.search.Ext
endedDismaxQParser

Then there's this guy:

————————— java.lang.IllegalAccessError: class 
org.apache.solr.search.SynonymExpandingExtendedDismaxQParser cannot access its 
superclass org.apache.solr.search.ExtendedDismaxQParser at 
java.lang.ClassLoader.defineClass1(Native Method) at 
java.lang.ClassLoader.defineClass(Unknown Source) at 
java.security.SecureClassLoader.defineClass(Unknown Source) at 
java.net.URLClassLoader.defineClass(Unknown Source) at 
java.net.URLClassLoader.access$100(Unknown Source) at

I can confirm seeing these same issues myself when I try to build using Solr 3.6.0 instead of 3.5.0.

Currently I'm still dumbfounded by these bugs. SynonymExpandingExtendedDismaxQParser is clearly a ExtendedDismaxQParser. It's even in the same package. So I have no idea why the class loader is complaining about this.

@nolanlawson
Copy link
Member Author

Comment from the blog post:

Nolan
I got it to work in run-time, and I want to just compliment you on how stunningly it works. I tested it with 3 word phrases and it broke it into single words, and then to ensure it finds the phrases exactly, I added quotes in the synonyms_extended.txt file. It worked like a charm.
How you ask?
I put the code for your synonym parser in with the rest of the actual Solr 3.5 source, and compiled the entire Solr source. Then I took that solr.war file and replaced my old one.
The issues that we keep seeing here, has to do with how Jetty, and Tomcat for that matter load the solr.war file, who is the envelope to the jars, and since the war file had no previous knowledge of the synonym parser being an extension of the QParser, well, you see the picture.
My next project is how to write it without needing to recompile solr.war, so that it’s just a synonymexpander.jar file I can drop into the lib folder, restart solr and be done and ready to go with the stock solr.war.
Oh yes, I also added a requestHandler to do the work, so my solr queries are clean like this localhost:8983/solr/ab/?q=shoes
explicit
xml
Hon Synonyms
synonym_edismax
*:*
30
*,score
2<-1 5<-2 6<90%
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4

true
myCoolAnalyzer
1.0
1.2
false
hope this helps
AB

@nolanlawson
Copy link
Member Author

OK, I finally managed to make some progress on this bug. According to this discussion, the problem is that the class files are loaded by multiple ClassLoaders, but classes in the same package should be loaded by the same ClassLoader.

Basically what you have to do is just make sure that the hon-lucene-synonyms-*.jar file is in the same directory as the apache-solr-core-*.jar file. So having the apache-solr-core file embedded in the solr.war file while the hon-lucene-synonyms.jar file is in the lib/ directory (in the example/ setup in Solr, for instance) will not work.

On the other hand, I'm still unable to get this to work in anything other than Tomcat. Tomcat runs beautifully, but Jetty (using the example/ settings) gives me this error:

SEVERE: org.apache.solr.common.SolrException: Error loading class 'org.apache.solr.search.SynonymExpandingExtendedDismaxQParserPlugin'
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:394)
    at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:419)
    at org.apache.solr.core.SolrCore.createInitInstance(SolrCore.java:441)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:1612)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:1606)
    at org.apache.solr.core.SolrCore.initPlugins(SolrCore.java:1639)
    at org.apache.solr.core.SolrCore.initQParsers(SolrCore.java:1556)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:555)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:480)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:332)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:216)
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:161)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mortbay.start.Main.invokeMain(Main.java:194)
    at org.mortbay.start.Main.start(Main.java:534)
    at org.mortbay.start.Main.start(Main.java:441)
    at org.mortbay.start.Main.main(Main.java:119)
Caused by: java.lang.ClassNotFoundException: org.apache.solr.search.SynonymExpandingExtendedDismaxQParserPlugin
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:627)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:378)
    ... 37 more

Exact same WAR file, exact same CWD, exact same everything. Tomcat works and Maven doesn't.

Even if I bundle apache-solr-core and hon-lucene-synonyms into the same WAR file, Jetty doesn't like it. Tomcat does, but not Jetty.

For the time being, I'm considering just adding separate builds for major Solr releases (3.5.0, 3.6.0, 3.6.1, 4.0.0, 4.1.0) and saying that this plugin only works with Tomcat. I'll also need to add better instructions for including the JAR file in with the WAR file, and maybe some better usage examples.

@nolanlawson
Copy link
Member Author

That's Tomcat 6.0.26 and Jetty jetty-6.1-SNAPSHOT, by the way.

@nolanlawson
Copy link
Member Author

Actually, it looks like Jetty shows the error but still works anyway. Weird.

@nolanlawson
Copy link
Member Author

This bug doesn't seem to have anything to do with the Solr version, and seems to rather depend on where the JAR file is placed relative to the Solr JAR files. I've tested with Solr 3.5.0, 3.6.1, and 3.6.2, I've tested in Jetty and Tomcat, I've built separate versions of the JAR file for 5 different versions of Solr, and plus I've added a "Getting Started" tutorial to the README: https://github.com/healthonnet/hon-lucene-synonyms/blob/master/README.md#getting-started .

I'm hoping that's enough to consider this bug squashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant