tags:

views:

21

answers:

2

What I basically have is this (obfuscated example of my real domain code):

In CarDaoEar:

@Entity
public class Car {
//...
}

@Stateless
public class CarDao implements CarDaoRemote {
   @PersistenceContext( unitName = "carPersistenceUnit" )
   private EntityManger em;

   public void storeCar( Car car ) {
      em.persist( car );
   }

   public Car findCar( Car car ) {
     return em.find( Car.class, car.getID );
   }
}

@Remote
public interface CarDaoRemote {
   public void storeCar( Car car );

   public Car findCar( Car car );
}

In CarInventoryTimerEar:

@Stateless
public class CarInventoryTimer {

   @EJB
   private CarDaoRemote _carDaoRemote;

   // do some stuff with _carDaoRemote...

}

So the problem is, if I package the Entity & dao bean with CarInventoryTimerEar then the app server complains that I am trying to deploy the Entity again - I understand this. If, however, I don't include the classes I get a ClassNotFoundException - this also makes sense.

I am sure I am not the first one to do something similar to this - so to all you EJB experts out there, what am I doing wrong? How do I make this work?

TIA

A: 

If I'm reading you right you have one ear running where you want to use the EJBs in another. You should be able to create a client jar off of the first that you can include in your second. That way the second ear can use the client jar and not get the ClassNotFoundExceptions.

SOA Nerd
When I do this the app server tries to load the Entity classes in the client jar - maybe I can strip the annotations in the client jar?
javamonkey79
A: 

My solution (which I don't like) is to include the Car & CarDaoRemote class & interface in a "proxy" project devoid of all annotations. I then have CarInventoryTimerEar depend on the proxy project instead of the dao project directly.

I hope this helps someone else.

javamonkey79