jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikolaj Rydzewski <m...@ceti.pl>
Subject Exporting repositories with RMI
Date Fri, 15 Sep 2006 10:40:51 GMT
Hello,

I want to export a Repository with RMI. So I gathered bot 
jackrabbit-core and jackrabbit-jcr-rmi stuff and (of course) have some 
problems. Could you please point me to the right direction?

When I run the sample code it throws the following exception:
Exception in thread "main" java.rmi.server.ExportException: object 
already exported
        at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:172)
        at sun.rmi.transport.Transport.exportObject(Transport.java:75)
        at 
sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:190)
        at 
sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:382)
        at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:116)
        at 
sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:180)
        at 
java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
        at 
java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:235)
        at jackrabbit.rmiserver.Server.main(Server.java:27)


My server code:

public class Server {

    public static void main(String[] args) throws Exception {
       
        Repository repository = getRepository();
        RemoteRepository remoteRepository = getRemoteRepository(repository);
       
        RemoteRepository stub = 
(RemoteRepository)UnicastRemoteObject.exportObject(remoteRepository, 0);
        Registry registry = LocateRegistry.getRegistry();
        registry.bind("rmi_repo", stub);
       
        System.out.println("Server ready");
       
    }

    private static RemoteRepository getRemoteRepository(Repository 
repository) throws RemoteException {
        RemoteAdapterFactory factory = new ServerAdapterFactory();
        RemoteRepository remote = factory.getRemoteRepository(repository);
        return remote;
    }

    private static Repository getRepository() throws NamingException, 
RepositoryException {
        String configFile = "repotest/repository.xml";
        String repHomeDir = "repotest";

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
        env.put(Context.PROVIDER_URL, "localhost");
        InitialContext ctx = new InitialContext(env);
        RegistryHelper.registerRepository(ctx,
               "repo",
                configFile,
                repHomeDir,
                true);
        Repository r = (Repository)ctx.lookup("repo");
        return r;
    }

}


-- 
Mikolaj Rydzewski <miki@ceti.pl>


Mime
View raw message