jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jain.sudhan...@indiatimes.com
Subject Issue :- Access jackrabbit-webapp-1.4.war through JNDI
Date Thu, 13 Mar 2008 12:36:44 GMT
Hi All,

I have deployed "jackrabbit-webapp-1.4.war" in tomcat server at runtime its create repository
at tomcat/bin directory with the name of jackrabbit at  tomcat/bin directory.I have two option
to get this repository object by my java client program .

Scenerio 1 is working fine but  in scenerio 2 i stuck to resolve out .please help to rectify
it.

scenerio 1 ::- 

Through RMI its work 

 //This set in the web.xml of the repository

String repoUrl = "//localhost:1099/jackrabbit-webapp-1.4/rmi";

Repository repository = factory.getRepository(repoUrl);

Scenerio 2:-


I want to access this repository through JNDI (NOT Working)

It cause an error 

org.apache.jackrabbit.core.config.ConfigurationException: Configuration file could not be
read.: Connection timed out: connect: Connection timed out: connect

please guide me, how to rectify it.

Java Client sample program:-


package com.test;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Hashtable;

import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.apache.jackrabbit.core.jndi.RegistryHelper;

public class TestTomcatRepository {

	private static Repository getRepository() throws Exception {
	
	String configFile = "C:/Tomcat/bin/jackrabbit/repository.xml";
	String repHomeDir = "C:/Tomcat/bin/jackrabbit";
	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, "jackrabbit.repository", configFile, repHomeDir,true);
		return (Repository) ctx.lookup("jackrabbit.repository");

	}

	
	public static void main(String[] args) {
	try {
		Repository repository = getRepository();
		System.out.println("Test1.main() repository "+repository);
		SimpleCredentials creds = new SimpleCredentials("admin",
				"admin".toCharArray());
		Session session = repository.login(creds);
		Node root = session.getRootNode();
		Node test1 = root.addNode("delhi");
	        Node test2 = test1.addNode("bombay");
	        test2.setProperty("message", "bangalore");
	        
	        session.exportDocumentView("/", new FileOutputStream(new File("C://xyz.xml")), false,
false);

		
	} catch (Exception e) {
		e.printStackTrace();
	}
	}
	
	}






can you please help me to rectify this




Mime
View raw message