ejb@glassfish.java.net

Re: [eclipselink-users] Error on deploy webapp

From: Michael Frank O'Brien <michael.obrien_at_oracle.com>
Date: Mon, 24 Jan 2011 10:30:19 -0500

Jose,
    Hi, your DI annotations on your SSB look fine. You should not need
any glassfish specific descriptors in sun-ejb-jar.xml or sun-web.xml
 From your exception it looks like the catalina-based web container does
not have a reference to your EJB on WAR deploy. What kind of client are
you using to access your SSB - I assume you are using @EJB injection on
a servlet or something similar for the ejb abstract or interface
class. Do you have a classpath reference to your ejb project jar from
your PruebaWEB war project jar?

    thank you
    Michael O'Brien

On 23/01/2011 09:34, Jose Alvarez de Lara wrote:
> Hi,
>
> I am having troubles on deploy a very simple webapp on GFv3.1
> using Eclipse Helios SR1 as IDE.
>
> This is the exception I get,
>
> cannot Deploy PruebaWEB
>
> Deployment Error for module: PruebaWEB: Exception while loading the
> app : java.lang.Exception: java.lang.IllegalStateException:
> ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
> java.lang.NoClassDefFoundError: Lejb/CountryFacade;
>
> This is the code in the ejb project,
>
> public abstract class AbstractFacade<T> {
>
> private Class<T> entityClass;
>
> public AbstractFacade(Class<T> entityClass) {
> this.entityClass = entityClass;
> }
>
> protected abstract EntityManager getEntityManager();
>
> public void create(T entity) {
> getEntityManager().persist(entity);
> }
>
> public void edit(T entity) {
> getEntityManager().merge(entity);
> }
>
> public void remove(T entity) {
> getEntityManager().remove(getEntityManager().merge(entity));
> }
>
> public T find(Object id) {
> return getEntityManager().find(entityClass, id);
> }
>
> public List<T> findAll() {
> javax.persistence.criteria.CriteriaQuery cq =
> getEntityManager().getCriteriaBuilder().createQuery();
> cq.select(cq.from(entityClass));
> return getEntityManager().createQuery(cq).getResultList();
> }
>
> public List<T> findRange(int[] range) {
> javax.persistence.criteria.CriteriaQuery cq =
> getEntityManager().getCriteriaBuilder().createQuery();
> cq.select(cq.from(entityClass));
> javax.persistence.Query q = getEntityManager().createQuery(cq);
> q.setMaxResults(range[1] - range[0]);
> q.setFirstResult(range[0]);
> return q.getResultList();
> }
>
> public int count() {
> javax.persistence.criteria.CriteriaQuery cq =
> getEntityManager().getCriteriaBuilder().createQuery();
> javax.persistence.criteria.Root<T> rt = cq.from(entityClass);
> cq.select(getEntityManager().getCriteriaBuilder().count(rt));
> javax.persistence.Query q = getEntityManager().createQuery(cq);
> return ((Long) q.getSingleResult()).intValue();
> }
> }
>
> And the CountryFacade ejb looks,
>
> @Stateless
> public class CountryFacade extends AbstractFacade<Country> {
>
> @PersistenceContext(unitName = "PruebaJPA")
> private EntityManager em;
>
> protected EntityManager getEntityManager() {
> return em;
> }
>
>
> public CountryFacade() {
> super(Country.class);
> }
> }
>
> Both classes in a package named 'ejb'.
>
> This happened to me with a JEE 5 MDB example developed to deploy on
> glassfish v2.x.
> In the begining I tried on glassfish v3 and that exception was what I
> got. Later I deployed the app
> on glassfish v2.x and it started to run correctly.
>
> Where is it going wrong?
>
> Thanks in advance,
> Jose
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users_at_eclipse.org
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>