1

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.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
  • separate jar is not a problem, for sure; what do you mean by 'the new build Versions seem to be invalid'? provide a stack trace please – Wacław Borowiec Feb 10 '12 at 15:14
  • ok, I added a few information. – Ludwig Nansen Feb 11 '12 at 08:16
  • Do you have the same method names in the Local and Remote interfaces? I.e. UserServiceFacadeLocal.doMyStuff and UserServiceFacadeRemote.doMyStuff? See BMnotPartOfRBIandLBI line at http://wiki.netbeans.org/wiki/view/EJBVerification – JScoobyCed Feb 11 '12 at 09:16
  • Even if I remove the remote interface (I don't need it in the moment) and remove the annotation from the EJB, I am still not able to deploy the project. – Ludwig Nansen Feb 11 '12 at 10:20
  • Did you check the generated .EAR? Is it possible that the .JAR of your EJB package is included twice: at /my-ejb.jar and at /lib/my-ejb.jar – JScoobyCed Feb 11 '12 at 11:15
  • I just found one jar-File. When deploying the jar cannot be found / it is prob. not included in the classpath. I cannot add it to the manifest to be considered, because Class-Path entries would not work with ext. jar-files. – Ludwig Nansen Feb 13 '12 at 10:58
  • http://stackoverflow.com/questions/4763960/accessing-a-stateless-ejb-from-another-instance-of-glassfish/10194057#10194057 – nihar Apr 17 '12 at 15:27
  • where are `UserServiceFacadeLocal` and `UserServiceFacadeRemote`? I think you need those in your lib folder...maybe. – Thufir Sep 19 '14 at 18:02

0 Answers0