jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anil K. Kotha" <An...@2xprime.com>
Subject RE: JCR RMI: how to connect to remote repository ?
Date Mon, 16 Jun 2008 12:03:37 GMT
Hi Frederic,
	You can connect to the remote repository using the following
code.

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String username = "username";
		String password = "password";
		String privider_url = "host:1099";
		String ctxLookup = "jnp://host:1099/jcrServer";

		Hashtable<String, String> env = new Hashtable<String,
String>();
		env
				.put(Context.INITIAL_CONTEXT_FACTORY,
	
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
		env.put(Context.PROVIDER_URL, privider_url);
		env
				.put(Context.URL_PKG_PREFIXES,
	
"org.jboss.naming:org.jnp.interfaces");
		InitialContext ctx;

		try {
			ctx = new InitialContext(env);
			RemoteRepository remoteRepository =
(RemoteRepository) ctx
					.lookup(ctxLookup);
			Session session = null;
			try {
				JackrabbitServerAdapterFactory
adapterFactory = new JackrabbitServerAdapterFactory();
				
				
				ClientAdapterFactory adapter = new
ClientAdapterFactory();
				Repository repository =
adapter.getRepository(remoteRepository);
				
				session = repository.login(new
SimpleCredentials(username,
	
password.toCharArray()));
				
			}catch (Exception e) {
				e.printStackTrace();
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
			
	}

Cheers,
Anilk.

-----Original Message-----
From: Frederic BOY [mailto:frederic.v4x@gmail.com] 
Sent: Monday, June 16, 2008 3:33 PM
To: users@jackrabbit.apache.org
Subject: JCR RMI: how to connect to remote repository ?

Hi,

I have successfully managed to deploy my JCR repository RMI on
jnp://localhost:1099/jcrServer (thanks to jackrabbit JCR RMI).
Now how can I access it remotely ?

I mean I used to call:
	repository = (Repository) ctx.lookup("java:jcr/local");
for standard local jndi lookup.

When I try to replace it with:  
	repository = (Repository)
ctx.lookup("jnp://{remote_ip_address}:1099/jcrServer");

I get a java.lang.ClassCastException:
org.apache.jackrabbit.rmi.server.ServerRepository_Stub


I guess I'm missing a point. What's the right method ?

Thanks guys in advance,

Frederic Boy


Mime
View raw message