users@glassfish.java.net

Re: Caused by: javax.ejb.AccessLocalException: Client not authorized for this i

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Jul 2010 15:20:34 PDT

I've done a very small project to investigate the trouble.
If the servlet has a simple Ejb there is no problem. fine !
@Stateless
public class SampleEJB implements SampleEJBLocal {
     public int test(int value) {
        testEJB.theTest();
        return 2;
    }
}

@WebServlet(name="SampleServlet", urlPatterns={"/SampleServlet"})
public class SampleServlet extends HttpServlet {
    @EJB
    private SampleEJBLocal sample;

 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            out.println(sample.test(23));
        } finally {
            out.close();
        }
    }
...


but if the EJb contains also another EBJ the AccessLocalException occured

@Stateless
public class SampleEJB implements SampleEJBLocal {
    @EJB
    TestEJBLocal testEJB;

    public int test(int value) {
        testEJB.theTest();
        return 2;
    }
}

@Stateless
public class TestEJB implements TestEJBLocal {
    @PermitAll
    public void theTest(){
    System.out.print("this is a test");
    }
}
see example attached
The exception occurred if you try to call the servlet
http://localhost:8080/Sample-web/SampleServlet

Does somebody has any Idea to solve this case ?
[Message sent by forum member 'zolive2']

http://forums.java.net/jive/thread.jspa?messageID=477038