Saturday, February 1, 2014

Solr with Websphere Commerce Server 6.0

Solr doesn't run out of the box on Websphere Application Server because does not support Java 5. The minimum version for Running Solar is WAS 6.1.x, cause WAS 6.0 doesn't support Java 5.
There are things needs required modifications for the apache-solr-1.3.0.war or latest solr version on WAS-6. This modifications should work with all versions of the the WAS 6.1 series.

Enabling Java 5 for JSP pages

Cause WAS-6.x is a J2EE 1.4 container, it doesn't support Java 5. We have to explicit enable Java 5 for the JSP compiler. To do this, we've got to create (or modify) 2 files:

  • WEB-INF/ibm-web-bnd.xmi
  • WEB-INF/ibm-web-ext.xmi
in ibm-web-bnd.xmi
<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1213147492785" virtualHostName="default_host">
  <webapp href="WEB-INF/web.xml#WebApp_ID"/>
</webappbnd:WebAppBinding>

in ibm-web-bnd.xmi

<?xml version="1.0" encoding="UTF-8"?>
<webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappext="webappext.xmi" xmi:id="WebAppExtension_1213147492785" reloadInterval="3" reloadingEnabled="true" additionalClassPath="" fileServingEnabled="true" directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="true">
  <webApp href="WEB-INF/web.xml#WebApp_ID"/>
  <jspAttributes xmi:id="JSPAttribute_1" name="jdkSourceLevel" value="15"/>
</webappext:WebAppExtension>

Adding index.jsp to Welcome File List

In the apache-solr-1.3.0.war or latest version, there is now welcome file section. WebSphere doesn't handle index.jsp as auto welcome file, so we've got to modify the web.xml to get a page displayed. Add the 'welcome-file' section add the bottom of the web.xml file.
web.xml.

Enable remote JMX monitoring on WebSphere and register Solr MBeans.

When you try to access Solr on WAS (with <jmx/> config enabled in solrconfig.xml) it fails to register beans (query, facet, etc) and throws"javax.management.InstanceAlreadyExitsException. We need to add following System property to your server (Application servers > server > Process definition > Java Virtual Machine > Custom properties)

javax.management.builder.initial=javax.management.MBeanServerBuilder

Restart the server and now WAS should not throw exception. To confirm that beans have been registered successfully make sure that you have following line in your logs.

org.apache.solr.core.JmxMonitoredMap <init> JMX monitoring is enabled. Adding Solr mbeans to JMX Server:

Once the beans registered we can connect and access Solr configurations and statistics via JMX remotely by adding following System properties to server.

com.sun.management.jmxremote.port="any unused port number"
com.sun.management.jmxremote.authenticate=false
com.sun.management.jmxremote.ssl=false

Restart the server and now we can use tool like JConsole to connect and access Solr configurations and statistics remotely via JMX by specifying the hostname and port.