Discussion:
[jboss-user] [jBPM] - Re: [JBPM 5.4] - Transaction / Concurrency problem
Maciej Swiderski
2013-08-12 05:14:10 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832232#832232

--------------------------------------------------------------
if you have mulitple ksessions that different threads operate on you cannot share the environment object. Each session must have dedicated instance of Environment and looking at the code given you share environment.
    *public* Environment getEnvironment() {
        *if*(environment == *null*) {
            LOGGER.info("CREATING NEW ENVIRONMENT");
            environment = KnowledgeBaseFactory.newEnvironment();
            environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, getEntityManagerFactoryJbpm());
        }
        *return* environment;
    }
HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832232#832232]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Guilherme Telles
2013-08-13 18:28:33 UTC
Permalink
Guilherme Telles [https://community.jboss.org/people/guilherme.telles] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832543#832543

--------------------------------------------------------------
Maciej, thanks for answering

I changed the code to the following:

    public Environment getEnvironment() {

        LOGGER.info("CREATING NEW ENVIRONMENT");

        environment = KnowledgeBaseFactory.newEnvironment();
        environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, getEntityManagerFactoryJbpm());
       
        return environment;
    }


So that everytime an Environment is needed, a new one is created.

But I'm still getting the same error.

There's some other cause to the error?

Thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832543#832543]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2013-08-14 05:15:52 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832577#832577

--------------------------------------------------------------
could you please describe your application configuration? Best would be to have sort of reproducer of this problem as it looks like some entity manger is cached somewhere and thus causing optimistic locking/stale object exception. In general the entity manager should be cleared at transaction completion but maybe that somehow does not work in spring - depending on transaction management. See https://github.com/droolsjbpm/droolsjbpm-integration/blob/5.5.x/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java#L151http:// here.

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832577#832577]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Guilherme Telles
2013-08-14 19:01:58 UTC
Permalink
Guilherme Telles [https://community.jboss.org/people/guilherme.telles] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832690#832690

--------------------------------------------------------------
Ok, I'll prepare a demo application for you.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832690#832690]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Guilherme Telles
2013-08-15 19:47:24 UTC
Permalink
Guilherme Telles [https://community.jboss.org/people/guilherme.telles] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832804#832804

--------------------------------------------------------------
I'm kind of busy to complete the demo application, but in the meanwhile, this is my application configuration you asked:

* JBPM 5.4 - The process, knowlodge base, and etc it's in a remote server
* Spring 3* My bean configuration for the entity manager factory:


     <bean id="entityManagerFactoryJbpm"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="org.jbpm.process" />
     </bean>

* JBoss 7.1.1: Here's my data source for the persistence of the process

               <datasource jndi-name="java:jboss/datasources/processDS" pool-name="processDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:postgresql://localhost:5432/mydatabase</connection-url>
                    <driver-class>org.postgresql.Driver</driver-class>
                    <driver>postgresql</driver>
                    <security>
                        <user-name>myuser</user-name>
                        <password>mypassword</password>
                    </security>
                </datasource>

* Postgres 9.2
* My persistence.xml : http://pastebin.com/Pz5NUxH7 http://pastebin.com/Pz5NUxH7

What kind of information do you need?

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832804#832804]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Guilherme Telles
2013-08-16 21:23:53 UTC
Permalink
Guilherme Telles [https://community.jboss.org/people/guilherme.telles] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/832941#832941

--------------------------------------------------------------
Maciej, here's the demo application, it's intructions are inside.

Due to lack of time, it does not reproduces the same concurrency error.

But maybe you can find what I'm doing wrong with this.

Of course it's a very basic application and I had to simplify a lot of code.

For example, getting a task service, adding users manually instead of using ldap, a local .bpmn2 file instead of a remote server, etc.

I'm not sending a war file because of the forum attachment size limit.

Thank you very much for helping me, I'm in kind of a tight spot here.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832941#832941]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Paulo Porto
2013-08-21 12:27:45 UTC
Permalink
Paulo Porto [https://community.jboss.org/people/paulo.porto] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/833384#833384

--------------------------------------------------------------
hey i'm also having the same trouble
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/833384#833384]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
mvermand
2013-08-22 08:50:49 UTC
Permalink
mvermand [https://community.jboss.org/people/mvermand] created the discussion

"Re: [JBPM 5.4] - Transaction / Concurrency problem"

To view the discussion, visit: https://community.jboss.org/message/833497#833497

--------------------------------------------------------------
I use multiple ksessions from a webApp servlet. I kept getting "Session is closed!" Exception from within "SingleSessionCommandService".
Post by Maciej Swiderski
Each session must have dedicated instance of Environment and looking at the code given you share environment.
This really saved my day!
Thanks a lot for that insigth!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/833497#833497]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...