jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gamba <holger.bre...@handelshof.de>
Subject Re: ERROR [EventStateCollection] Unable to resolve path for item ...
Date Fri, 18 Sep 2009 11:33:23 GMT

Thx for the hint with the UUIDs.

Sure, I totally agree with you it could be an concurrency problem, because
I'm not able ro reproduce this exceptions at the moment. During the tests
some other excpetions occurs e.g "inactive logical session handle called" or 

 javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist
resource, see the previous warnings. tx=TransactionImple < ac, BasicAction:
a11359c:48a:4ab35912:269d status: ActionStatus.ABORT_ONLY >	at
org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:759)
at ...

So, indeed, it looks like a concurrency problem. But I have a
singleton-instance which should be thread-safe (only one access-point to
jcr) and I did not expect such a behaviour. Here is the singleton code:

public final class SessionSingleton
{
	private final static Logger	log	= Logger.getLogger(SessionSingleton.class);

	// Made final so singleton will be read-only
	private final static SessionSingleton	instance;

	// Static initializer
	static {
		try {
			// Perform initialization here
			instance = new SessionSingleton();
			
			if (log.isDebugEnabled()) {
				log.debug("New SessionSingleton Instance created ...");
			}
		}
		catch (Throwable e) {
			throw new RuntimeException(e.getMessage());
		}
	}

	// private construktor
	private SessionSingleton()
	{}

	// get Singleton-Instance
	public static SessionSingleton getInstance() {
		if (log.isDebugEnabled()) {
			System.out.println("Retrieving SessionSingleton instance ...");
		}
		return instance;
	}

	// -----
	// Methods for JCR-Access
	// -----
	public void createFolderNode(String path, String name, Repository
repository)
		throws HMGJCRException, RepositoryException
	{
		synchronized (instance) {
			Session session = null;
			Node lastNodeInTree = null;

			try {
				// JackRabbit Zugriff über JNDI
				session = repository.login(new SimpleCredentials("user", 
                                    "pwd".toCharArray()), "default");

				Node rootNode = session.getRootNode();
				lastNodeInTree = rootNode.getNode(path);
				Node addedNode = null;

				if (!lastNodeInTree.hasNode(name)) {
					addedNode = lastNodeInTree.addNode(name);
				}
				else {
					throw new HMGJCRException("Folder " + name + " in path " + path + " 
                                           already existis");
				}

				if (log.isInfoEnabled()) {
					log.info("Folder " + name + " in path " + path + " added by Thread  : "
+ 
                                           
Thread.currentThread().getName());
				}

				session.save();
			}
			finally {
				if (session != null) {
					session.logout();
					session = null;
				}
			}
		}
	}

	public void deleteFolderNode(String path, Repository repository)
		throws RepositoryException
	{
		synchronized (instance) {
			Session session = null;
			Node oldNode = null;

			try {
				// JackRabbit Zugriff über JNDI
				session = repository.login(new SimpleCredentials("user",
                                  "pwd".toCharArray()), "default");

				Node rootNode = session.getRootNode();

				if (rootNode.hasNode(path)) {
					oldNode = rootNode.getNode(path);
					// oldNode.lock(true, true);
					oldNode.remove();
			
					if (log.isInfoEnabled()) {
						log.info("Folder " + path + " deleted by Thread: " +
                                                 
Thread.currentThread().getName());
					}
				}
				else {
					if (log.isInfoEnabled()) {
						log.info("Folder " + path + " not found by Thread: " + 
                                                 
Thread.currentThread().getName());
					}
				}

				session.save();
			}
			finally {
				if (session != null) {
					session.logout();
					session = null;
				}
			}
		}
	}
}

Regards,
Gamba

-- 
View this message in context: http://www.nabble.com/ERROR--EventStateCollection--Unable-to-resolve-path-for-item-...-tp25505035p25507216.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message