Easiest way to use JPA with my GWT app

I would like to create a simple Google Web Toolkit application that uses RPC. For persistence, I would like to use something like Java Persistence API.

Does this mean that I have to use an application server like Glassfish? or can I stick with a simple web container?

For specific libraries, how should I proceed? TopLink? Hibernate? ...

+1


source to share


3 answers


I believe the GWT RPC stuff is implemented as simple servlets. Assuming you can fully use JPA in a web container like Tomcat and don't need a full blown J2EE application server.



To do this, you need to do a little manual configuration to make it easier to access the PersistenceContext. Hibernate suggests using ThreadLocal and I have a blog entry detailing how I did it for Tomcat here

+3


source


I personally recommended Glassfish for being more stable, better implemented and generally of higher quality than Tomcat. I don’t want to start a fiery war (saying putting J2EE in Tomcat is like lipstick on a pig), but I’ll tell you how we deploy all of our applications:



We use Glassfish as a web container, TopLink as a persistence provider, usually linked to a MySQL 5 database. We use POJO JPA entirely from the EJB tier, via the web tier and GWT tier, and also via RPC. We also use Stripes and JSP for all presentation logic that doesn't require AJAX functionality. We have never had any problems with this approach and so far we have done at least 10 large-scale projects. This is the best architecture we've had to date and we've had many (tomcat, jboss, hibernate, struts, spring, etc. Etc. Etc.).

+2


source


You can use any container you like, I mean servlet and jpa containers.

The key point is that GWT does not support jpa, so you need to use the DTO design batch. This will keep everything organized and you won't have problems with lazy loading.

+1


source







All Articles