as application server I use GlassFish to create my new Java EE 6 application.
I have two projects in my workspace, resp. on one sever.
The first is a pure EJB Project including some EJBs with local and remote accessibility. (I am using @remote and @local in the EJB. Interfaces stay pure.)
The second is a web project trying to connect one of the EJBs from the first module using InitialContext-lookup. Due to the fact that both modules are on the same server, I am using the local interface for communication. I casted the retrieved object (after lookup) to "Object" and it worked fine. But as a simple object: useless.
To get the correct EJB-Instance I extracted the interfaces (local and remote) of the EJBs in an external jar-file and added it in both modules. The result is that my EJBs cannot be deployed anymore, because the new build Versions seem to be invalid.
Is there a probem with @remote and @local annotations in EJBs having the interfaces stored in an external jar?
Thanks for your help :-)
EDIT:
The EJB looks like this:
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import de.myapp.business.user.facade.UserServiceFacadeLocal;
import de.myapp.business.user.facade.UserServiceFacadeRemote;
@Stateless
@Remote(value=UserServiceFacadeRemote.class)
@Local(value=UserServiceFacadeLocal.class)
public class UserServiceFacade implements UserServiceFacadeLocal, UserServiceFacadeRemote
{ ... }
The error during publishing:
cannot Deploy myappBusiness
Deployment Error for module: myappBusiness: Error occurred during deployment: Exception while deploying the app [myappBusiness] : Invalid ejb jar
[myappBusiness]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.. Please see server.log for more details.
The server.log says this:
INFO: User [admin] from host 127.0.0.1 does not have administration access
WARNUNG: Error in annotation processing: java.lang.NoClassDefFoundError: de/myapp/business/user/facade/UserServiceFacadeLocal
SCHWERWIEGEND: Exception while deploying the app [bacchusBusiness] SCHWERWIEGEND: Invalid ejb jar [bacchusBusiness]: it contains zero ejb.
The imports work well. No Error, no Exception. But if the server cannot find the interfaces, the EJB might appear wrong.