0

I am migrating a large JavaEE web app to a multi-module Maven form.

The roles declared for a specific EJB in the ejb-jar.xml are not being seen by that EJB when I run the multi-module web app.

The ejb-jar.xml is identical to the one I had in the single large web app (which worked fine), except for a change in the qualified name (packaging) of the EJB, which has been carefully matched in the new ejb-jar.xml.

The @Resource SessionContext ctx is working: it can see the Principal etc.

It just does not detect any of the roles from the ejb-jar.xml any more, so ctx.isCallerInRole(String) always fails.

I can use @DeclareRoles annotations in the EJB and it works (but that's not an acceptable solution, it's just for diagnosis).

The ejb-jar.xml in the EJB module is at:

.../src/main/resources/META-INF/ejb-jar.xml

Maven builds it to:

.../target/classes/META-INF/ejb-jar.xml

And it definitely makes it into the final target jar for the EJB module (I have even extracted it and checked).

The deployment is to the same Glassfish or Payara server as for the single large web app (where it worked fine).

I am not getting any relevant logged warnings of any kind during deployment.

Grateful for ideas about what else could be preventing the system from apparently catching the ejb-jar.xml on deployment of the multi-module web app project, or for suggestions on how to further diagnose the problem.



EDIT 2017-03-15: I found (after some sleep) that if I copy (or move) the ejb-jar.xml from the EJB module to .../src/main/webapp/WEB-INF/ of the web module it works as expected. But this is not quite a solution, as I want different web modules to be able to use the same EJB module, and also it means that the <security-role> and any <security-role-ref> and <role-link> are in one web module not the EJB module. I am also using the EJB module for REST services (independent of web role context) and want the same role concepts (so defined in the EJB module).

  • 1
    Do one or both builds of your application use a `glassfish-ejb-jar.xml` file? – Steve C Mar 14 '17 at 12:30
  • This particular project does not use any `glassfish-ejb-jar.xml` file yet (no glassfish-specific descriptors). – Webel IT Australia - upvoter Mar 15 '17 at 01:04
  • I found (after some sleep) that if I copy (or move) the `ejb-jar.xml` from the EJB module to `.../src/main/webapp/WEB-INF/` of the web module it works as expected. But this is not quite a solution, as I want different web modules to be able to use the same EJB module, and also it means that the `` and any `` and `` are in the web module not the EJB module. I am also using the EJB module for REST services (independent of web role context) and want the same role concepts (so defined in the EJB module). – Webel IT Australia - upvoter Mar 15 '17 at 01:07
  • I wanted to head down the relationship query path, but `@DeclareRoles` and `` are supposed to represent the same piece of configuration. – Steve C Mar 15 '17 at 02:04
  • is there any other ejb-jar.xml in the modules and loaded before this one? – The Bitman Mar 16 '17 at 23:18
  • @TheBitman Good question, no other `ejb-jar.xml` are in modules other than the core EJB module (unless I move it to the core web module, in which case the security roles are then caught on deployment by the EJBs in the EJB module). Thanks for input. – Webel IT Australia - upvoter Mar 18 '17 at 05:29

0 Answers0