Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.1.0
-
None
-
Linux, JBoss 5.1.0.GA, Sun JDK 1.6
Description
Documentation or code samples found from http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss about the use of Jackrabbit JCR RMI with JBoss are either obselete or unclear.
Here are the following steps I've performed in order to get a working JCR session with a standalone Java client from a remote (even if localhost is not so remote).
In jackrabbit-rmi-service.xml (to be in x-jcr-rmi.jar), I've edited two lines :
<attribute name="LocalAddress">_LOCAL_JNDI_NAME_TO_JCR_</attribute>
<attribute name="RemoteAddress">jnp://localhost:1099/aRemoteName</attribute>
Replace _LOCAL_JNDI_NAME_TO_JCR_ by the actual JNDI name the JCR repository was locally bound to within JBoss (value of <jndi-name> element in x-jcr-ds.xml JCA descriptor). Replace aRemoteName by wanted name for the RMI remote repository.
Then I've copied the x-jcr-rmi.jar in jboss main deploy directory ($JBOSS_HOME/server/default/deploy), and restarted JBoss.
Finally I use the following code in my standalone client (actually a testing one) :
import javax.naming.InitialContext;
import javax.jcr.Repository;
import javax.jcr.Session;
import org.apache.jackrabbit.rmi.remote.RemoteRepository;
import org.apache.jackrabbit.rmi.client.ClientAdapterFactory;
[...]
ClientAdapterFactory caf = new ClientAdapterFactory();
InitialContext ctx = new InitialContext();
RemoteRepository rr = (RemoteRepository) ctx.lookup("jnp://localhost:1099/aRemoteName");
Repository repo = caf.getRepository(rr);
Session s = repo.login(...);