4 Replies Latest reply on Feb 19, 2009 11:41 AM by swd847

    could not acquire lock on @Synchronized, help me.

    sherkan777

      Sometime my STSB's throws this error to log files on server.
      Can anybody help me to resolve problem? What can't be wrong?



      Caused by: java.lang.IllegalStateException: could not acquire lock on @Synchronized component: galaxyAction
           at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:41)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
           at org.javassist.tmp.java.lang.Object_$$_javassist_9.takeOverSystem(Object_$$_javassist_9.java)
           ... 55 more
      2009-02-17 13:44:05,419 ERROR [org.jboss.seam.servlet.ContextualHttpServletRequest] ended request due to exception


        • 1. Re: could not acquire lock on @Synchronized, help me.
          swd847

          Session scoped components are automatically Synchronized, so multiple threads cannot access then at once. If a thread is waiting two long to acquire a lock that exception will get thrown.

          • 2. Re: could not acquire lock on @Synchronized, help me.
            blabno

            I've run at the same problem when I was writing module that took a long time to perform some task and other component was trying to access the busy component (i.e. on page refresh). I suggest running that task in separate thread. Note that when you use @Asynchronous annotation to fire method in async mode, then it does not have access to conversation scope. You might find it easier sometimes to create separate thread by hand and set it up right.

            • 3. Re: could not acquire lock on @Synchronized, help me.
              sherkan777

              So only way is to set bigger timeout using @Synchronized at bean begin in this case (if I use SESSION scope bean).



              @Stateful
              @Scope(ScopeType.SESSION)
              @Name("xxxxx")
              @Synchronized(timeout=10000)



              but in conversation state each conversation is separated thread and this it not necesary. Am I right?

              • 4. Re: could not acquire lock on @Synchronized, help me.
                swd847

                yes, I think there is some way to remove the synchronization but I cannot remember it off the top of my head, you would have to check the docs. If you do this the you will have to deal with thread safety issues yourself though.