You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by krispyjala <kr...@yahoo.com> on 2006/12/08 03:53:37 UTC

Re: Problems with repository initialization.

Hi all,
   Does anyone have any clue to this?  I am also running into the same error
and I can't get anywhere.  Same as Joan, there is no .lock file when I start
my repository but when I wrote code to try to get the jcr session it's
saying that the .lock file is locked by another process.  But the thing is I
have only one repository! How can this be?

Thank you for any help you can give,
KJ



Joan Fisbein wrote:
> 
> I have a JackRabit JCR reporsitory in Spring Project.
> 
> When I try to start the aplication I get the following exception:
> 
> 
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'repository' defined in ServletContext resource
> [/WEB-INF/XXXShop-JCR.xml]: Initialization of bean failed; nested
> exception is javax.jcr.RepositoryException: The repository home at
> C:\Desarrollo\Billing\workspace\XXXShop\target\web\repo appears to be in
> use since the file at
> C:\Desarrollo\Billing\workspace\XXXShop\target\web\repo\.lock is locked
> by another process.
> javax.jcr.RepositoryException: The repository home at
> C:\Desarrollo\Billing\workspace\XXXShop\target\web\repo appears to be in
> use since the file at
> C:\Desarrollo\Billing\workspace\XXXShop\target\web\repo\.lock is locked
> by another process.
>      at
> org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock(RepositoryImpl.java:322)
>      at
> org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:197)
>      at
> org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:483)
>      [...]
> 
> 
> (before launching the application there's not .lock file in the repo
> folder)
> 
> 
> This is my context configuration:
> <bean id="sessionFactory" class="org.springmodules.jcr.JcrSessionFactory">
>      <property name="repository" ref="repository" />
>      <property name="credentials">
>          <bean class="javax.jcr.SimpleCredentials">
>              <constructor-arg index="0" value="bogus" />
>              <constructor-arg index="1">
>                  <bean factory-bean="password"
> factory-method="toCharArray" />
>              </constructor-arg>
>          </bean>
>      </property>
> </bean>
> 
> <!-- create the password to return it as a char[] -->
> <bean id="password" class="java.lang.String">
>      <constructor-arg index="0" value="pass" />
> </bean>
> 
> <!-- configuring the default repository -->
> <!-- normal factory beans params -->
> <bean id="repository"
> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
>      <property name="configuration" value="classpath:repository.xml" />
>      <property name="homeDir" value="/repo" />
> </bean>
> 
> 
> If I use a TransientRepositoryFactoryBean instead of
> RepositoryFactoryBean it works, but I want to have an instance of the
> repository all the time ready for the JCR operaions.
> 
> Attached is my repository.xml
> 
> 
> In this thread in the Spring Forum one of the maintainers says that the
> issue is related to jackrabit.
> 
> http://forum.springframework.org/showthread.php?t=28592
> 
> What am I doing wrong?
> 
> 
> Thanks in advance.
> 
> 
> <?xml version="1.0"?>
> <!DOCTYPE Repository [
>     <!--
>         the Repository element configures a repository instance;
>         individual workspaces of the repository are configured through
>         separate configuration files called workspace.xml which are
>         located in a subfolder of the workspaces root directory
>         (see Workspaces element).
> 
>         it consists of
> 
>             a FileSystem element (the virtual file system
>             used by the repository to persist global state such as
>             registered namespaces, custom node types, etc..
> 
>             a Security element that specifies the name of the app-entry
>             in the JAAS config and the access manager
> 
>             a Workspaces element that specifies to the location of
>             workspaces root directory and the name of default workspace
> 
>             a Workspace element that is used as a workspace configuration
>             template; it is used to create the initial workspace if
> there's
>             no workspace yet and for creating additional workspaces
> through
>             the api
> 
>             a Versioning element that is used for configuring
>             versioning-related settings
> 
>             a SearchIndex element that is used for configuring
> Indexing-related
>             settings on the /jcr:system tree.
>     -->
>     <!ELEMENT Repository
> (FileSystem,Security,Workspaces,Workspace,Versioning,SearchIndex?)>
> 
>     <!--
>         a virtual file system
>     -->
>     <!ELEMENT FileSystem (param*)>
>     <!ATTLIST FileSystem
>       class CDATA #REQUIRED>
> 
>     <!--
>         the Security element specifies the name (appName attribute)
>         of the JAAS configuration app-entry for this repository. 
> 
>         it also specifies the access manager to be used (AccessManager
> element).
>     -->
>     <!ELEMENT Security (AccessManager, LoginModule?)>
>     <!ATTLIST Security
>       appName CDATA #REQUIRED>
> 
>     <!--
>         the AccessManager element configures the access manager to be used
> by
>         this repository instance; the class attribute specifies the FQN of
> the
>         class implementing the AccessManager interface
>     -->
>     <!ELEMENT AccessManager (param*)>
>     <!ATTLIST AccessManager
>       class CDATA #REQUIRED>
> 
>     <!--
>         generic parameter (name/value pair)
>     -->
>     <!ELEMENT param EMPTY>
>     <!ATTLIST param
>       name CDATA #REQUIRED
>       value CDATA #REQUIRED>
> 
>      <!--
>         the LoginModule element optionally specifies a JAAS login module
> to
>         authenticate users. This feature allows the use of Jackrabbit in a
>         non-JAAS environment.
>     -->
>     <!ELEMENT LoginModule (param*)>
>     <!ATTLIST LoginModule
>       class CDATA #REQUIRED>
> 
>    <!--
>         the Workspaces element specifies the workspaces root directory
>         (rootPath attribute) and the name of the default workspace
>         (defaultWorkspace attribute).
> 
>         individual workspaces are configured through individual
> workspace.xml
>         files located in a subfolder each of the workspaces root
> directory.
>     -->
>     <!ELEMENT Workspaces EMPTY>
>     <!ATTLIST Workspaces
>       rootPath CDATA #REQUIRED
>       defaultWorkspace CDATA #REQUIRED>
> 
>     <!--
>         the Workspace element serves as a workspace configuration
> template;
>         it is used to create the initial workspace if there's no workspace
> yet
>         and for creating additional workspaces through the api
>     -->
>     <!ELEMENT Workspace (FileSystem,PersistenceManager,SearchIndex?)>
>     <!ATTLIST Workspace
>       name CDATA #REQUIRED>
> 
>     <!--
>         the PersistenceManager element configures the persistence manager
>         to be used for the workspace; the class attribute specifies the
>         FQN of the class implementing the PersistenceManager interface
>     -->
>     <!ELEMENT PersistenceManager (param*)>
>     <!ATTLIST PersistenceManager
>       class CDATA #REQUIRED>
> 
>     <!--
>         the SearchIndex element specifies the locaction of the search
> index
>         (used by the QueryHandler); the class attribute specifies the
>         FQN of the class implementing the QueryHandler interface.
>     -->
>     <!ELEMENT SearchIndex (param*,FileSystem?)>
>     <!ATTLIST SearchIndex
>       class CDATA #REQUIRED>
> 
>     <!--
>         the Versioning element configures the persistence manager
>         to be used for persisting version state
>     -->
>     <!ELEMENT Versioning (FileSystem, PersistenceManager)>
>     <!ATTLIST Versioning
>       rootPath CDATA #REQUIRED
>     >
> ]>
> <!-- Example Repository Configuration File -->
> <Repository>
> 	<!--
> 		virtual file system where the repository stores global state
> 		(e.g. registered namespaces, custom node types, etc.)
> 	-->
> 	<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> 		<param name="path" value="${rep.home}/repository" />
> 	</FileSystem>
> 
> 	<!--
> 		security configuration
> 	-->
> 	<Security appName="Jackrabbit">
> 		<!--
> 			access manager:
> 			class: FQN of class implementing the AccessManager interface
> 		-->
> 		<AccessManager
> class="org.apache.jackrabbit.core.security.SimpleAccessManager">
> 			<!-- <param name="config" value="${rep.home}/access.xml"/> -->
> 		</AccessManager>
> 
> 		<LoginModule
> class="org.apache.jackrabbit.core.security.SimpleLoginModule">
> 			<!-- anonymous user name ('anonymous' is the default value) -->
> 			<param name="anonymousId" value="anonymous" />
> 			<!--
> 				default user name to be used instead of the anonymous user
> 				when no login credentials are provided (unset by default)
> 			-->
> 			<!-- <param name="defaultUserId" value="superuser"/> -->
> 		</LoginModule>
> 	</Security>
> 
> 	<!--
> 		location of workspaces root directory and name of default workspace
> 	-->
> 	<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"
> />
> 	<!--
> 		workspace configuration template:
> 		used to create the initial workspace if there's no workspace yet
> 	-->
> 	<Workspace name="${wsp.name}">
> 		<!--
> 			virtual file system of the workspace:
> 			class: FQN of class implementing the FileSystem interface
> 		-->
> 		<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> 			<param name="path" value="${wsp.home}" />
> 		</FileSystem>
> 		<!--
> 			persistence manager of the workspace:
> 			class: FQN of class implementing the PersistenceManager interface
> 		-->
> 
> 		<!-- 
> 			<PersistenceManager
> class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
> 			<param name="url" value="jdbc:derby:${wsp.home}/db;create=true" />
> 			<param name="schemaObjectPrefix" value="${wsp.name}_" />
> 		</PersistenceManager>
> 		-->
> 
> 		<PersistenceManager
> class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
> 			<param name="driver" value="com.mysql.jdbc.Driver" />
> 			<param name="url" value="jdbc:mysql://localhost/fonjcr" />
> 			<param name="schema" value="mysql" />
> 			<param name="schemaObjectPrefix" value="${wsp.name}_" />
> 			<param name="externalBLOBs" value="true" />
> 			<param name="user" value="fon" />
> 			<param name="password" value="fon" />
> 		</PersistenceManager>
> 
> 		<!--Search index and the file system it uses. class: FQN of class
> implementing the QueryHandler interface -->
> 		<SearchIndex
> class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
> 			<param name="path" value="${wsp.home}/index" />
> 		</SearchIndex>
> 	</Workspace>
> 
> 	<!--
> 		Configures the versioning
> 	-->
> 	<Versioning rootPath="${rep.home}/version">
> 		<!--
> 			Configures the filesystem to use for versioning for the respective
> 			persistence manager
> 		-->
> 		<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> 			<param name="path" value="${rep.home}/version" />
> 		</FileSystem>
> 
> 		<!--
> 			Configures the persistence manager to be used for persisting version
> state.
> 			Please note that the current versioning implementation is based on
> 			a 'normal' persistence manager, but this could change in future
> 			implementations.
> 		-->
> 		<!--
> 		<PersistenceManager
> class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
> 			<param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"
> />
> 			<param name="schemaObjectPrefix" value="version_" />
> 		</PersistenceManager>
> 		-->
> 
> 		<PersistenceManager
> class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
> 			<param name="driver" value="com.mysql.jdbc.Driver" />
> 			<param name="url" value="jdbc:mysql://localhost/fonjcr" />
> 			<param name="schema" value="mysql" />
> 			<param name="schemaObjectPrefix" value="version_" />
> 			<param name="externalBLOBs" value="true" />
> 			<param name="user" value="fon" />
> 			<param name="password" value="fon" />
> 		</PersistenceManager>
> 	</Versioning>
> 
> 	<!--
> 		Search index for content that is shared repository wide
> 		(/jcr:system tree, contains mainly versions)
> 	-->
> 	<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
> 		<param name="path" value="${rep.home}/repository/index" />
> 	</SearchIndex>
> </Repository>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-repository-initialization.-tf2184034.html#a7751926
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problems with repository initialization.

Posted by krispyjala <kr...@yahoo.com>.
Thanks for replying Jukka.  I found the culprit of my problem.  It turns out
we are using multiple applicationContext-*.xml to define our
spring/hibernate definitions, and I defined all the repository settings in
applicationContext-service.xml.  Now, there are other context files that
import applicationContext-service.xml and that's why there's always the
.lock file--the repository's getting initialized twice.  I corrected the
problem by using a separate context file that doesn't import anything and
now it works like a charm.  And yes turning on spring log to DEBUG level
really helps in debugging this problem :)

