How to fix java RuntimeException: Can't find resource 'solrconfig.xml' in classpath?
I'm having issues setting up Solr as Tomcat service in CentOS. I’m using solr 3.3.0 which should be working with Tomcat 5.5 installed from cPanel. The error I was getting is:
Can't find resource 'solrconfig.xml' in classpath or '/home/sampleuser/public_html/apache-solr/example/solr/./conf/', cwd=/usr/local/jakarta/apache-tomcat-5.5.33/bin
I saw other people having similar issues. I googled and tried to apply all of the approaches. However nothing worked for me so far.
I did the following:
- Copied
solr.war
totomcat/webapps
- Restarted Tomcat Service
Edited
/usr/local/jakarta/tomcat/webapps/solr/WEB-INF/web.xml
as:<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>/home/sampleuser/public_html/apache-solr/example/solr</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
Created
solr.xml
in/usr/local/jakarta/tomcat/conf/Catalina/localhost
as:<?xml version="1.0" encoding="utf-8"?> <Context docBase="/usr/local/jakarta/tomcat/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/home/sampleuser/public_html/apache-solr/example"override="true"/> </Context>
Edited tomcat startup script at
etc/init.d
(not sure if I had to do it at all) with:
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/home/sampleuser/public_html/apache-solr/example/solr"
Below is the complete error log from catalina.err:
Oct 9, 2011 7:35:06 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Oct 9, 2011 7:35:06 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Oct 9, 2011 7:35:06 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Oct 9, 2011 7:35:06 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Oct 9, 2011 7:35:06 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Oct 9, 2011 7:35:06 PM org.apache.coyote.http11.Http11BaseProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Oct 9, 2011 7:35:21 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk/jre/lib/amd64/server:/usr/local/jdk/jre/lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Oct 9, 2011 7:35:23 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 9, 2011 7:35:23开发者_JS百科 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2875 ms
Oct 9, 2011 7:35:23 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 9, 2011 7:35:23 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.33
Oct 9, 2011 7:35:23 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Oct 9, 2011 7:35:24 PM org.apache.catalina.startup.HostConfig deployDescriptor
WARNING: A docBase /usr/local/jakarta/tomcat/webapps/solr.war inside the host appBase has been specified, and will be ignored
Oct 9, 2011 7:35:25 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: Using JNDI solr.home: /home/sampleuser/public_html/apache-solr/example/solr
Oct 9, 2011 7:35:25 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: Solr home set to '/home/sampleuser/public_html/apache-solr/example/solr/'
Oct 9, 2011 7:35:25 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: SolrDispatchFilter.init()
Oct 9, 2011 7:35:25 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: Using JNDI solr.home: /home/sampleuser/public_html/apache-solr/example/solr
Oct 9, 2011 7:35:25 PM org.apache.solr.core.CoreContainer$Initializer initialize
INFO: looking for solr.xml: /home/sampleuser/public_html/apache-solr/example/solr/solr.xml
Oct 9, 2011 7:35:25 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: Using JNDI solr.home: /home/sampleuser/public_html/apache-solr/example/solr
Oct 9, 2011 7:35:25 PM org.apache.solr.core.CoreContainer <init>
INFO: New CoreContainer: solrHome=/home/sampleuser/public_html/apache-solr/example/solr/ instance=1537767228
Oct 9, 2011 7:35:25 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: Solr home set to '/home/sampleuser/public_html/apache-solr/example/solr/'
Oct 9, 2011 7:35:26 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: Solr home set to '/home/sampleuser/public_html/apache-solr/example/solr/./'
Oct 9, 2011 7:35:26 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.RuntimeException: Can't find resource 'solrconfig.xml' in classpath or '/home/sampleuser/public_html/apache-solr/example/solr/./conf/', cwd=/usr/local/jakarta/apache-tomcat-5.5.33/bin
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:268)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:234)
at org.apache.solr.core.Config.<init>(Config.java:141)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:131)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:435)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:133)
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3666)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4258)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:634)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:561)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:496)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
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.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:219)
Oct 9, 2011 7:35:26 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: user.dir=/usr/local/jakarta/apache-tomcat-5.5.33/bin
Oct 9, 2011 7:35:26 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: SolrDispatchFilter.init() done
Oct 9, 2011 7:35:26 PM org.apache.solr.servlet.SolrServlet init
INFO: SolrServlet.init()
Oct 9, 2011 7:35:26 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: Using JNDI solr.home: /home/sampleuser/public_html/apache-solr/example/solr
Oct 9, 2011 7:35:26 PM org.apache.solr.servlet.SolrServlet init
INFO: SolrServlet.init() done
Oct 9, 2011 7:35:26 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: Using JNDI solr.home: /home/sampleuser/public_html/apache-solr/example/solr
Oct 9, 2011 7:35:26 PM org.apache.solr.servlet.SolrUpdateServlet init
INFO: SolrUpdateServlet.init() done
When I copy the missing path via shell I was able to navigate just fine. Seem like Tomcat cannot locate the solrconfig.xml
.
First off: you don't need to #3 and #4 and 5. #3 isn't really recommended unless you are explicitly customizing the solr.war. #4 and #5 are two different ways to do the same thing - use whichever one is most convenient for you (JNDI vs system properties)
Second: please note that while #3 and #5 are consistent, in #4 you actually specify a different Solr home dir (the parent dir of what you really want)
Third: I think the crux of your problem is file permissions.
The logging is a bit confusing due to SOLR-3264 which causes "instanceDirs" for each core to be refered to erroneously as "Solr Home" but what seems to be happening is that it can't find (or read) your "/home/sampleuser/public_html/apache-solr/example/solr/solr.xml" so it's going into legacy "Single Core" mode where it assumes that you want to use your Solr Home dir as an instanceDir for a (single) Solr Core -- so it then looks for "/home/sampleuser/public_html/apache-solr/example/solr/solrconf.xml" and if it can't find (or read) that file it gives up.
So depending on whether your main concern is that you actually have a solr.xml (pointing to alternate instanceDirs) hat it's not finding, or if you actually have a solrconfig.xml file where it's looking, check the file permissions of those files (and their directories), and make sure they are readable by the effective user of your tomcat server.
(FWIW: Solr 3.6 and up will have better logging when solr.xml is not found and legacy mode is used, and I've opened SOLR-3266 to pursue better ways of logging/erroring on unreadable files in the future)
精彩评论