Figured out some way to make sure Ignite is initialized before EntityManagerFactory, not sure if it's the right way though. Please let me know if I'm doing something conceptually wrong here.
I'm trying to use the class-name and factory-name (as described here: http://tomee.apache.org/application-resources.html) to make sure the DataSource is initialized after Ignite.start() is called. The sequence problem seems to be resolved, but I'm not sure how to properly manually instantiate the JTA managed datasource. Here is my resources.xml: <resources> <Resource id="myDS" type="javax.sql.DataSource" class-name="com.bla.bla.DataSourceFactory" factory-name="create"> JdbcDriver = org.postgresql.Driver JdbcUrl = jdbc:postgresql://localhost:5432/mydb UserName = user Password = test maxActive = 10 maxIdle = 10 TestOnBorrow = true TestWhileIdle = true TestOnReturn = true ValidationQuery = SELECT 1 JtaManaged=true </Resource> </resources> Here is my factory method (ofcom.bla.bla.DataSourceFactory): public Object create() { initIgnite(); BasicManagedDataSource resource = new BasicManagedDataSource("myDB"); resource.setJdbcDriver("org.postgresql.Driver"); resource.setJdbcUrl("jdbc:postgresql://localhost:5432/mydb"); resource.setUserName("user"); resource.setPassword("test"); resource.setTestOnBorrow(true); resource.setTestWhileIdle(true); resource.setTestOnReturn(true); resource.setValidationQuery("SELECT 1"); return resource; } BasicManagedDataSource doesn't have the setJtaManaged(), so it's probably not a good choice... Also, and I'm seeing this in the log: 27-Sep-2018 18:26:50.516 WARNING [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.unusedProperty unused property 'JdbcDriver' for resource 'my-app/myDS' 27-Sep-2018 18:26:50.516 WARNING [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.unusedProperty unused property 'JdbcUrl' for resource 'my-app / myDS ' 27-Sep-2018 18:26:50.516 WARNING [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.unusedProperty unused property 'UserName' for resource 'my-app / myDS ' 27-Sep-2018 18:26:50.516 WARNING [http-nio-8080-exec-4] org.apache.openejb.assembler.classic.Assembler.unusedProperty unused property 'Password' for resource 'my-app / myDS ' ... From: Shultz, Dmitry Sent: Thursday, September 27, 2018 10:03 AM To: users@tomee.apache.org Subject: Apache Ignite initialization before EntityManagerFactory Hi All, I'm trying to use Apache Ignite as a L2 cache in my app. Both JPA/Hibernate and Ignite are configured to work together, but I'm not sure how to make the Ignite to started before JPA/Hibernate is initialized. Right now the war deployment fails when deployer is trying to create EntityManagerFactory and can't find the specified (in persistence.xml) Ignite instance. Do I have to deploy another app (with Ignite.start() in it) before the 'main' app or there is some other way to do it? Cheers, Dmitry