Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Hayrah Burki   on Jun 07 In Java Category.

  
Question Answered By: Russell Burns   on Jun 07

your instruction was great but i think some thing is misunderstood because that code i've just represented it is just part of my application.
one of the most tedious parts of EJB2.x development was writing the same few lines of boilerplate code many times to do a JNDI lookup whenever you needed to access an ejb  or a container managed resource such as a pooled database connection handle. I know in EJB3.0, JNDI lookups have been turned into simple configuration. Using metadata.
In your example if you want to access the YourFacadeBean EJB from another EJB or Servlet you can choose another approach or better say the new method
........
@EJB private YourFacadeBean yourFacadeBean;
private void  callBean() {
System.out..println(yourUserFacade.sayHello());
}
........
Did you see this is a miracle.
My problem  is here, my main  question is how can i implement this approach?
for example in JBoss when you want to call YourFfacadeBean
you have to follow this way (In ejb3  i think it's not recommended as i explained about it on above side).


import javax.naming.*;
import java.util.Properties;

public class  CallBean {
 public  static void main(String[] myString) {
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
prop.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
prop.setProperty("java.naming.provider.url","localhost:1099");

Context ctx = new InitialContext(prop);
YourFfacadeBean yourFfacadeBean = (YourFfacadeBean)ctx.lookup("YourFfacadeBean/remote");
System.out.println(yourFfacadeBean.sayHello());
}
}

you see it's boring.
of course in ejb3 we have a better solution for solving this disaster;

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on RMI and JNDI ejb3 problem Or get search suggestion and latest updates.


Tagged: