users@glassfish.java.net

Re: Security Role

From: Shing Wai Chan <Shing-Wai.Chan_at_Sun.COM>
Date: Fri, 02 Jun 2006 15:23:25 -0700

Art wrote:
> Shing,
>
> I do have 18 compiled 3.0 entity ejbs in my ejb jar archive file, but my
> ejb-jar.xml file is empty of any content (<ejb-jar/> namespace
> declarations omitted due to space limitations) because I use annotations
> to declare the EJB type and security roles. Based on previous responses
> on this list I was not sure if you wanted me to include the ejb-jar.xml
> file in my ejb jar archive file, so I tried including and excluding the
> ejb-jar.xml file. The results of this exercise were given in my
> previous e-mail.
>
If you use annotations, then you don't need to have the ejb-jar.xml.
My previous email corresponds to another common user errors of having an
ejb-jar without any ejb (including from annotations and ejb-jar.xml).

In the email below, it seems that you are using auto-deploy.

Hong,
Can you help Ark on this?

Thanks.
     Shing Wai Chan
> - Art
>
> Shing Wai Chan wrote:
>
>> Art wrote:
>>
>>> In section 2.1 of EJB 3.0 Simplified API
>>>
>>> "Metadata annotations may be used as an alternative to the deployment
>>> descriptors that were required by
>>> earlier versions of the Enterprise JavaBeans specification."
>>>
>>> My ejb jar file is empty because I use annotations instead.
>>>
>>>
>> If your ejb jar is empty, then there is no classes there, then how can
>> you have annotations.
>> Can you clarify what you mean?
>>
>>> If I remove my ejb-jar.xml file I get the error:
>>>
>>> [#|2006-06-02T13:04:55.796-0700|INFO|sun-appserver-pe9.0|javax.enterprise.system
>>>
>>> .tools.deployment|_ThreadID=11;_ThreadName=Timer-3;|[AutoDeploy]
>>> Exception occur
>>> es while invoking backend deployment service for file :
>>> C:\bin\glassfish\domains\domain1\autodeploy\test-EJBModule.jar. --
>>> Cannot determine the Java EE module type for
>>> C:\bin\glassfish\domains\domain1\autodeploy\test-EJBModule.jar -
>>> - Cannot determine the Java EE module type for
>>> C:\bin\glassfish\domains\domain1\autodeploy\test-EJBModule.jar|#]
>>>
>>> If I leave in the ejb-jar.xml file I get the error listed in my old
>>> email.
>>>
>>> Do you have any sugestions?
>>>
>>> Thanks,
>>>
>>> Art
>>>
>>> Dennis Gesker wrote:
>>>
>>>
>>>> Shing-Wai:
>>>>
>>>> Exactly right. My original test app did not have any ejbs in the
>>>> ejb.jar. I didn't realize this was a violation of the spec. As soon as I
>>>> added the empty session bean the problem cleared up.
>>>>
>>>> Dennis
>>>>
>>>> Shing Wai Chan wrote:
>>>>
>>>>
>>>>> Dennis Gesker wrote:
>>>>>
>>>>>
>>>>>> Art:
>>>>>>
>>>>>> I just posted my logs for Shing-Wai to examine. However, after adding
>>>>>> a single session bean (no methods) the app deployed. I guess I don't
>>>>>> know enough about how things are supposed to work to know if this is
>>>>>> really a bug or just a curious happening.
>>>>>>
>>>>>>
>>>>> Does it means your original test-EJBModule_jar does not have any ejb?
>>>>> It is illegal to have an ejb jar without ejb.
>>>>>
>>>>> Hi Hong,
>>>>> Do you remember which build has this fix?
>>>>>
>>>>> Thanks.
>>>>> Shing Wai Chan
>>>>>
>>>>>
>>>>>> Dennis
>>>>>>
>>>>>> Art wrote:
>>>>>>
>>>>>>
>>>>>>> +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
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Dennis R. Gesker
>>>>>> email: dennis_at_alamon.com
>>>>>> gpg key: 0xEFA10A51
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>