1 2 Previous Next 27 Replies Latest reply: Jul 22, 2009 6:34 PM by Ronald van Kuijk Go to original post RSS
  • 15. Re: About integrating JBPM in an existing EAR
    Shekhar Vemuri Newbie

    Sorry, that should read:

    Once you do the above, you should have the code going such that jBPM uses your sessionFactory to interact with the database.

  • 16. Re: About integrating JBPM in an existing EAR
    Kerdudou Ronan Apprentice

    Thanks a lot shekharv,

    I will have a try right now !

  • 17. Re: About integrating JBPM in an existing EAR
    blalls asdsd Novice

    I am trying to achieve a similar goal. My testing code looks like this:

     SessionFactory sesionFactory = new org.hibernate.cfg.Configuration().configure("jbpm.hibernate.cfg.xml").buildSessionFactory();
    
     JbpmConfiguration config = new JbpmConfiguration();
     config.setSessionFactory(sesionFactory);
     ProcessEngine processEngine = config.buildProcessEngine();
    
     Transaction trx = sesionFactory.getCurrentSession().beginTransaction();
    
     ExecutionService executionService = processEngine.getExecutionService();
     Map<String,Object> variables = new HashMap<String,Object>();
     variables.put("username", "arash");
     variables.put("filename", "file1");
     ProcessInstance processInstance = executionService.startProcessInstanceByKey("add_media", variables);
     MyEntity myEntity = new MyEntity();
     myEntity.setFileName("tada1");
     myEntity.setProcessId("pro1");
     sesionFactory.getCurrentSession().save(myEntity);
     trx.rollback();
    


    There is no transaction manager configured in the hibernate config file and this is a JDBC transaction.
    The result is jbpm writing the new process to the database even though I rolled back the transaction.

    Could somebody tell me please how can I manage the transaction probabely.

  • 18. Re: About integrating JBPM in an existing EAR
    Shekhar Vemuri Newbie

    Is your hibernate session setup as following?

    <hibernate-session current="true"/>

  • 19. Re: About integrating JBPM in an existing EAR
    Kerdudou Ronan Apprentice

    Hello both of you,

    I'm on the same way. I succeed to inject my sessionFactory to jBPM thanks to shekharv's tips.

    I set in my config file:

    <hibernate-session current="true"/>


    But I notice that jBPM create it own transaction (and in my case, also close the session I injected !!). I think that why your process is saved even if you rollback your transaction.
    The jBPM class that do the job is "HibernateSessionResource". I have to look for a way to disable it. I don't want jBPM to manage any hibernate session or transaction.


  • 20. Re: About integrating JBPM in an existing EAR
    Shekhar Vemuri Newbie

    Could you post your entire jbpm config again?

  • 21. Re: About integrating JBPM in an existing EAR
    blalls asdsd Novice

    I copied the samples config files. The only change in hibernate config which is as follow:

    <?xml version="1.0" encoding="utf-8"?>
    
    <!DOCTYPE hibernate-configuration PUBLIC
     "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    
    <hibernate-configuration>
     <session-factory>
     <!-- hibernate dialect -->
     <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    
    
     <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
     <property name="hibernate.connection.url">jdbc:postgresql://localhost/mediagateway</property>
     <property name="hibernate.connection.username">user</property>
     <property name="hibernate.connection.password">pass</property>
     <!-- Automatic schema creation (begin) -->
     <property name="hibernate.hbm2ddl.auto">update</property>
     <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
    
     <mapping resource="jbpm.repository.hbm.xml" />
     <mapping resource="jbpm.execution.hbm.xml" />
     <mapping resource="jbpm.history.hbm.xml" />
     <mapping resource="jbpm.task.hbm.xml" />
     <mapping resource="jbpm.identity.hbm.xml" />
     <mapping resource="MyEntity.hbm.xml"/>
     </session-factory>
    </hibernate-configuration>
    


  • 22. Re: About integrating JBPM in an existing EAR
    Shekhar Vemuri Newbie

    OK, I took a few minutes out and whipped up a post about this, I will fleshing out the details today and tomorrow, but you guys can download the code and test it out.

    The blog post is @:
    http://shekharv.blogspot.com/2009/07/sample-hibernate-and-jbpm-application.html

    Right now there is just a Test class but I will be building out the whole WebApp through this week.

    You can lay around with the code and check out the transactions in the test class, by throwing exceptions and other things.

  • 23. Re: About integrating JBPM in an existing EAR
    Kerdudou Ronan Apprentice

    I just checked at your demo and especially the config file.
    I notice you have no "standard-transaction-interceptor"

    <command-service>
     <standard-transaction-interceptor />
     .....
    


    I just removed it from my config file and sucess: "Hello world" is printed !

    Thanks a lot again for your help

    Notices, it would have been easier if a doc explaining all the jBPM config file was available.

    Cheers.


  • 24. Re: About integrating JBPM in an existing EAR
    Ronald van Kuijk Master

    Ronan,

    This release of jBPM 4 was not targeted at being customized this way. It does not mean it is not possible, it is just (on purpose) not documented yet. There are more things in the dev guide that needs some more depth or that are in there because they are in 'incubation'

    If you have contributions in that area (documentation), you are more than welcome to attach them as patches to jira issues and I'll be happy to add

  • 25. Re: About integrating JBPM in an existing EAR
    blalls asdsd Novice

     

    "shekharv" wrote:

    OK, I took a few minutes out and whipped up a post about this, I will fleshing out the details today and tomorrow, but you guys can download the code and test it out.

    The blog post is @:
    http://shekharv.blogspot.com/2009/07/sample-hibernate-and-jbpm-application.html

    Thank you very much. IT worked for me too.

  • 26. Re: About integrating JBPM in an existing EAR
    blalls asdsd Novice

     

    "kukeltje" wrote:
    Ronan,

    This release of jBPM 4 was not targeted at being customized this way. It does not mean it is not possible, it is just (on purpose) not documented yet.

    Does this mean it is not a good idea to use it in this way? Do you think any risk is involved in this customization?

  • 27. Re: About integrating JBPM in an existing EAR
    Ronald van Kuijk Master

    The risk involved are:
    - that some details might still change before becomming stable.
    - that you might run into 'problems' where there is not programmed against interfaces yet
    - The source code is the best documentation
    - Support in the forums will be limited unless you have tried a lot yourself and have a very detailed question. e.g. a question like 'how can I implement my own transcation interceptor and do you have an example' will probably not be answered by the core team (others might though)

    I'm stating this very boldly now, but it is not that bad. The basics will not change and the source is fairly clear as real documentation, so you can give it a try, but don't complain if some details change ;-)

1 2 Previous Next