2
votes

I have an application ("CC") containing two modules: CC-ejb and CC-war. CC-ejb contains JPA entities and facades which CC-war uses. This application works correctly. Now I create another one ("CINT") with also two modules: CINT-ejb and CINT-war. In web module I need to access objects provided by CC-ejb. I use NetBeans 7.1 for development and Glassfish 3.1.1 for deployment.


In CC-ejb I have an interface:

/* ... */
import javax.ejb.Local;

@Local
public interface CallDetailsFacadeLocal {
        /* ... */

and an implementing class:

/* ... */
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
/* ... */
import tp.coma.data.entities.CallDetails;

@Stateless
public class CallDetailsFacade
            extends AbstractFacade<CallDetails>
            implements CallDetailsFacadeLocal {
    @PersistenceContext(unitName = "CC-ejbPU")
    private EntityManager em;
    /* ... */

In CINT-war I refer to it in one of my beans:

/* ... */
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import tp.coma.data.beans.CallDetailsFacadeLocal;
/* ... */

@ManagedBean(name = "bookingController")
@SessionScoped
public class BookingController implements Serializable {
    /* ... */
    @EJB
    private CallDetailsFacadeLocal cdrFacade;
    /* ... */

When deploying CINT (CC is already up and running) I get the following message:

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Ltp/coma/data/beans/CallDetailsFacadeLocal;java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Ltp/coma/data/beans/CallDetailsFacadeLocal;. Please see server.log for more details.

In server log I can see:

[#|2012-03-28T12:42:42.236+0200|SEVERE|glassfish3.1.1|global|_ThreadID=22;_ThreadName=Thread-2;|Class [ Ltp/coma/data/beans/CallDetailsFacadeLocal; ] not found. Error while loading [ class tp.coma.cint.jsf.BookingController ]|#] [#|2012-03-28T12:42:42.252+0200|SEVERE|glassfish3.1.1|global|_ThreadID=22;_ThreadName=Thread-2;|Class [ Ltp/coma/data/beans/CallDetailsFacadeLocal; ] not found. Error while loading [ class tp.coma.cint.jsf.BookingController ]|#]

And a few (eight) exception stack traces.

What am I doing wrong??

1
Seem like you haven't included CallDetailsFacadeLocal class in the second app.andbi
CC-ejb project is added to CINT-war libraries in "project properties" and set not to be included in the package.ManieQ
@ManielQ, at least interface must be included.andbi

1 Answers

1
votes

If you are doing builds with maven, read about generating a client jar along with your ejb jar. http://maven.apache.org/plugins/maven-ejb-plugin/examples/ejb-client-dependency.html

If you are doing ant builds, create a task that generates a client jar, just include **/*Local.jar, or whatever pattern makes sense for your project.

And don't forget about the *$1.class files, they can bite you later. For example if you do a switch on an Enum, java generates a anonymous class, and you'll end up with XYZ$1.class, and depending on what it is, you'll need to exclude or include it. In my case maven included the generated $1.class from a session bean implementation. Then the different classloaders got mad that there were two copies of this anonymous class. (IllegalAccessError)