Thursday, September 29, 2011

GWT Persistence call failing


I started a project with GWT using existing EJB-classes. Those EJB-
classes are inside an own .jar-file but included into the GWT war\WEB-
INF\classes\*.class compiled.

My problem: The EJB-class (ProductHome) is instanciated, but my
EntityManager (bound by @PersistenceContext) remains NULL. The
EntityManager is defined in HomeBase<T> which is extended by

I included the persistence.xhtml from the ejb-project in war\WEB-INF

Why does the PersistenceContext not work in this case? Are there
requirements, I'm missing?

The files:

------ HomeBase<T>
public abstract class HomeBase<T>
@PersistenceContext(unitName="sung_app_kylintv_gwt" ,type =
protected EntityManager entityManager;

------ ProductHome
@Stateless(name = "Product")
public class ProductHome extends HomeBase<ProductEntity> implements
Serializable, Product
protected Option sessionOption;
public boolean createTestEntry()
System.out.println("TEST creating Data BEGIN");

ProductEntity currentProduct = new ProductEntity();
catch(Exception e)
//print out an error message and return false
System.out.println( e.getCause().getMessage() );
return false;
return true;

------ ServiceImpl
public class DatabaseBuilderServiceImpl extends RemoteServiceServlet
implements DatabaseBuilderService
private Product product;

@EJB(mappedName = "sung/app/kylintv/product" )
public void setProduct(Product product)
this.product = product;

public DatabaseBuilderServiceImpl()

public boolean createDefaultDatabaseEntries()
return product.createTestEntry();

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment