[EJB 3.0 Development] - javax.ejb.EJBAccessException: Caller unauthorized when calling //EJB3 @Service from client code
by Dave Bredesen
Dave Bredesen [http://community.jboss.org/people/dbredesen] created the discussion
"javax.ejb.EJBAccessException: Caller unauthorized when calling //EJB3 @Service from client code"
To view the discussion, visit: http://community.jboss.org/message/546116#546116
--------------------------------------------------------------
Hello,
I'm building an application on JBoss AS 5.1 and ICEFaces. The application runs in a single JBoss instance currently. I'm doing authentication via JAAS, using the DatabaseServerLoginModule, and I'm able to login successfully via ICEFaces as follows:
* CallbackHandler cb = new Handler("someuser", password);
*
* LoginContext lc = new LoginContext("foo", cb);
*
* lc.login();*
Once logged in, I can see clearly that "someuser" has the "admin" role. Now, I have an EJB set up as follows:
* @Service
*
* @Local
*
* @SecurityDomain("foo") // corresponds to the security domain above
*
* public class MyService implements MyServiceLocal {
*
* @RolesAllowed("admin")
*
* public void doSomething() {
*
* // do something
*
* }
*
* }*
I am trying to call MyBean.doSomething() from my ICEFaces client code as follows:
* InitialContext ctx = new InitialContext();
*
* final String name = "MyService/local";
*
* service = (MyServiceLocal) ctx.lookup(name);
*
* service.doSomething(); //* *causes EJBAccessException: Caller unauthorized*
Somehow, the callee doesn't recognize that I am authenticated. I did a bit of debugging, and the caller thinks my principal is "anonymous".
How do I get EJB to recognize my credentials which were established outside of EJB? Do I need to pass some extra information to the InitialContext? (I tried setting Context.SECURITY_PRINCIPAL, with no luck...). Any help would be appreciated!
Thanks,
Dave Bredesen
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546116#546116]
Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 7 months
Re: [jboss-dev-forums] [JBoss Microcontainer Development POJO Server] - Implementing a non-flat deployment for Weld Integration
by Flavia Rainone
Flavia Rainone [http://community.jboss.org/people/flavia.rainone%40jboss.com] replied to the discussion
"Implementing a non-flat deployment for Weld Integration"
To view the discussion, visit: http://community.jboss.org/message/546115#546115
--------------------------------------------------------------
> Pete Muir wrote:
>
> > I've been thinking about correctness all this time. If somebody places a jar in lib and expects that the beans are created upfront when AS starts, then this would not work using your approach.
>
>
> Ok, I think we've got crossed wires. You can't deploy a library jar in some "context" outside a deployment. The beans don't get created or anything outside the context of a deployment.
>
>
>
> Another way to think of it is that a library in default/lib with a beans.xml in it works just like a library in WEB-INF/lib.
In that case, why the lazy approach wouldn't work?
>From what I can see, if it works just like a library in WEB-INF/lib, it means that we will need to provide a BDA for a lib jar only when Weld requests for one through loadBeanDeploymentArchive, right?
Or, if I'm wrong, do you mean that a BDA for every lib jar with a META-INF/beans.xml should be provided as direct or indirect result of BeanDeploymentArchive.getBeanDeploymentArchives() for every BDA in a Deployment?
Explaining better, given commos/lib/mylib.jar with the following structure:
mylib.jar
|_
META-INF/beans.xml
|_
whatever classes in here
Say we create a BDA upfront, let's call it MY_LIB_BDA, and add this BDA to DefalutDomain Classpath. No deployment is created upfront.
Now, say my-ejb.jar with a META-INF/beans.xml file is deployed to deploy dir. We create a Deployment for it, of course, and we create a BDA for it as well. This BDA, called MY_EJB_BDA, belongs to Default Domain Classpath. So, when Weld invokes MY_EJB_BDA.getBDAs(), it should , directly on indirectly (i.e., by walking on the BDA graph structure), reach MY_LIB_BDA?
This is different from the lazy approach in which you are not required to call loadBeanDeploymentArchive in order to obtain MY_LIB_BDA.
Is that what Weld requires us to do?
> Pete Muir wrote:
>
> > Flavia Rainone wrote:
> >
> > > Ales Justin wrote:
> > >
> > > Why the rush? :-)
> > > If you ask me, I would do it lazily aka on_demand.
> > >
> > > Scanning the whole common/lib is gonna be slow,
> > > and imo, people should not be using libs to deploy Weld components -- simply put them in deploy/.
> > >
> > > Or why would you do it upfront?
> Because the Java EE/CDI specs require it.
BTW, I've read the spec sometime ago. Of course I don't remember all the details so, if you think rereading some specific part of it might be useful, let me know.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546115#546115]
Start a new discussion in JBoss Microcontainer Development POJO Server at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 7 months
Re: [jboss-dev-forums] [JBoss Microcontainer Development POJO Server] - Implementing a non-flat deployment for Weld Integration
by Flavia Rainone
Flavia Rainone [http://community.jboss.org/people/flavia.rainone%40jboss.com] replied to the discussion
"Implementing a non-flat deployment for Weld Integration"
To view the discussion, visit: http://community.jboss.org/message/546078#546078
--------------------------------------------------------------
> Ales Justin wrote:
>
> Why the rush? :-)
> If you ask me, I would do it lazily aka on_demand.
>
> Scanning the whole common/lib is gonna be slow,
> and imo, people should not be using libs to deploy Weld components -- simply put them in deploy/.
>
> Or why would you do it upfront?
I've been thinking about correctness all this time. If somebody places a jar in lib and expects that the beans are created upfront when AS starts, then this would not work using your approach.
Thinking about performance, though, I think that we should trade that by better performance, i.e., we should use the suggested lazy approach.
And I don't see any useful scenario where somebody would want to have a bean deployed to lib dir loaded at startup, specially if no other bean deployed in deploy dir has a dependency towards it.
Pete, does the lazy approach fullfills the Weld prerequisites regarding lib jars?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546078#546078]
Start a new discussion in JBoss Microcontainer Development POJO Server at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 7 months