I am wrapping CoreContainer in my own class (FacetServerImpl), so that I can
override the query(SolrRequest request) method to return an xml String. This
is the best way I found to get an xml response from Solr, without deploying
solr as a service, note that EmbeddedSolrServer returns a NamedList.

My application works fine in JUnit tests, creating a CoreContainer and
getting a SolrCore object as listed below. However when I try to deploy
FacetServerImpl.class to a web container (JBoss) I get a
java.lang.NoClassDefFoundError for SolrIndexReader, (See Stack Trace below).
I am instantiating MyServerImpl using Spring's ContextLoaderListener when
deploying my application. I have the apache-solr-core-nightly.jar (which
contains SolrIndexReader.class) in the WEB-INF/lib directory on my
application.

I have also tried putting apache-solr-core-nightly.jar in the lib directory
under Solr Home. When I do this, the stack trace prints that it loads the
apache-solr-core-nightly.jar, but still fails due to the
NoClassDefFoundError found above, I have also included this StackTrace. I
have also tried making CoreContainer a Spring managed bean, but the same
Exception is thrown. Making CoreContainer a Spring managed bean may allow me
to pass in in a ClassLoader but I'm not sure if this is the right approach
to solve the problem.

How can I make the apache-solr-core-nightly.jar available to
ContextLoaderListener during bootstrapping of my Web Application?


     //these are String parameters retrieved from my solr.properties
argument
     coreContainer = createContainer(solrHome, configFilename, dataDir,
solrSchema);  

    private CoreContainer createContainer(String solrHome, String
configFilename, String dataDir, String solrSchema) {
        CoreContainer container = getCoreContainer();
        SolrCore core = core(solrHome, configFilename, dataDir, solrSchema,
container);
        container.register(CORE_NAME, core, false);
        return container;
    }

    private CoreContainer getCoreContainer() {
        String dir = SolrResourceLoader.locateInstanceDir();
        SolrResourceLoader loader = new SolrResourceLoader(dir);
        return new CoreContainer(loader);
    }

    private SolrCore core(String solrHome, String configFilename, String
dataDir, String solrSchema, CoreContainer container) {
        SolrConfig solrConfig = createSolrConfig(solrHome, configFilename);
        CoreDescriptor descriptor = descriptor(container);
        IndexSchema schema = new IndexSchema(solrConfig, solrSchema, null);
        return new SolrCore(CORE_NAME, dataDir, solrConfig, schema,
descriptor);
    }

Exception Stack Trace:
2009-03-03 17:13:31,774 INFO  [org.apache.solr.core.SolrResourceLoader]
Reusing parent classloader
2009-03-03 17:13:32,332 ERROR
[org.springframework.web.context.ContextLoader] Context initialization
failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'net.fct.pct.facet.importer.DataImporterImpl#0'
defined in URL
[jar:file:/home/sheperdj/work/pct_facet_web2/procat-web/gen/jboss/jboss-eap-4.3/jboss-as/server/production/tmp/deploy/tmp7114744926167161286pct-exp.war/WEB-INF/lib/procat-facet.jar!/applicationContext-facet.xml]:
Unsatisfied dependency expressed through constructor argument with index 0
of type [net.fct.pct.facet.server.FacetServer]: Error creating bean with
name 'net.fct.pct.facet.server.FacetServerImpl#0' defined in URL
[jar:file:/home/sheperdj/work/pct_facet_web2/procat-web/gen/jboss/jboss-eap-4.3/jboss-as/server/production/tmp/deploy/tmp7114744926167161286pct-exp.war/WEB-INF/lib/procat-facet.jar!/applicationContext-facet.xml]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [net.fct.pct.facet.server.FacetServerImpl]: Constructor threw
exception; nested exception is java.lang.NoClassDefFoundError:
org/apache/solr/search/SolrIndexReader

StackTrace with apache-solr-core-night.jar in solr.home/lib directory
2009-03-03 17:58:15,350 INFO  [org.apache.solr.core.SolrResourceLoader] Solr
home set to '/opt/procat/solr/'
2009-03-03 17:58:15,351 INFO  [org.apache.solr.core.SolrResourceLoader]
Adding 'file:/opt/procat/solr/lib/apache-solr-core-nightly.jar' to Solr
classloader
2009-03-03 17:58:15,351 INFO  [org.apache.solr.core.SolrResourceLoader]
Adding 'file:/opt/procat/solr/lib/apache-solr-solrj-nightly.jar' to Solr
classloader
2009-03-03 17:58:15,352 INFO  [org.apache.solr.core.SolrResourceLoader]
Adding 'file:/opt/procat/solr/lib/apache-solr-cell-nightly.jar' to Solr
classloader
2009-03-03 17:58:15,353 INFO  [org.apache.solr.core.SolrResourceLoader]
Adding 'file:/opt/procat/solr/lib/apache-solr-dataimporthandler-nightly.jar'
to Solr classloader
2009-03-03 17:58:16,265 ERROR
[org.springframework.web.context.ContextLoader] Context initialization
failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'net.fct.pct.facet.importer.DataImporterImpl#0'
defined in URL
[jar:file:/home/sheperdj/work/pct_facet_web2/procat-web/gen/jboss/jboss-eap-4.3/jboss-as/server/production/tmp/deploy/tmp4998059991089383325pct-exp.war/WEB-INF/lib/procat-facet.jar!/applicationContext-facet.xml]:
Unsatisfied dependency expressed through constructor argument with index 0
of type [net.fct.pct.facet.server.FacetServer]: Error creating bean with
name 'net.fct.pct.facet.server.FacetServerImpl#0' defined in URL
[jar:file:/home/sheperdj/work/pct_facet_web2/procat-web/gen/jboss/jboss-eap-4.3/jboss-as/server/production/tmp/deploy/tmp4998059991089383325pct-exp.war/WEB-INF/lib/procat-facet.jar!/applicationContext-facet.xml]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [net.fct.pct.facet.server.FacetServerImpl]: Constructor threw
exception; nested exception is java.lang.NoClassDefFoundError:
org/apache/solr/search/SolrIndexReader

applicationContext snippet
    <bean class="net.fct.pct.facet.server.FacetServerImpl">
        <constructor-arg ref="solr.properties"/>
    </bean>
-- 
View this message in context: 
http://www.nabble.com/Can-find-solr-jars-in-WEB-INF-lib-directory-tp22304076p22304076.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to