Running Apache Solr on JBoss

Off late, I’ve been doing a lot of development with Railo running on JBoss. So naturally, I wanted to plug in Apache Solr (which now ships with ColdFusion 9) into my JBoss instance running Railo.

What I thought would be straight-forward took a bit to figure out. The issue comes when you have to setup the solr.home property. The Apache Solr wiki suggests putting an <env-entry> node in the web.xml. However, if you do that, the XML does not validate as “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”. JBoss 5 is a little particular about web.xml validating properly — which is a good thing!

So the trick to declare Solr home variable is to do this:

Add the following to conf/jboss-service.xml

<!-- For Apache Solr -->
<mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="jboss.tests:service=JNDIBindingServiceMgr">
      <attribute name="BindingsConfig" serialDataType="jbxb">
         <jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:jndi="urn:jboss:jndi-binding-service:1.0" xs:schemaLocation="urn:jboss:jndi-binding-service:1.0resource:jndi-binding-service_1_0.xsd">
            <jndi:binding name="solr/home">
                <jndi:value type="java.lang.String">FILESYSTEM_PATH_TO_SOLR_HOME</jndi:value>
            </jndi:binding>
         </jndi:bindings>
      </attribute>
 </mbean>

Replace FILESYSTEM_PATH_TO_SOLR_HOME in the above node to the actual physical filesystem path where Solr home for your application lives, e.g., in my case it was: /Users/indy/solr/

Add the following node to the application specific WEB-INF/web.xml:

<resource-env-ref>
     <resource-env-ref-name>solr/home</resource-env-ref-name>
     <resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>

And finally create a WEB-INF/jboss-web.xml file (if it already does not exist for your web application) and add the following content to it:

<jboss-web>
	<context-root>solr</context-root>
	<resource-env-ref>
		<resource-env-ref-name>solr/home</resource-env-ref-name>
		<jndi-name>/solr/home</jndi-name>
	</resource-env-ref>
</jboss-web>

Once done, browse to your app: http://yourserver:port/solr/ and you should see Apache Solr running. Obviously you need to make sure that the Solr home directory contains the appropriate XML descriptors for Solr configuration.

1 thought on “Running Apache Solr on JBoss”

  1. Without “jboss:service=Naming“, it can cause “name=jboss:service=JNDIBindingServiceMgr state=Create mode=Manual requiredState=Installed” error,

    So,
    The changes in conf/jboss-service.xml should be as follows:


    jboss:service=Naming



    FILESYSTEM_PATH_TO_SOLR_HOME



Comment on this blog post...