Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Call secured Remote EJB from WebClient  RSS feed

Matze Json
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to access a secured @Remote EJB running on an Glassfish v2 instance from a WebClient (WAR) running on another Glassfish v3 instance.

When not securing the Remote EJB via file-realm basic username/password authentication, access from the WAR is no problem simply using annotations @EJB(mappedName="Location of EJB").

But when the EJB is secured - which is pretty usual as also in my case the two applications are running on different machines - then getting access seems to be quite complicated (or what am I doing wrong?!):
1. is there a way to provide the username and password a) via annotations or b) deployment descriptors?

2. if not, how can one lookup the Remote EJB in the Web Client via InitialContext?! Unfortunately, the FAQ in this respect ( does not says anything on accessing secured EJBs and the solution for properties provided there for standalone apps regarding the EJB lookup do not work:
I tried it this way:
Properties props = new Properties();

props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
props.put("", "username");
props.put("", "password");

ic = new InitialContext(props);

myBean = (MyBean) ic.lookup("ejb/MyBean");

but I get the following error:
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at com.sun.enterprise.naming.GlassFishNamingBuilder.createInitialContextFactory(

3. I also tried adding a security constraint (basic authentication with username and password) to the web client hoping the security identity is propagated to the Remote EJB, but that failed also with the exception (although I am not using the RunAs annotation):
iiop.secmechanism_exception Cannot propagate username/password required by target when using run as identity

Can anyone help on this issue?
It can't be so complicated to just call a secured remote EJB from a web client, I think that this is a very common scenario! What am I doing wrong?
Thanks a lot!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!