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

Thread: jBPM: No datasource on schema-creation

  1. #1
    Join Date
    Aug 2004
    Posts
    2,715

    Default jBPM: No datasource on schema-creation

    Just tried to get started with spring-jbpm (from cvs), jBPM 3.0.2 and hibernate 3.1.1.

    I had problems on spring configuration of jBPM in conjunction with JbpmSchema#createSchema invocation. I always got a "No local data source" exception.

    Now I tracked down the problem:
    the createSchema() method tries to get a connection via org.hibernate.connection.ConnectionProviderFactory. This one instantiates a new org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider instance. This instance tries to resolve the data source via LocalSessionFactoryBean.getConfigTimeDataSource().
    The point is, that a DataSource configured to org.springframework.orm.hibernate3.LocalSessionFac toryBean could not be resolved for that new instance, because the configTimeDataSource property is not available anymore (reset after initialization).

    Now, in order to create the jBpm schema, one has to supply database parameters in the hibernate properties and omit the data source.
    Note, that accessing a created schema works with a spring configured data source.

    Maybe someone has a solution for this issue?

    Regards,
    Andreas

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Please raise an issue - I *might* be able to look at this issue at some point in the future. IIRC, the LocalSessionFactoryBean had a similar problem and the fix was pretty trivial (keep the datasource around for schema export) - I'm sure it can apply to your case though.
    Last edited by Costin Leau; Jan 18th, 2006 at 03:07 PM.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Done

    I created the issue for Spring modules, since the problem occurred there. Though I think changes in ORM classes might also be required.

    Andreas

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Thanks. I'll try to reproduce it. I'm not up-to-date with the status of jBPM especially since it was moved on the sf.net CVS. I'll try to contact Rob and see what's the situation.
    I'll keep you update but again, it might take a while.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Just in case you are not watching the JIRA, I have created a very simple test that confirms the bug and indeed the fault lies in the LocalSessionFactoryBean. You can see the JIRA issue for more details. Thanks for reporting.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    I tracked the issue. As it seems, we have to wait for jBPM 3.1 which hopefully handles this case more sensible.

    Anyway, thanks for your help.
    Andreas

  7. #7
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I have some ideas on a possible workaround for even with jbpm 3.0.x. One would be to extend the jbpmSchema class so that execute method (which calls the static Hibernate ConnectionProvider) would work better. I haven't tested yet but I hope I will in the very near future.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  8. #8
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    One solution for this problem (which already existed inside the tests) is to set SchemaUpdate to true on HB localSessionFactory. This will force the HBSessionFactoryBean to create the mapping before even the jBPM will be initilialized.
    However, you still have the problem with JbpmSchema - when doing dropping for clean/create/drop. In these situation you can get the LocalSessionFactoryBean and use create/drop/updateDatabaseSchema.
    Note that this will work at any (not just during the afterPropertiesSet()). I have imlemented the same mechanism as the one used in Hibernate (add a special ConnectionProvider) but that just duplicates code and it's available just during start-up (afterPropertiesSet).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  9. #9
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    The SchemaUpdate-flag I didn't want to use. I built a test prototype and wanted to be able to perform cleaning in between.
    Ok, a manual approach would be possible in any case, so that could be a fallback (even with code duplication).

    I think the approach to override JbpmSchema seems to be a good idea.

    Regards,
    Andreas

  10. #10
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Overriding the jbpmSchema is a really ugly hack - I can't extend the problematic method (createConnection) since it's private so I basically have to duplicate code which is not just hard to maintain but may actually create an license issue and will fall under the LGPL license which is not compatible with Apache/BSD.
    I'm not happy with the outcome and that's why I recommend using the methods on LocalSessionFactory since they offer IMO a clean solution that exists already and moreover, that is available during the whole lifetime of the HB/jBPM factoryBeans.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

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