JPAContainer and JNDI

Hi,

has anybody succesfully used JPAContainer

with JBoss 7.1
using it through JNDI


?

I am struggling with this issue for a number of days now and I am not able to make it work.
I followed the provide guidelines but it seems that there is no entity-manager to connect to.

I am using Hibernate 4 and in persistence.xml you need to provide a JNDI-binding property for the EntityManagerFactory.
This binding works: I made some testcode and I can find the object.
However it seems that the entity manager binding (jboss.entity.manager.jndi.name) doesn’t work (anymore). I tried to set it and there is no such binding after (re-starting) the server.

When you use the makeJndi method, you can use a second paramet to set the UserTransaction and EntityManager names, however without a proper binding (-name) it won’t work.

I’ve tried all other ways of using the JPAContainer and they all work, except the JNDI-version. If somebody has an idea and is willing to solve this:

Thanks !

Leo

It seems that not many Vaadin users use this combination. After 5 months still no reply ??

I the meantime I switched to Glassfish 4 and the provided “Vaadin book” solution works without a problem. Unfortunately I will not use the JPAContainer, because of its excessive number of queries. I will create a new post for that issue. Hoepfully I will get an answer this time…

From :
https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide#JPAReferenceGuide-BindingEntityManagerFactorytoJNDI

By default JBoss AS7 does not bind the entity manager factory to JNDI. However, you can explicitly configure this in the persistence.xml of your application by setting the jboss.entity.manager.factory.jndi.name property. The value of that property should be the JNDI name to which the entity manager factory should be bound.

Dear Petrus,

I already shifted to Glassfish so I have no need to use AS7, but thanks anyway.

Binding the EntityManagerFactory in AS7 was not the problem but I mentioned that the entity manager binding (jboss.entity.manager.jndi.name) is not available in AS7. You can add it to persistence.xml, but binds nothing.

In Glassfish everything works directly “out-of-the-box”. Vaadin & GF/EclipselInk is more a symbiosis than the forced integration you have with Vaadin & AS7/Hibernate. However Glassfish has not the professional support which JBoss has, so I have another kind of problem now ;-(

Leo

Is Wildfly 8 an option for you? I’ve been able to use “JPAContainerFactory.makeJndi()” to create JPA containers - although I use it with the Eclipselink module installed.

Here is the relevant part of my persistence.xml file:

[code]

<?xml version="1.0" encoding="UTF-8"?>



org.eclipse.persistence.jpa.PersistenceProvider
jdbc/Pelco
com.pelco.jpa.job.Job



[/code]I annotate my servlet with @PersistenceContext like this:

@WebServlet(value = "/*", asyncSupported = true) @PersistenceContext(name = "persistence/em", unitName = "Pelco") @VaadinServletConfiguration(ui = JobManagerUI.class, productionMode = false) @SuppressWarnings("serial") public class JobManagerServlet extends com.vaadin.server.VaadinServlet { } And in my UI I am able to create a JPA Container using makeJndi() like this:

import com.pelco.jpa.job.Job;
...
    protected void init(com.vaadin.server.VaadinRequest request) {
        this.jobContainer = JPAContainerFactory.makeJndi(Job.class);
        ...
    }

Do this at all resemble what you are trying to do?

Hi Darell,

Thanks for your reply. I switched to GlassFish 4 a few months ago. At the moment I am not using JPAContainer because it has a serious unsolvable performance problem (see: https://vaadin.com/forum#!/thread/7966277).

I am using the BeanContainer with backend session beans + CDI. Far better from an architectural point of view and a far better performance. Needed to write of bookkeeping code, but it was worth te effort.

Leo

Yeah, I saw your other post. My JPA Containers have been fairly small so I haven’t seen the performance issues…yet.

I’m curious to know how you came to the conclustion that the JPA add-in performance problems were “unsolvable”?

Are you considering publishing your own add-in?

Hi,

just switch on the sql-logging in persistence.xml and you’ll be surprised about the amount of queries which is produced.

At the moment I have small tables (<20 rows) with a single entity, so I could live with it. Unfortunately other parts of the application use compex interrelated entities, much larger tables with up to a few thousand rows. Don’t want to end-up with an overloaded DB and/or low response times.

Another point is the lack of a pure “JPQL” interface. IMHO could be a valuable addition to the component. Existing complex queries with subselects (100% pure Hibernate queries!) would need a lot of re-engineering to squeeze it in a JPAContainer.

At the moment priority #1 is to get the stuff up-and-running, beautifying comes later. Therefor for the moment I don’t think there will be an add-on, but I could write a sort of HOWTO with JPA/CDI/VAADIN/BeanContainer.

Leo

Posting a HOWTO would be great!