或者如何设置一个solr.solr.home系统属性?给下面的代码用。
     if( home == null ) {
        String prop = "solr.solr.home";
        home = normalizeDir(System.getProperty(prop));
        if( home != null ) {
          log.info("using system property solr.home: " + home );
        }
      }原SOLR资料地址:http://www.cnblogs.com/abob/archive/2007/08/05/844193.aspx

解决方案 »

  1.   

    Tomcat的JNDI有bug,时灵时不灵,把我搞得半死。。还是避免用JNDI吧,非要用的话,改用weblogic
      

  2.   

    这是一个完整的context片段,你可以在Apache Software Foundation\Tomcat 5.0\conf\Catalina\localhost\创建一个solr.xml文件,然后复制进去。把CSDNOne换成你的Web名,把jdbc/db2DataSource换成你要建的jndi名,root,password不用我说了吧,都改,还有url,
    说了这么多,记着给分,卖血呀!
    <Context path="/CSDNOne" docBase="CSDNOne"
            debug="5" reloadable="true" crossContext="true">
      <Logger className="org.apache.catalina.logger.FileLogger"
                 prefix="localhost_DBTest_log." suffix=".txt"
                 timestamp="true"/>
      <Resource name="jdbc/db2DataSource"
                   auth="Container"
                   type="javax.sql.DataSource"/>
      <ResourceParams name="jdbc/db2DataSource">
        <parameter>
          <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>

        <!-- Maximum number of dB connections in pool. Make sure you
             configure your mysqld max_connections large enough to handle
             all of your db connections. Set to 0 for no limit.
             -->
     
        <parameter>
          <name>maxActive</name>
          <value>100</value>
        </parameter>

        <!-- Maximum number of idle dB connections to retain in pool.
             Set to 0 for no limit.
             -->
     
        <parameter>
          <name>maxIdle</name>
          <value>30</value>
        </parameter>

        <!-- Maximum time to wait for a dB connection to become available
             in ms, in this example 10 seconds. An Exception is thrown if
             this timeout is exceeded.  Set to -1 to wait indefinitely.
             -->
     
        <parameter>
          <name>maxWait</name>
          <value>10000</value>
        </parameter>

        <!-- MySQL dB username and password for dB connections  -->

        <parameter>
         <name>username</name>
         <value>root</value>
        </parameter>
        <parameter>
         <name>password</name>
         <value>123456</value>
        </parameter>

        <!-- Class name for mm.mysql JDBC driver -->

        <parameter>
           <name>driverClassName</name>
           <value>org.gjt.mm.mysql.Driver</value>
        </parameter>

        <!-- The JDBC connection url for connecting to your MySQL dB.
             The autoReconnect=true argument to the url makes sure that the
             mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
             connection.  mysqld by default closes idle connections after 8 hours.
             -->
     
        <parameter>
          <name>url</name> <value>jdbc:mysql://localhost:3306/CSDNOne?autoReconnect=true</value>
        </parameter>
      </ResourceParams>
    </Context>
    ________________________________________
    访问时用:
    Context initContext = new InitialContext();
    //在tomcat中配置的数据源名jdbc\db2DataSource
    Context envContext = (Context)initContext.lookup("java:comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/db2DataSource");
      

  3.   

    已经搞定 有两种办法:
    1。tomcat配置jndi
    <Context docBase="f:/solr.war" debug="0" crossContext="true" >
       <Environment name="solr/home" type="java.lang.String"
    value="f:/my/solr/home" override="true" />
    </Context>
    2.tomcat配置系统属性
    set JAVA_OPTS="-Dsolr.solr.home=D:\\test\\solr"