Cuba 6.7 Bug in aditional stores

Hi

When defining more than one external datasource in project properties, for instance “My2ndDataSource” and after closing and reopening the project we get:
Additional data store ‘My2ndDataSource,’ not loaded. ‘cuba.dataSourceJndiName_My2ndDataSource,’ property not found in ‘[…/app.properties]’ properties files.
The referred property IS in fact in app.properties.

Hi,
The issue is known. The fix will be delivered in the Studio version 6.7.2.
Thank you.

Hi

Don’t know if because of this issue but now every entity on those external datastores gives "IllegalArgumentException: MetaClass not found for " running the browser screen.
This happens in Studio 6.7.2 after upgrading to platform 6.7.1
Please, how do I correct this?

And Studioo 7.2 version still has the problem above described.
I’ve been solving editing app.properties and removing the ‘,’ separator from datasources names in cuba.additionalStores

Thanks

Hi,
We have not fixed the issue in 6.7.2. It will be delivered only in 6.7.3. See the “Fix versions” property of the YouTrack issue.

Regarding the IllegalStateException. Additional datastores are registered in the following places:

  1. Context.xml (in the core module)
<Context>
...
    <Manager pathname=""/>
    <!--Data store 'name1' connection-->
    <Resource driverClassName="org.postgresql.Driver"
              maxIdle="2"
              maxTotal="20"Preformatted text
              maxWaitMillis="5000"
              name="jdbc/name1"
              password="cuba"
              type="javax.sql.DataSource"
              url="jdbc:postgresql://localhost/name1"
              username="cuba"/>
    <!--Data store 'name2' connection-->
    <Resource driverClassName="org.postgresql.Driver"
              maxIdle="2"
              maxTotal="20"
              maxWaitMillis="5000"
              name="jdbc/name2"
              password="cuba"
              type="javax.sql.DataSource"
              url="jdbc:postgresql://localhost/name2"
              username="cuba"/>
</Context>
  1. app.properties
    cuba.additionalStores = name1, name2

    cuba.persistenceConfig_name1 = +com/company/datastores/name1-persistence.xml
    cuba.dbmsType_name1 = postgres
    cuba.dataSourceJndiName_name1 = jdbc/name1

    cuba.persistenceConfig_name2 = +com/company/datastores/name2-persistence.xml
    cuba.dbmsType_name2 = postgres
    cuba.dataSourceJndiName_name2 = jdbc/name2
  1. web-app.properties and desktop-app.properties (if exists):
cuba.additionalStores = name1, name2
cuba.persistenceConfig_name1 = +com/company/datastores/name1-persistence.xml
cuba.persistenceConfig_name2 = +com/company/datastores/name2-persistence.xml
  1. Spring.xml
 <!-- Annotation-based beans -->
 <context:component-scan base-package="com.company.datastores"/>
<bean id="cubaDataSource_name1"
      class="com.haulmont.cuba.core.sys.CubaJndiObjectFactoryBean">
    <property name="jndiNameAppProperty"
              value="cuba.dataSourceJndiName_name1"/>
    <property name="resourceRef"
              value="true"/>
</bean>
<bean id="entityManagerFactory_name1"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      lazy-init="false">
    <property name="persistenceXmlLocation"
              value="file:${cuba.dataDir}/name1-persistence.xml"/>
    <property name="dataSource"
              ref="cubaDataSource_name1"/>
    <property name="jpaVendorAdapter"
              ref="jpaVendorAdapter"/>
</bean>
<bean id="transactionManager_name1"
      class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory"
              ref="entityManagerFactory_name1"/>
    <property name="dataSource"
              ref="cubaDataSource_name1"/>
    <qualifier type="org.springframework.beans.factory.annotation.Qualifier"
               value="name1"/>
</bean>
<bean id="cubaDataSource_name2"
      class="com.haulmont.cuba.core.sys.CubaJndiObjectFactoryBean">
    <property name="jndiNameAppProperty"
              value="cuba.dataSourceJndiName_name2"/>
    <property name="resourceRef"
              value="true"/>
</bean>
<bean id="entityManagerFactory_name2"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      lazy-init="false">
    <property name="persistenceXmlLocation"
              value="file:${cuba.dataDir}/name2-persistence.xml"/>
    <property name="dataSource"
              ref="cubaDataSource_name2"/>
    <property name="jpaVendorAdapter"
              ref="jpaVendorAdapter"/>
</bean>
<bean id="transactionManager_name2"
      class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory"
              ref="entityManagerFactory_name2"/>
    <property name="dataSource"
              ref="cubaDataSource_name2"/>
    <qualifier type="org.springframework.beans.factory.annotation.Qualifier"
               value="name2"/>
</bean>
</beans>
  1. And also name1-persistence.xml, name2-persistence.xml (separate persistence config for each datastore) are created in the global module.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             version="2.0">
    <persistence-unit name="name1"
                      transaction-type="RESOURCE_LOCAL">
        <class>com.company.datastores.entity.LibraryTown</class>
    </persistence-unit>
</persistence>

Make sure that correct settings are defined in that files.

@iskandarov i checked each file and when i try to test app: (- ./gradlew -g /cache/.gradle test --info)

i get exeption (latest stable version of cuba):

12:34:05.202 DEBUG com.haulmont.cuba.core.sys.CubaJndiDataSourceFactoryBean - Located object with JNDI name [java:comp/env/jdbc/CubaDS]

[529](https://gitlab.atena.sk/root/ramcove-zmluvy/-/jobs/39#L529)  12:34:08.823 DEBUG com.haulmont.cuba.core.sys.CubaJndiObjectFactoryBean - Converted JNDI name [java:comp/env/jdbc/atena] not found - trying original name [jdbc/atena]. javax.naming.NamingException: Not bound: java:comp/env/jdbc/atena

[530](https://gitlab.atena.sk/root/ramcove-zmluvy/-/jobs/39#L530)  12:34:08.838 WARN com.haulmont.cuba.core.sys.CubaCoreApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory_atena' defined in class path resource [com/company/ramcovezmluvy/spring.xml]: Cannot resolve reference to bean 'cubaDataSource_atena' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cubaDataSource_atena' defined in class path resource [com/company/ramcovezmluvy/spring.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Not bound: jdbc/atena

[531](https://gitlab.atena.sk/root/ramcove-zmluvy/-/jobs/39#L531) Gradle Test Executor 1 finished executing tests.

[532](https://gitlab.atena.sk/root/ramcove-zmluvy/-/jobs/39#L532) > Task :app-core:test FAILED