Cheers,
Kris.



Jukka Zitting wrote:
> 
> Hi,
> 
> On 12/8/06, krispyjala <kr...@yahoo.com> wrote:
>> Does anyone have any clue to this?  I am also running into the same error
>> and I can't get anywhere.  Same as Joan, there is no .lock file when I
>> start
>> my repository but when I wrote code to try to get the jcr session it's
>> saying that the .lock file is locked by another process.  But the thing
>> is I
>> have only one repository! How can this be?
> 
> The problem is most likely that you have more than one Repository
> instance around. Either you have a separate JVM that has an open
> repository running on the same directory, or you already have another
> repository instance in the same JVM.
> 
> Check that the repository is defined as a singleton bean in Spring,
> and that you've defined the bean only once. If that doesn't help, you
> may want to monitor the .lock file or your logs to better understand
> when and why the first repository instance is created.
> 
> BR,
> 
> Jukka Zitting
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-repository-initialization.-tf2184034.html#a7797181
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Problems with repository initialization.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 12/8/06, krispyjala <kr...@yahoo.com> wrote:
> Does anyone have any clue to this?  I am also running into the same error
> and I can't get anywhere.  Same as Joan, there is no .lock file when I start
> my repository but when I wrote code to try to get the jcr session it's
> saying that the .lock file is locked by another process.  But the thing is I
> have only one repository! How can this be?

The problem is most likely that you have more than one Repository
instance around. Either you have a separate JVM that has an open
repository running on the same directory, or you already have another
repository instance in the same JVM.

Check that the repository is defined as a singleton bean in Spring,
and that you've defined the bean only once. If that doesn't help, you
may want to monitor the .lock file or your logs to better understand
when and why the first repository instance is created.

BR,

Jukka Zitting