Solr with JBoss

Optional Configuration

URI Charset Config (only needed before Solr 4.1)

(warning) Solr4.1 Solr now parses request parameters (in URL or sent with POST using content-type application/x-www-form-urlencoded) in its dispatcher code. It no longer relies on special configuration settings in JBoss or other web containers to enable UTF-8 encoding, which is mandatory for correct Solr behaviour.

Solr now works out of the box with e.g. Tomcat, JBoss,...

In older Solr versions (before Solr4.1), you have to change the container's default URI encoding: Edit JBoss's server/default/deploy/jbossweb-tomcat55.sar/server.xml and add the following attribute to the correct Connector element: URIEncoding="UTF-8". If you're using JBoss v4.0 or above, then the file is located at: server/default/deploy/jboss-web-deployer/server.xml

<Server ...>
 <Service ...>
   <Connector ... URIEncoding="UTF-8"/>
     ...
   </Connector>
 </Service>
</Server>

This is only an issue when sending non-ascii characters in a query request... no configuration is needed for Solr/Tomcat to return non-ascii chars in a response, or accept non-ascii chars in an HTTP-POST body.

SNMP Monitoring

For more information on Using SNMP with Solr in JBoss please see SolrSnmp

Configuring Solr Home

You can configure the Solr home directory globally via -Dsolr.solr.home in the file bin/run.bat. But that is often not desired because you potentially want more than one Solr installation deployed.

Solr Home via web.xml

You can configure the Solr home directory to use per webapp in Solr's web.xml file. Add following snippet to the web.xml:

  <env-entry>
    <env-entry-name>solr/home</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>C:\Projects\solr-trunk\example\solr</env-entry-value>
  </env-entry>

Solr Home via properties-service.xml

You can also configure it (and other Solr variables, such as the Solr-data-dir) in properties-service.xml like so:

<mbean code="org.jboss.varia.property.SystemPropertiesService" name="jboss:type=Service,name=SystemProperties">
  <attribute name="Properties">
    solr.solr.home=C:/jboss-X/server/default/conf/solr
    solr.data.dir=C:/solr/data
  </attribute>
</mbean>

JBoss Logging

By default JBoss uses Log4J for its logging, while the default Solr installation uses the SLF4J binding to log via the JDK1.4 logging system. In order to get Solr to log via Log4J, you must replace the slf4j-jdk*.jar binding with the slf4j-log4j*.jar binding. From that point on, logging can be configured via the log4j.xml configuration file.

For example, this can be used to silence all the INFO messages from Solr:

<category name="org.apache.solr"> 
  <priority value="WARN"/>
</category>

Troubleshooting

If you encounter the error "statements are only available if source level is 5.0" then you have to edit the file server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml.

Comment in the block

<init-param>
   <param-name>compilerSourceVM</param-name>
   <param-value>1.5</param-value>
</init-param>

JBoss 5

Solr (1.3) (* TODO: should test with 1.4 too*) works fine in JBoss 5, but you should remove the following jars:

from the WEB-INF/lib folder of solr.war

Since JBoss ships with its own version, solr will use the lib provided by JBoss 5.

You can even remove all the libs in WEB-INF/lib and put in server/{yourinstance}/lib if you want to deploy multiple instances of solr.

Logging should work without the steps declared in JBoss Logging section.

JBoss 6 and Solr 3.3

In order for the solr.war deployment to work:

JBoss 7 and Solr 4.0-ALPHA

You can add solr.solr.home and solr.data.dir in "Profile => System Properties".

UTF-8

Add org.apache.catalina.connector.URI_ENCODING to the system properties and set the value to UTF-8 so queries with UTF-8 characters (for example Umlaute) work.