jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jain.sudhan...@indiatimes.com
Subject How to unlock jcr repository or to access repository through JNDI
Date Wed, 12 Mar 2008 11:08:44 GMT
Hi,

I want to know how to unlock the Jackrabbit repository
which is build during deployement of "jackrabbit-webapp-1.4.war" 
it create repository at tomcat/bin directory with the name of jackrabbit and create repository.xml
file.

I want to access this repository through JNDI 



sample program:-


package com.hcl.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 {
	
	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();
	}
	}
	
	
	

	private static Repository getRepository() throws Exception {

		
		
		
		
		String configFile = "C:/Tomcat/bin/jackrabbit/repository.xml";
		String repHomeDir = "C:/Tomcat/bin/jackrabbit";
			
		System.out.println("get Rep");
		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");

	}
	
	
	
}


It cause error 


get Rep
org.apache.jackrabbit.core.config.ConfigurationException: Configuration file could not be
read.: Connection timed out: connect: Connection timed out: connect
	at org.apache.jackrabbit.core.config.ConfigurationParser.parseXML(ConfigurationParser.java:551)
	at org.apache.jackrabbit.core.config.ConfigurationParser.parseRepositoryConfig(ConfigurationParser.java:200)
	at org.apache.jackrabbit.core.config.RepositoryConfig.create(RepositoryConfig.java:140)
	at org.apache.jackrabbit.core.config.RepositoryConfig.create(RepositoryConfig.java:83)
	at org.apache.jackrabbit.core.jndi.BindableRepository.init(BindableRepository.java:127)
	at org.apache.jackrabbit.core.jndi.BindableRepository.create(BindableRepository.java:115)
	at org.apache.jackrabbit.core.jndi.RegistryHelper.registerRepository(RegistryHelper.java:56)
	at com.hcl.test.TestTomcatRepository.getRepository(TestTomcatRepository.java:63)
	at com.hcl.test.TestTomcatRepository.main(TestTomcatRepository.java:21)
Caused by: java.net.ConnectException: Connection timed out: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.Socket.connect(Socket.java:516)
	at java.net.Socket.connect(Socket.java:466)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
	at sun.net.www.http.HttpClient.New(HttpClient.java:287)
	at sun.net.www.http.HttpClient.New(HttpClient.java:299)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:796)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:748)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:673)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:917)
	at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at org.apache.jackrabbit.core.config.ConfigurationParser.parseXML(ConfigurationParser.java:542)
	... 8 more
java.net.ConnectException: Connection timed out: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.Socket.connect(Socket.java:516)
	at java.net.Socket.connect(Socket.java:466)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
	at sun.net.www.http.HttpClient.New(HttpClient.java:287)
	at sun.net.www.http.HttpClient.New(HttpClient.java:299)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:796)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:748)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:673)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:917)
	at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at org.apache.jackrabbit.core.config.ConfigurationParser.parseXML(ConfigurationParser.java:542)
	at org.apache.jackrabbit.core.config.ConfigurationParser.parseRepositoryConfig(ConfigurationParser.java:200)
	at org.apache.jackrabbit.core.config.RepositoryConfig.create(RepositoryConfig.java:140)
	at org.apache.jackrabbit.core.config.RepositoryConfig.create(RepositoryConfig.java:83)
	at org.apache.jackrabbit.core.jndi.BindableRepository.init(BindableRepository.java:127)
	at org.apache.jackrabbit.core.jndi.BindableRepository.create(BindableRepository.java:115)
	at org.apache.jackrabbit.core.jndi.RegistryHelper.registerRepository(RegistryHelper.java:56)
	at com.hcl.test.TestTomcatRepository.getRepository(TestTomcatRepository.java:63)
	at com.hcl.test.TestTomcatRepository.main(TestTomcatRepository.java:21)


can you please help me to rectify this



Mime
View raw message