Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Session not close after registerNamespaces

  1. #1

    Default Session not close after registerNamespaces

    Hi,

    I tried to setup the spring jcr but when I start the Tomcat, it show the warning "Unclosed session detected. The session was opened here".
    Below is the stacktrace:

    Code:
    java.lang.Exception: Stack Trace
            at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:249)
            at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:271)
            at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:105)
            at org.apache.jackrabbit.core.RepositoryImpl.createSessionInstance(RepositoryImpl.java:1517)
            at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:964)
            at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1395)
            at org.apache.jackrabbit.core.jndi.BindableRepository.login(BindableRepository.java:162)
            at org.springframework.extensions.jcr.JcrSessionFactory.getBareSession(JcrSessionFactory.java:270)
            at org.springframework.extensions.jcr.JcrSessionFactory.registerNamespaces(JcrSessionFactory.java:182)
            at org.springframework.extensions.jcr.JcrSessionFactory.afterPropertiesSet(JcrSessionFactory.java:142)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowi
    reCapableBeanFactory.java:1369)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireC
    apableBeanFactory.java:1335)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCap
    ableBeanFactory.java:473)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBea
    nFactory.java:409)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapab
    leBeanFactory.java:380)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegis
    try.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListable
    BeanFactory.java:429)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplic
    ationContext.java:728)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
            at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
            at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
            at org.apache.catalina.core.StandardService.start(StandardService.java:448)
            at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
    2009-08-15 16:54:04,546 main INFO [springframework.web.context.ContextLoader] Root WebApplicationContext: initialization
     completed in 155843 ms
    Here's my spring config file:
    Code:
    <jee:jndi-lookup id="repository" jndi-name="jcr/repository"/>
    
        <bean id="jcrSessionFactory" class="org.springframework.extensions.jcr.JcrSessionFactory">
            <property name="repository" ref="repository"/>
            <property name="credentials">
                <bean class="javax.jcr.SimpleCredentials">
                    <constructor-arg index="0" value="hnghiem"/>
                    <constructor-arg index="1" value="hnghiem"/>
                </bean>
            </property>
            <property name="namespaces">
                <props>
                    <prop key="owe">http://www.owe.com/jcr</prop>
                </props>
            </property>
            <property name="skipExistingNamespaces" value="true"/>
        </bean>
    
        <bean id="jcrTemplate" class="org.springframework.extensions.jcr.JcrTemplate">
            <property name="sessionFactory" ref="jcrSessionFactory"/>
            <property name="allowCreate" value="true"/>
        </bean>
    Can anyone help me?
    Thanks!!!

  2. #2
    Join Date
    May 2009
    Location
    Rome
    Posts
    22

    Default

    Hi burgleboy711, sorry for the delay, have you still this problem?

  3. #3
    Join Date
    Jul 2008
    Location
    Barcelona, Spain
    Posts
    20

    Default

    Same problem here!

    Code:
    	<bean id="repository" class="org.springframework.extensions.jcr.jackrabbit.RepositoryFactoryBean">
    		<property name="configuration" value="classpath:jackrabbit-repo.xml"/>
    		<property name="homeDir" value="classpath:tmp"/>
    	</bean>
    	
    	<bean id="jcrSessionFactory" class="org.springframework.extensions.jcr.jackrabbit.JackrabbitSessionFactory">
    		<property name="nodeDefinitions">
    		    <list>
    		    	<value>file:C:/../../mycnd.cnd</value>
    		    </list>
      		</property>
      		<property name="contentType" value="text/x-jcr-cnd" />
    		<property name="namespaces">
                <props>
                    <prop key="myns">http://myns.com/jcr/1.0</prop>
                </props>
            </property>
    		<property name="repository" ref="repository"/>
    		<property name="workspaceName" value="public" />
    		<property name="credentials">
    			 <bean class="javax.jcr.SimpleCredentials">
                                  <constructor-arg index="0" value="blabla"/>
                                  <constructor-arg index="1" value="blabla"/>
                             </bean>
    		</property>	
    	</bean>
    		
    	<bean id="jcrTemplate" class="org.springframework.extensions.jcr.JcrTemplate">
    	    <property name="sessionFactory" ref="jcrSessionFactory"/>
    	    <property name="allowCreate" value="true"/>
    	</bean>
    EDIT: I forgot to mention that this problem it's not a big deal because all seems to work correctly
    Last edited by Yuki; Nov 17th, 2009 at 03:29 AM.

  4. #4
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

  5. #5
    Join Date
    Jul 2008
    Location
    Barcelona, Spain
    Posts
    20

    Default

    Thank you!

    have the patch worked for you? I'm trying to compile using the patch but I get errors during the test >.<

  6. #6
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    Did you apply http://jira.springframework.org/browse/SEJCR-17?

    I created 18 on top of 17.
    What are the compilation errors you see?
    Thanks
    Dmitry

  7. #7
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    This is really simple patch:

    in JcrSessionFactory.registerNodeTypes change

    Code:
            NamespaceRegistry registry = getBareSession().getWorkspace().getNamespaceRegistry();
    with

    Code:
    Session session = getBareSession();
            NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
    and add

    Code:
    session.logout();
    as the last statement in the method.
    Thanks
    Dmitry

  8. #8
    Join Date
    Jul 2008
    Location
    Barcelona, Spain
    Posts
    20

    Default

    Yes!

    I've downloaded the trunk from https://src.springframework.org/svn/se-jcr/trunk
    and then I've applied the two patches (first SEJCR-17)

    The nexts tests fail:

    Code:
    Results :
    
    Failed tests:
      testRegisterNamespaces(org.springframework.extensions.jcr.JcrSessionFactoryTes
    t)
      testForceRegistryNamespace(org.springframework.extensions.jcr.JcrSessionFactor
    yTest)
      testForceRegistryNamespace(org.springframework.extensions.jcr.JcrSessionFactor
    yTest)
      testKeepRegistryNamespace(org.springframework.extensions.jcr.JcrSessionFactory
    Test)
      testSkipRegisteredNamespaces(org.springframework.extensions.jcr.JcrSessionFact
    oryTest)
    
    Tests run: 74, Failures: 5, Errors: 0, Skipped: 0
    If I applied only the patch from SEJCR-17 compilation works fine.

  9. #9
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    You right. My bad. I am attaching a patch for the test. Forgot to include that in the original patch. Shame on me
    Thanks
    Dmitry

  10. #10
    Join Date
    Jul 2008
    Location
    Barcelona, Spain
    Posts
    20

    Default

    Thank you very much!!

    Everything works perfect!

    The same problem with the session exists in the class JackRabbitSessionFactory in the function registerNodeTypes, line 52.
    I've made the session.logout() and the compilation works fine without changing the tests

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •