1
votes

I have an ear which contains 2 war files and each war contains stateless ejb and jersey rest classes. The interfaces locate in commons.jar file. The EAR structure looks like this:

EAR
 -- /lib/commons.jar

 -- rest-1.war
      -- stateless-ejb-1.java
      -- jersey-rest-1.java

 -- rest-2.war
      -- stateless-ejb-2.java
      -- jersey-rest-2.java

I am trying to use stateless-ejb-1 from stateless-ejb-2 with @Inject annotation but I get a CDI deployment failure:WELD-001408: Unsatisfied dependencies error during deployment time. When I use @EJB in stateless-ejb-2 then the ear is deployed but I get a remote lookup error while calling jersey-rest-2.

This are my method call chains:

  • jersey-rest-1 > stateless-ejb-1: works fine
  • jersey-rest-2 > stateless-ejb-2 > stateless-ejb-1: I get an ejb-1 lookup error

I do not want to use remote ejb call because everything is packaged in the same ear (I would like to use @Inject instead of @EJB) but it does not work.

I guess that if I pack stateless-ejb-1.java to a jar and put it under EJB/lib than it will work. But I do not want to create a new module in my project just to pack this one file to separated jar file. What is the solution?

1

1 Answers

2
votes

You need to move stateless-ejb-1 into an ejb-jar module in the EAR.

Classes in different WAR files are never visible to each other, even when built into an EAR file.