users@glassfish.java.net

Re: Security Role

From: Art <ainfo_at_patteran.com>
Date: Thu, 01 Jun 2006 16:48:03 -0700

+1 - I had this same error too. I posted the following to nbusers but I
have heard nothing yet.

Date: Thu, 01 Jun 2006 12:54:27 -0700
From: Art <ainfo_at_patteran.com>
To: nbusers_at_netbeans.org
Subject: error deploying ear : Linked policy contexts have different
roleToSubjectMaps

Hello,

I am trying to deploy my application as a ear on glassfish b48 on nb5.5
(20060531200). I am getting the PolicyContextException shown below:

Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Cannot
generate policy file for test. --
javax.security.jacc.PolicyContextException: java.lang.RuntimeException:
Linked policy contexts have different roleToSubjectMaps
(test/test-WebModule_war)<->(test/test-EJBModule_jar)
        at
com.sun.enterprise.security.SecurityUtil.generatePolicyFile(SecurityUtil.java:242)
        at
com.sun.enterprise.deployment.backend.AppDeployerBase.generatePolicy(AppDeployerBase.java:379)
        at
com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:130)
        at
com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
        at
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
        at
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
        at
com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
        at
com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
        at
com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
        at
com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)

I have set my identical <security-role> in web.xml and application.xml.
 I set my EJB class roles as annotations using
@RolesAllowed(value="ROLE1") leaving the ejb-jar.xml file blank. I also
set identical <security-role-mapping> in sun-web.xml and
sun-ejb-jar.xml and sun-application.xml to no avail.

In this post it is stated we should not do this:

http://forums.java.net/jive/thread.jspa?threadID=14134&tstart=135

"In 9.1, we will fail deployment for empty ejb jar with an error message
indicating the cause.

So if you see this inconsistent module state error, please check your
ejb jar to make sure you have ejbs inside. You should either have an
ejb-jar.xml with all the bean elements defined. Or if you use
annnotations and not having an ejb-jar.xml, your need to have component
level annotations in your bean source code: @Stateless, @Stateful,
@MessageDriven.

Additional note: persistent unit (@Entity) should not be packaged as ejb
jar(specified as ejb module in the application.xml)."

My ejb-jar is empty because I use annotations to set the security roles.
How do I get rid of this error? Any help is much appreciated.

Dennis Gesker wrote:
> <security-role>
> <role-name>employee</role-name>
> </security-role>
>
> When I add the element above to my application.xml I get a "Linked
> policy contexts have different roleToSubjectMaps" error. This is a fresh
> project.
>
> Could someone offer a hint as to what is happening? Shouldn't the
> application.xml cover both my ejb.jar and war files?
>
> Dennis
>