Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:12:30+00:00 2026-06-12T02:12:30+00:00

I have an anonymous WebService EJB – webservice calls are working poperly. Now I

  • 0

I have an anonymous WebService EJB – webservice calls are working poperly.

Now I want the WebService to RunAs as a specific SecurityRole.

At the Webservice I have following Annotations:

@Stateless
@WebService
@DeclareRoles({ "LoggedUser" })
@SecurityDomain("my-jboss-real")
@RunAs("LoggedUser")
public class MyWebService { ...

Now I want to access a @EJB with @RolesAllowed({"LoggedUser"}) from an Webservice Method there I get:

ERROR [org.jboss.aspects.tx.TxPolicy] javax.ejb.EJBTransactionRolledbackException: javax.ejb.EJBAccessException.message: 'Caller unauthorized'
WARN  [org.jboss.ejb3.stateless.StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
javax.ejb.EJBTransactionRolledbackException: javax.ejb.EJBAccessException.message: 'Caller unauthorized'
        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)

I’m running on JBoss 5.1GA

Is this the right use of @RunAs or is there another way to do this.

Edit

Added:

@Resource
private WebServiceContext wsCtx;
@Resource
private EJBContext ejbCtx;

myWebServiceMethod(){
     ...
     System.out.println("EJBCtx: " + ejbCtx.getCallerPrincipal());
     System.out.println("EJBCtx: " + ejbCtx.isCallerInRole("LoggedUser"));
     System.out.println("WebContext: " + wsCtx.getUserPrincipal());
     System.out.println("WebContext: " + wsCtx.isUserInRole("LoggedUser"));
     ...

This Outputs:

EJBCtx: anonymous
EJBCtx: false
WebContext: anonymous
WebContext: false
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:12:31+00:00Added an answer on June 12, 2026 at 2:12 am

    JBoss AS 5 and especially 6 are very buggy with regard to a security context and @RunAs in anything but the most basic usecases.

    A large number of those bugs have been fixed in
    AS 7. You could try to setup a test case there and see if you run into the same issue.

    Do realize that @RunAs does not apply to the code that runs in the bean on which the annotation is applied. Instead, it only applies to beans that are called -from- that bean. You could think of it as the “outgoing/outbound” role.

    More troublesome is that Java EE has a serious ommission and that’s that there is no way to also define a RunAs identity. Some servers don’t react well when you define a RunAs role for the “unauthenticated” identity. JBoss has a proprietary annotation for the RunAs identify. You might want to try if this takes you a step further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this anonymous type : var t= new {a=1,b=lalala,c=DateTime.Now}; How can I make
I have a directory with PHP files I do not want anonymous users to
I have an anonymous inner class inside another class ( SomeClass ). Both SomeClass.class.getClasses()
I have an anonymous linq query that I bind to a datagrid, when I
We have this anonymous function in our code, which is part of the jQuery's
I have an anonymous type object that I receive as a dynamic from a
So I have a anonymous type which I have used ToString on, and put
I have setup an anonymous cvs user to be able to check out my
I have a cell array of anonymous function handles, and would like to create
I have a project to setup an anonymous feedback form to our website. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.