Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Call secured Remote EJB from WebClient

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!
Honk if you love justice! And honk twice for tiny ads!
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic