Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-4411

XWikiServiceImpl's xwiki context is not handled threadsafe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.0.1, 2.1 M1
    • None
    • {Unused} APIs
    • None
    • GWT
    • Easy

    Description

      Sometimes this error occurs when calling the XWikiService related functions:

      com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while searching documents with sql select distinct doc from XWikiDocument as doc where lower(doc.title) like '%%' or lower(doc.fullName) like '%%'
      Wrapped Exception: Session is closed!
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2142)
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2072)
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2061)
      	at com.xpn.xwiki.store.XWikiCacheStore.search(XWikiCacheStore.java:581)
      	at com.xpn.xwiki.XWiki.search(XWiki.java:1565)
      	at com.xpn.xwiki.wysiwyg.server.DefaultWysiwygService.getMatchingPages(DefaultWysiwygService.java:432)
      	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 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
      	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:166)
      	at com.xpn.xwiki.gwt.api.server.XWikiServiceImpl.processCall(XWikiServiceImpl.java:85)
      	at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:117)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
      	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
      	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:326)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
      
      
      Wrapped Exception:
      
      
      org.hibernate.SessionException: Session is closed!
      	at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
      	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1110)
      	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2134)
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2072)
      	at com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2061)
      	at com.xpn.xwiki.store.XWikiCacheStore.search(XWikiCacheStore.java:581)
      	at com.xpn.xwiki.XWiki.search(XWiki.java:1565)
      	at com.xpn.xwiki.wysiwyg.server.DefaultWysiwygService.getMatchingPages(DefaultWysiwygService.java:432)
      	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 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
      	at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:166)
      	at com.xpn.xwiki.gwt.api.server.XWikiServiceImpl.processCall(XWikiServiceImpl.java:85)
      	at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:117)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
      	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
      	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:326)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
      

      which is tipically the error when the same context is shared by 2 different threads.
      In the XWikiServiceImpl context preparing code, the prepared context is stored as a member of the service servlet to be retrieved afterwards in the called function, which makes it shared by 2 threads if 2 calls to the service are made simultaneously.

      Attachments

        Activity

          People

            lucaa Anca Luca
            lucaa Anca Luca
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: