[ https://issues.apache.org/jira/browse/SOLR-17297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847147#comment-17847147 ]
David Smiley commented on SOLR-17297: ------------------------------------- Interesting. SolrResourceLoader.addToClassLoader has a clear contract in its javadocs that it MUST only be called prior to using to get any resources. Yet I suspect the underlying class loader here has already loaded stuff, based on your description. bq. Switching setupSharedLib and initModules might work too (haven't tested) My thoughts exactly. Try that :-) FWIW where I work, our Lucene PostingsFormat/Codec level stuff goes into WEB-INF/lib because we ran into issues with it in sharedLib. I'm glad to see you've looked closely at the matter. > Classloading issue with plugin and modules > ------------------------------------------ > > Key: SOLR-17297 > URL: https://issues.apache.org/jira/browse/SOLR-17297 > Project: Solr > Issue Type: Bug > Security Level: Public(Default Security Level. Issues are Public) > Components: SolrCloud > Affects Versions: 9.3 > Reporter: Patson Luk > Priority: Critical > > h2. Summary > Using plugin jar and enabling any modules could trigger > {{java.lang.ClassNotFoundException}} > h2. Description > 1. An implementation of {{org.apache.lucene.codecs.PostingsFormat}} with the > jar within the <solr install dir>/lib > 2. Enable modules in solr.xml for example <str > name="modules">opentelemetry</str> > 3. Now on startup. As a part of {{NodeConfig#setupSharedLib}}, it would load > all the SPIs, it locates our jar and loads the class with a > {{FactoryURLClassLoader}} with the classpaths point at the jar of the lib, > which is correct > 4. After {{NodeConfig#setupSharedLib}}, {{NodeConfig#initModules}} is > invoked, which eventually calls {{SolrResourceLoader#addURLsToClassLoader}} > that closes the previous class loader, which is the one used in 3. > 5. Now a core is loaded with that codec, it runs the <init> code which > references other classes within our plugin jar, but unfortunately it would > use the Classloader that loads our class in step 3., and such loader is > marked as "closed" hence no longer load the correct resource/class. This > triggers ClassNotFoundException. > I have tried several things, the only thing that seems to work so far is > commenting out {{IOUtils.closeWhileHandlingException(oldLoader);}} in > {{SolrResourceLoader#addURLsToClassLoader}}, which is likely not the right > workaround as the {{closeWhileHandlingException}} should be there for a > reason ;) > Switching {{setupSharedLib}} and {{initModules}} might work too (haven't > tested), but I don't want to try any weird changes since I don't really know > the ordering significance. > Would appreciate some helps from the Solr experts! :) -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org