Jackrabbit on Sun App Server 7

Following on from my earlier post about how to get Jackrabbit working on WebSphere, I also faced some difficulties getting Jackrabbit to run with Sun App Server 7. I think a lot of the difficulties stem from the fact that App Server 7 had a very early implementation of the connector specification – the later versions of the app server seem to be a lot easier to set up. So here is what worked for me:

1) Configure Endorsed Libraries

Before you can deploy on Sun App Server 7 you need to configure the server instance to use a newer version of the SAX parser rather than the one built into JDK1.4. To do this carry out the following steps:

  • In the admin console, click the server instance you want to deploy under
  • Click the JVM Setting tab
  • Click the JVM Options link
  • In the blank JVM Option box at the top, enter:
  •    -Djava.endorsed.dirs=<server_root>/lib/endorsed
    

    Where <server_root> is the path of your server instance directory

  • Apply the changes to the instance
  • Now create an endorsed directory in the server’s lib directory (matching the path specified above
  • Copy recent version of xercesImpl.jar and xalan.jar into your new endorsed directory

You can get more information about ‘endorsed’ libraries here:
http://java.sun.com/j2se/1.4.2/docs/guide/standards/
http://wiki.apache.org/cocoon/EndorsedLibsProblem

2) Edit resource adapter deployment descriptors

Because App Server 7 only supports version 1.0 of the connector spec you will need to edit your ra.xml deployment descriptor slightly to make it deploy. Also, there is no way of configuring your connector in the admin console, so you need to include all the relevant config in the ra.xml and sun-ra.xml files.

So, to make it work with app server 7, carry out the following steps:

  • Download the jackrabbit-jca-1.3.rar file from the jackrabbit site (or the latest version if newer)
  • Unzip the contents to a directory
  • Find the ra.xml file inside the META-INF directory
  • Edit it to read as follows:
  •    <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE connector PUBLIC
            &#039;-//Sun Microsystems, Inc.//DTD Connector 1.0//EN&#039;
            &#039;http://java.sun.com/dtd/connector_1_0.dtd&#039;>
        <connector>
          <display-name>Jackrabbit JCR Adapter</display-name>
          <vendor-name>Apache.org</vendor-name>
          <spec-version>>1.0</spec-version>
          <eis-type>JCR Adapter</eis-type>
          <version>>1.0</version>
          <license>
            <description>ASF</description>
            <license-required>false</license-required>
          </license>
          <resourceadapter>
            <managedconnectionfactory-class>org.apache.jackrabbit.jca.JCAManagedConnectionFactory
                </managedconnectionfactory-class>
            <connectionfactory-interface>javax.jcr.Repository</connectionfactory-interface>
            <connectionfactory-impl-class>org.apache.jackrabbit.jca.JCARepositoryHandle
                </connectionfactory-impl-class>
            <connection-interface>javax.jcr.Session</connection-interface>
            <connection-impl-class>org.apache.jackrabbit.jca.JCASessionHandle
                </connection-impl-class>
            <transaction-support>XATransaction</transaction-support>
            <config-property>
              <config-property-name>HomeDir</config-property-name>
              <config-property-type>java.lang.String</config-property-type>
              <config-property-value> Your repository home directory here
                  </config-property-value>
            </config-property>
            <config-property>
              <config-property-name>ConfigFile</config-property-name>
              <config-property-type>java.lang.String</config-property-type>
              <config-property-value> Your repository config file here
                  </config-property-value>
            </config-property>
            <reauthentication-support>false</reauthentication-support>
          </resourceadapter>
        </connector>
    
  • Now, create a sun-ra.xml file in the same directory containing the following:
  •     <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE sun-connector PUBLIC
              &#039;-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Connector 1.0//EN&#039;
              &#039;http://www.sun.com/software/sunone/appserver/dtds/sun-connector_1_0-0.dtd&#039;>
        <sun -connector>
          <resource -adapter jndi-name=" Your JNDI Name Here " max-pool-size="20" steady-pool-size="2"
              max-wait-time-in-millis="300000" idle-timeout-in-seconds="5000">
          </resource>
        </sun>
    
  • Now, re-zip the directory and name it jackrabbit-jca-1.3.rar (or whatever the original filename was)

3) Deploy the resource adapter

  • In the admin console, select the sever instance you want, and click Applications > Connector Modules
  • Click Deploy
  • Click browse, locate your newly edited rar file and click OK
  • On the next page make sure the name you give the app matches the JNDI name you configured in sun-ra.xml, click OK
  • You will probably also have to copy the jar files that were included in the rar file into the server’s lib directory
  • Restart your server instance

4) Make use of your repository

  • You should now be able to make use of your repository using code something like this:
  • InitialContext  ctx = new InitialContext ();
    repository = (Repository) ctx.lookup(" Your JNDI Name Here ");
    SimpleCredentials cred = new SimpleCredentials("login","password".toCharArray());
    Session session = repository.login(cred, null);
    Workspace workspace = session.getWorkspace();
    

    Potential Problems

    I thought I would mention some of the problems I had setting this up so you can avoid making similar mistakes.

    Firstly, make sure your repository.xml is correct, and especially make sure that you have the LoginModule element included – something like:

            <loginmodule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
                    <param name="anonymousId" value="anonymous"/>
            </loginmodule>
    

    Leave a Reply