Thursday, September 29, 2011

GWT Persistence call failing

Hi,

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
ProductHome.

I included the persistence.xhtml from the ejb-project in war\WEB-INF
\classes\META-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 =
PersistenceContextType.EXTENDED)
protected EntityManager entityManager;
}

------ ProductHome
@Stateless(name = "Product")
@Local(Product.class)
public class ProductHome extends HomeBase<ProductEntity> implements
Serializable, Product
{
@EJB
protected Option sessionOption;
...
@TransactionAttribute(REQUIRED)
public boolean createTestEntry()
{
try
{
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 google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment