[GLASSFISH-20689] @runAs annotation fails when ejb is called from servlet during deplyment Created: 09/Jul/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: security
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: rsoika Assignee: Nithya Ramakrishnan
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)



 Description   

I have a EAR project containing an EJB and a WEB module. The EJB module contains a stateless session ejb with a runAs annotation:

@DeclareRoles({ "org.imixs.ACCESSLEVEL.MANAGERACCESS" })
@RunAs("org.imixs.ACCESSLEVEL.MANAGERACCESS")
@Stateless
@Local
public class UserGroupService {
....

In the web module there is a Servlet defined whith a loadOnStartup=1 option:

@WebServlet(loadOnStartup=1)
public class SetupServlet extends HttpServlet {
	@EJB
	UserGroupService userGroupService;

To declare the RunAs annotation the EAR module contains a glassfish-application.xml file with

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS</role-name>
		<group-name>IMIXS-WORKFLOW-Manager</group-name>
		<principal-name>IMIXS-WORKFLOW-Service</principal-name>
	</security-role-mapping>	

So I think I map a principal to that role which is used to by the RunAs annotation.
In addition the ejb module contains a glassfish-ejb-jar.xml file with :

	<ejb>
			<ejb-name>UserGroupService</ejb-name>
			<principal>
				<name>IMIXS-WORKFLOW-Service</name>
			</principal>
		</ejb>

During deployment the servlet should call some methods of the UserGroupService. The UserGroupService is injected as far as I can see during debugging.
But now I got a "Could not create stateless EJB" exception when the servlet tries to call a EJB method.

The same ear deploys on GlassFish 3.1.2.2 without any problem.
Are there any changes in the security definition? Or is there something going wrong during the deployment process of GlassFish4



 Comments   
Comment by rsoika [ 30/Dec/13 ]

I am now running nightly build glassfish4.0.1.b04-12_28_2013
But it seems that I have still the same issue. The only log file information is:

WARNING: A system exception occurred during an invocation on EJB ProfileService, method: public org.imixs.workflow.ItemCollection org.imixs.marty.ejb.ProfileService.lookupProfileById(java.lang.String)

Can I do anything to provide you with helpful information? Or can you tell me what that issue depends on?

Comment by rsoika [ 30/Dec/13 ]

During deployment I see the following warning. But no information why that warning is shown:

[2013-12-30T16:09:01.431+0100] [glassfish 4.0] [WARNING] [] [javax.enterprise.system.tools.deployment.dol] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1388416141431] [levelValue: 900] [[
enterprise.deployment.backend.computeRunAsPrincipal]]

Comment by rsoika [ 14/Jan/14 ]

I have not tested the application with WildFly. I can deploy the same application without any problems on WildFly 8

Comment by Nithya Ramakrishnan [ 05/Mar/14 ]

Hi,

Have you tried moving the security-role-mapping to glassfish-ejb-jar.xml from glassfish-application.xml ?
If the same prb exists, couuld you pls attach the app ?

Generated at Tue Dec 06 18:58:02 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.