title: How to fix java RuntimeException: Can't find resource 'solrconfig.xml' in classpath?
body: <p>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: </p>
  
  <blockquote>
    <p>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 </p>
  </blockquote>
  
  <p>I saw other people having similar issues. I googled and tried to apply all of the approaches. However nothing worked for me so far. </p>
  
  <p>I did the following: </p>
  
  <ol>
  <li>Copied <code>solr.war</code> to <code>tomcat/webapps</code></li>
  <li>Restarted Tomcat Service </li>
  <li><p>Edited <code>/usr/local/jakarta/tomcat/webapps/solr/WEB-INF/web.xml</code> as: </p>
  
  <pre><code>&lt;env-entry&gt;
   &lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;
   &lt;env-entry-value&gt;/home/sampleuser/public_html/apache-solr/example/solr&lt;/env-entry-value&gt;
   &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
  &lt;/env-entry&gt;
  </code></pre></li>
  <li><p>Created <code>solr.xml</code> in <code>/usr/local/jakarta/tomcat/conf/Catalina/localhost</code> as: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
  &lt;Context docBase="/usr/local/jakarta/tomcat/webapps/solr.war" debug="0" crossContext="true"&gt;
    &lt;Environment name="solr/home" type="java.lang.String"    
         value="/home/sampleuser/public_html/apache-solr/example"override="true"/&gt;
  &lt;/Context&gt;
  </code></pre></li>
  <li><p>Edited tomcat startup script at <code>etc/init.d</code> (not sure if I had to do it at all) with:</p></li>
  </ol>
  
  <p><code>export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/home/sampleuser/public_html/apache-solr/example/solr"</code></p>
  
  <p>Below is the complete error log from catalina.err: </p>
  
  <pre><code>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 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 &lt;init&gt;
  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 &lt;init&gt;
  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 &lt;init&gt;
  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 &lt;init&gt;
  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.&lt;init&gt;(Config.java:141) 
          at org.apache.solr.core.SolrConfig.&lt;init&gt;(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.&lt;init&gt;(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 
  </code></pre>
  
  <p>When I copy the missing path via shell I was able to navigate just fine. Seem like Tomcat cannot locate the <code>solrconfig.xml</code>.</p>