How to inject a JPAContainer?

Hi,

I’m using the Vaadin CDI Addon throughout my application. I’m now trying to integrate a database layer, therefore using the JPAContainer.

Problem: all instances in my services and also the UI views are created using the CDI @Inject. But the JPA manager is manually created like this:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
JPAContainer container = JPAContainerFactory.make(MyClass.class, ApplicationUI.PERSISTENCE_UNIT);

container.addEntity(...); //Exception

Question: do I also have to inject the JPAContainer somehow?
Because, the exception occuring on addEntity() is:

Caused by: java.lang.IllegalStateException:
Exception Description: Cannot use an EntityTransaction while using JTA.
    at org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper.getTransaction(JTATransactionWrapper.java:73)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.getTransaction(EntityManagerImpl.java:1311)
    at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider.runInTransaction(MutableLocalEntityProvider.java:111)
    at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider.addEntity(MutableLocalEntityProvider.java:137)
    at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.addEntity(CachingMutableLocalEntityProvider.java:164)
    at com.vaadin.addon.jpacontainer.JPAContainer.addEntity(JPAContainer.java:1113)

What is wrong here?

Maven:


<dependency>
		   <groupId>com.vaadin.addon</groupId>
		   <artifactId>jpacontainer</artifactId>
		   <version>3.1.0</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.persistence</groupId>
			<artifactId>javax.persistence</artifactId>
			<version>2.1.0</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.persistence</groupId>
			<artifactId>eclipselink</artifactId>
			<version>2.5.1</version>
		</dependency>

Use makeJndi method instead make.