I´ve solved the problem... It´s embarrasing to admit, but spring's autowire
functionality got me this time.

I am also using Hibernate, and springs was injecting hibernate sessionFacty
in another bean that needed JCR sessionFactory...

Now everithing works fine

On 2/14/07, dj mamana <[EMAIL PROTECTED]> wrote:

Hi, I have a strange problem wich ends in RepositoryExpception because of
the .lock file in the repository when running the application in Tomcat.

Then I could reproduce the error in a TestCase, here is the description of
the problem.

The application has a Dao layer and a Service layer, the acces to the
repository is done at the Dao layer. Then the services consumes the Daos
(everithing is wired with Spring)

I use RepositoryFactoryBean and the strange part is that when I run the
tests (usign Spring´s AbstractDependencyInjectionSpringContextTests) of the
dao layer everithing works fine, but then I have another test from the
service layer I got RepositoryException becasuse of the .lock file.

The test of the service layer is very simple, it has injected a
UserService class wich has injected a Dao from the Dao layer (the same Dao
that works fine in the Dao test)

In the log of the bean factory it is like the repository is beign started
or instantiated more than once, but it is defined as a singleton.

I´ve checked the spring configuration and it doent't seem to be wrong

¿What the problem could be?

Here I post the configuration files


[code]
<?xml version="1.0 " encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd
">

<beans default-autowire="byName">

    <bean id="jcrSessionFactory"
        class="org.springmodules.jcr.JcrSessionFactory">
        <property name="repository" ref="jcrRepository" />
        <property name="credentials">
            <bean class="javax.jcr.SimpleCredentials">
                <constructor-arg index="0" value="defaultuser" />
                <constructor-arg index="1" value="secret" />
            </bean>
        </property>
    </bean>

    <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
        <property name="sessionFactory" ref="jcrSessionFactory" />
        <property name="allowCreate" value="false" />
    </bean>

    <!-- configuring the default repository -->
    <bean id="jcrRepository"
        class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean"
singleton="true" destroy-method="shutdown">
        <property name="configuration" value="classpath:repository.xml" />
        <property name="homeDir" value=" file://d:\jcr-repo" />
    </bean>

    <!--JCR transaction manager-->
    <bean id="jcrTransactionManager"
        class="org.springmodules.jcr.jackrabbit.LocalTransactionManager ">
        <property name="sessionFactory" ref="jcrSessionFactory" />
    </bean>

    <!-- transaction proxy for Jcr services/facades -->
    <bean id="transactionProxyTemplate" abstract="true"
        class="
org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="proxyTargetClass" value="true" />
        <property name="transactionManager" ref="jcrTransactionManager" />

        <property name="transactionAttributes">
            <props>
                <!--      <prop key="save*">PROPAGATION_REQUIRED</prop>-->

                <!--      <prop key="*">PROPAGATION_REQUIRED,
readOnly</prop>-->
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

<!--    ***************************-->
<!--    FolderDao                  -->
<!--    ***************************-->
    <bean id="folderDao" parent="transactionProxyTemplate">
        <property name="target">
            <ref bean="folderDaoTarget"/>
        </property>
    </bean>

    <bean id="folderDaoTarget" class="
com.fdv.core.model.dao.jcr.impl.FolderDaoImpl">
        <property name="jcrTemplate" ref="jcrTemplate"/>
    </bean>

<!--    ***************************-->
<!--    repositoryManager          -->
<!--    ***************************-->
    <bean id="repositoryManager" parent="transactionProxyTemplate"
lazy-init="true">
        <property name="target">
            <ref bean="repositoryManagerTarget"/>
        </property>
    </bean>

    <bean id="repositoryManagerTarget" class="
com.fdv.core.RepositoryManagerImpl">
        <property name="jcrTemplate" ref="jcrTemplate"/>
        <property name="folderDao" ref="folderDao"/>
    </bean>

<!--    ***************************-->
<!--    DocumentDao-->
<!--    ***************************-->
    <bean id="documentDao" parent="transactionProxyTemplate">
        <property name="target">
            <ref bean="documentDaoTarget"/>
        </property>
    </bean>

    <bean id="documentDaoTarget" class="
com.fdv.core.model.dao.jcr.impl.DocumentDaoImpl">
        <property name="jcrTemplate" ref="jcrTemplate"/>
    </bean>

    <bean id="repositoryConfiguration"     class="
com.fdv.core.RepositoryConfiguration" init-method="load"
lazy-init="false">

    </bean>
</beans>
[/code]

the stacktrace is:
[CODE]
org.springframework.beans.factory.BeanCreationException : Error creating
bean with name 'jcrSessionFactory' defined in class path resource [
spring-jcr-config.xml]: Cannot resolve reference to bean 'jcrRepository'
while setting bean property 'repository'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'jcrRepository' defined in class path resource [
spring-jcr-config.xml]: Invocation of init method failed; nested exception
is javax.jcr.RepositoryException: The repository home at D:\jcr-repo
appears to be in use since the file at D:\jcr-repo\.lock is locked by
another process.
Caused by: org.springframework.beans.factory.BeanCreationException : Error
creating bean with name 'jcrRepository' defined in class path resource [
spring-jcr-config.xml]: Invocation of init method failed; nested exception
is javax.jcr.RepositoryException: The repository home at D:\jcr-repo
appears to be in use since the file at D:\jcr-repo\.lock is locked by
another process.
Caused by: javax.jcr.RepositoryException: The repository home at
D:\jcr-repo appears to be in use since the file at D:\jcr-repo\.lock is
locked by another process.
    at org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock (
RepositoryImpl.java:412)
    at org.apache.jackrabbit.core.RepositoryImpl.<init>(
RepositoryImpl.java:236)
    at org.apache.jackrabbit.core.RepositoryImpl.create(
RepositoryImpl.java:573)
    at
org.springmodules.jcr.jackrabbit.RepositoryFactoryBean.createRepository (
RepositoryFactoryBean.java:57)
    at org.springmodules.jcr.RepositoryFactoryBean.afterPropertiesSet(
RepositoryFactoryBean.java:57)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(
AbstractAutowireCapableBeanFactory.java:1057)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
(AbstractAutowireCapableBeanFactory.java:1024)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(
AbstractAutowireCapableBeanFactory.java:421)

...

[/CODE]

The fragment of Spring bean definition of the service layer
[CODE]
    <bean id="userService" class="com.fdv.service.impl.UserServiceImpl"
autowire="byName">
        <property name="dao">
            <ref bean="userDAO"/>
        </property>
        <property name="mail">
            <ref bean="mailService"/>
        </property>
        <property name="businessConfigurationDAO">
            <ref bean="businessConfigurationDAO"/>
        </property>
        <property name="repositoryManager">
            <ref bean="repositoryManager"/>
        </property>
    </bean>
[/CODE]

Where "repositoryManager " is the bean defined above in the other spring
xml file.

thanks in advance
mamana

Reply via email to