I am in the process of converting a large J2EE app from EJB 2 to EJB 3 (all stateless session beans, using glassfish 2.1.1), and running out of ideas.
The first EJB I converted (let's call it Foo) ran without major problems (it was the only one in its ejb-module and I could completely replace the deployment descriptor with annotations) and the app ran fine. But after converting the second one (let's call it Bar, one of several in a different ejb-module) there is a weird combination of problems:
The app deploys without errors (nothing in the logs either)
There is an error when looking up Bar via JNDI
When looking at the JNDI tree in the glassfish admin console, Bar is not present at all.
Then when I look at the logs, I see this (Foo is the correct name of the EJB's remote interface of the first converted, previously working EJB):
Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interface Foo [Root exception is java.lang.ClassNotFoundException: Foo]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:414)
at com.sun.enterprise.naming.SerialContext.list(SerialContext.java:603)
at javax.naming.InitialContext.list(InitialContext.java:395)
at com.sun.enterprise.admin.monitor.jndi.JndiMBeanHelper.getJndiEntriesByContextPath(JndiMBeanHelper.java:106)
at com.sun.enterprise.admin.monitor.jndi.JndiMBeanImpl.getNames(JndiMBeanImpl.java:231)
... 68 more
Caused by: java.lang.ClassNotFoundException: XXX
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1578)
at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:679)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:348)
... 75 more
This is followed by more exceptions for all the entries that (like Foo) do appear in the JNDI tree. These look like this:
Caused by: javax.naming.NotContextException: BarHome cannot be listed
at com.sun.enterprise.naming.SerialContext.list(SerialContext.java:607)
at javax.naming.InitialContext.list(InitialContext.java:395)
at com.sun.enterprise.admin.monitor.jndi.JndiMBeanHelper.getJndiEntriesByContextPath(JndiMBeanHelper.java:106)
at com.sun.enterprise.admin.monitor.jndi.JndiMBeanImpl.getNames(JndiMBeanImpl.java:231)
... 68 more
However, no exception for Bar, it does not appear in the log at all except one entry during deployment. The other EJBs in the same module do appear, as does Foo.
Any ideas what could cause this or how to diagnose it further? The beans are pretty straightforward:
@Stateless(name = "Foo")
@RolesAllowed("FOOUSER")
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class FooImpl extends BaseBean implements Foo {
I'm also having some problems with the deployment descriptor for Bar (I'd like to eliminate it, but glassfish doesn't seem to like having a bean appear only in sun-ejb-jar.xml, or having some beans in a module declared in the descriptor and others use only annotations), but I can't see how that could cause the ClassNotFoundException on Foo.
Is there a way to see the ClassPath that Glassfish is actually using?