geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stig Even Larsen <s...@nimra.no>
Subject Re: request.isUserInRole("some-role") always return false after @EJB injection
Date Thu, 19 Jun 2008 07:06:13 GMT
David Jencks wrote:
> On Jun 18, 2008, at 4:31 AM, Stig Even Larsen wrote:
>> <snip>
>> Hi again,
>>
>> I think I've found an related error.
>> I use javaBeans for wrapping Session EJB via jndi (one-to-one, method 
>> to method) to avoid to much java code in jsps.
>>
>> request.isUserInRole() always return false no mather how many times it 
>> is called. Is seems like the jndi lookup prevents the isUserinRole to 
>> work normally.
>>
>> Should I file a new bug-report or is this the same problem describe 
>> with EJB injection?
>>
>> An example.
>>
>> I have an stateless session bean (EJB):
>> @Stateless
>> public class TimeUtilsBean implements TimeUtilsLocal {
>>
>>    public String getString() {
>>        return "Hello from Stateless EJB!";
>>    }
>> }
>>
>> A javaBean EJB wrapper:
>> public class EJBWrapper {
>>
>>    private TimeUtilsLocal lookupTimeUtilsBean() {
>>        try {
>>            Context c = new InitialContext();
>>            return (TimeUtilsLocal) 
>> c.lookup("java:comp/env/TimeUtilsBean");
>>        } catch (NamingException ne) {
>> System.out.println("NameingException: "+ne.getMessage());
>>        }
>>    }
>>
>>
>>    public String getDate(){
>>        return(this.lookupTimeUtilsBean().getString());
>>    }
>> }
>>
>>
>> A form protected (j_security_check) jsp
>>
>> <%@page contentType="text/html" pageEncoding="UTF-8" 
>> import="no.nimra.ejb.wrapper.EJBWrapper "%>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>   "http://www.w3.org/TR/html4/loose.dtd">
>> <jsp:useBean id="nisAdmin" class="no.nimra.ejb.wrapper.EJBWrapper" 
>> scope="session" />
>>
>> <html>
>>    <head>
>>        <meta http-equiv="Content-Type" content="text/html; ">
>>        <title>JSP Test</title>
>>    </head>
>>    <body>
>>
>>        <h2>Role test</h2>
>>
>>        Time: <%= nisAdmin.getDate() %>
>>
>>        <%if(request.isUserInRole("partners")){%>
>>            user is partner :)
>>        <%}else{%>
>>            user is NOT partner :(
>>        <%}%>
>>    </body>
>> </html>
>>
>>
> 
> My jsp deciphering skills are not the best but it looks to me as if the 
> role check is done after the ejb lookup.  This is the subject to the 
> same problem as in GERONIMO-4119 and ought to work properly in the 
> latest code in svn (in all branches): there's a test case in trunk 
> checking that this scenario works.  Which code are you seeing the 
> problem with?
> 
> thanks
> david jencks
> 

Hi David,

I'm using Geronimo 2.0.2 (also testet with equal result in 2.0.3 SNAPSHOT)

You are right. EJB lookup was done before role check. If I do a role 
check before EJB lookup an preserves these results we have an 
alternative way until this malfunction is corrected.

When do you expect the next 2.1. (or 2.2) release?

Regards,
Stig Even Larsen

Mime
View raw message