You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Stefan Guggisberg (JIRA)" <ji...@apache.org> on 2007/05/18 16:46:16 UTC

[jira] Commented: (JCR-919) java.nio.channels.OverlappingFileLockException

    [ https://issues.apache.org/jira/browse/JCR-919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496895 ] 

Stefan Guggisberg commented on JCR-919:
---------------------------------------

the issue's twofold:
  
-  looking at the code it seems like the repository instance 
   is not shutdown after the first run. hence the exception thrown 
   in the second run. note that you can't concurrently instantiate 
   2 repositories which use the same or identical configuration.

   the following code snippet will throw an exception on the last
   line:

            Repository rep1 = new TransientRepository();
            Session s1 = rep1.login(new SimpleCredentials("johndoe", "".toCharArray()));
            Repository rep2 = new TransientRepository();
            Session s2 = rep2.login(new SimpleCredentials("johndoe", "".toCharArray()));

- the 'real' issue is that the wrong, i.e. an unchecked exception is thrown. 
  a RepositoryException should be thrown instead. this is already covered by 
  JCR-912.
  

> java.nio.channels.OverlappingFileLockException
> ----------------------------------------------
>
>                 Key: JCR-919
>                 URL: https://issues.apache.org/jira/browse/JCR-919
>             Project: Jackrabbit
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.3
>         Environment: WINDOWS XP/JDK1.6/Tomacat Apache
>            Reporter: CHANDAN KUMAR
>         Assigned To: Stefan Guggisberg
>
> I am running Tomcat apache 6.0 in windows XP. I am trying to access Transient repository. 
> In very first run, I am able to open and close session for Transient repository. but in the next run, it always throws exception "java.nio.channels.OverlappingFileLockException".
> To resolve that issue(workaround)  I have to restart the apache server. In case of very first run, I am able to read/write from/to repository. 
> code snippet used: ( wrapper calls to class to session open and close)
> import java.io.OutputStream;
> import javax.jcr.Repository;
> import javax.jcr.Session;
> import javax.jcr.SimpleCredentials;
> import org.apache.jackrabbit.core.TransientRepository;
> public class jackrabbitPlugin 
> {
> 	public static Session session;
> 	public static int SUCCESS =0;
> 	public static int FAILURE =-1;
> 	private int isOpened = 0;
> 	public String errMsg;
> 	private Repository repository = null;
> 	
> 	public String logout() 
> 	{
> 		String retValue = "SUCCESS";
> 		try
> 		{
> 			session.logout();
> 		}
> 		catch(Exception exp)
> 		{
> 			retValue = "Exception:" + exp;
> 		}
> 		return retValue;
> 	}
> 	public String login (String user,String password, String RepositoryPath,String workspaceName) 
> 	{
> 		String retValue = "SUCCESS";
> 		if(workspaceName.compareTo("")==0)
> 		{
> 			workspaceName="default";
> 		}
> 		try 
> 		{
> 			if(IsSessionOpen()==false)
> 			{
> 				System.setProperty("org.apache.jackrabbit.repository.home",RepositoryPath);
> 				repository = new TransientRepository();
> 				session = repository.login(new SimpleCredentials(user,password.toCharArray()),workspaceName);
> 				if(session!=null)
> 				{
> 					retValue = "SUCCESS";
> 					isOpened = 1;
> 				}
> 			}
> 		}
> 		catch (Exception exp) 
> 		{
> 			String errMsg = "Exception:" + exp;
> 			retValue = errMsg;
> 			System.out.println(errMsg);
> 			((TransientRepository)repository).shutdown();
> 			logout();
> 			this.errMsg =  errMsg;
> 		} 
> 		return retValue;
> 	}
> 		
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.