cancel
Showing results for 
Search instead for 
Did you mean: 

Using data source

spark2
Champ in-the-making
Champ in-the-making
I am trying to have basic setup of Activiti in web project deployed on WebSphere 7

I have "jdbc/dbsource" configured as Oracle data source and below is code for Process engine.
Data source test connection is successful.

      ProcessEngineConfiguration config = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
      config.setDatabaseSchemaUpdate("false");
      config.setJobExecutorActivate(true);
      config.setDatabaseType("oracle");
                config.setDataSourceJndiName("jdbc/dbsource");
                ProcessEngine p = config.buildProcessEngine();

               ….

However after initiating, I see in log files that it is taking default h2 database.
I do not have activiti.cfg.xml (I believe it is not required as all configuration is static as above)

What i am missing? How to tell activiti to use datasource and not default h2 database.

Thanks
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
By setting the DataSourceJndiName, you tell activiti to use that to lookup the schema (relevant source in ProcesEngineConfigurationImpl):


protected void initDataSource() {
    if (dataSource==null) {
      if (dataSourceJndiName!=null) {
        try {
          dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
        } catch (Exception e) {
          throw new ActivitiException("couldn't lookup datasource from "+dataSourceJndiName+": "+e.getMessage(), e);
        }

It will throw a message if the JNDI-name does not resolve to a correct datasource. Are you sure you're using the ProcessEngine instance that you built yourself (and not using ProcessEngines.getDefault())?