Integration test. Exception when create additional database transaction

Hello! I got some trouble. Try to run simple test:

    @Test
    public void getSimpleData() {
        Transaction tx = persistence.createTransaction("additional");
        try {
            EntityManager em = persistence.getEntityManager("additional");
            Query query = em.createQuery("select c from nl$Data c where c.id=1");
        }catch (Exception ex){
            ex.printStackTrace();
        }finally {
            tx.close();
        }
    }

And got exception:

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: java.lang.AbstractMethodError

If create transaction like this (without additional storename) all work’s fine.

Transaction tx = persistence.createTransaction();

But I need create transaction to additional database and now I can’t do this.

My test container code:

package com.company.nl;

import com.haulmont.cuba.core.sys.AppContext;
import com.haulmont.cuba.testsupport.TestContainer;
import com.haulmont.cuba.testsupport.TestContext;
import com.haulmont.cuba.testsupport.TestDataSource;

import javax.naming.NamingException;
import java.util.ArrayList;
import java.util.Arrays;

public class SalesTestContainer extends TestContainer {

    SalesTestContainer() {
        super();
        appComponents = new ArrayList<>(Arrays.asList(
                "com.haulmont.cuba",
                "com.haulmont.reports"
        ));
        appPropertiesFiles = Arrays.asList(
                "com/company/nl/app.properties");
        dbDriver = "org.postgresql.Driver";
        dbUrl = "**********";
        dbUser = "**********";
        dbPassword = "**********";
    }



    @Override
    protected void initDataSources() {
        super.initDataSources();
        try {
            Class.forName("net.sourceforge.jtds.jdbc.Driver");
            TestDataSource mydbDataSource
                    = new TestDataSource("**********", "***", "***");
            TestContext.getInstance().bind(AppContext.getProperty("cuba.dataSourceJndiName_additional"), mydbDataSource);
        } catch (ClassNotFoundException | NamingException e) {
            throw new RuntimeException("Error initializing datasource", e);
        }
    }

    public static class Common extends SalesTestContainer {

        public static final SalesTestContainer.Common INSTANCE = new SalesTestContainer.Common();

        private static volatile boolean initialized;

        private Common() {
        }

        @Override
        public void before() throws Throwable {
            if (!initialized) {
                super.before();
                initialized = true;
            }
            setupContext();
        }

        @Override
        public void after() {
            cleanupContext();
            // never stops - do not call super
        }
    }

}

Thanks!

Hello, I’m affected on this problem too.
Cuba developers, can you help to resolve this problem?
In my project heavely used additional datasource and without integration tests project grow slow.

Hello! Nobody writes tests? Or no one has this problem?

This is an old problem …

see :

I have the same problem. If someone solves it please share your decision.

The decision for additional data store was presented in this post: Can't resolve reference to additional datasource during testing - #5 от пользователя krivopustov

If you encounter a problem, please create a new topic with some details.

Thank you for the answer.