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
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 '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN' 'http://java.sun.com/dtd/connector_1_0.dtd'> <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>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-connector PUBLIC
'-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Connector 1.0//EN'
'http://www.sun.com/software/sunone/appserver/dtds/sun-connector_1_0-0.dtd'>
<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>
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
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>