Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

create ejb object by calling create method of home interface  RSS feed

 
lyes bensaada
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hellow friends,

i have developped an ejb(TestBean), here what i have written :

Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
env.setProperty("java.naming.provider.url", "iiop://localhost:3700");
InitialContext ic = new InitialContext(env);
Object objref = ic.lookup("ejb/TestBean");
TestHome tt =(TestHome) PortableRemoteObject.narrow(objref, TestHome.class);
ty=tt.create();

but when i try to do this : tt.create(); an error message appear :

java.lang.NullPointerException in this line.

is there someOne to help me.

thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65832
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"lyes lyes", please check your private messages.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Object objref = ic.lookup("ejb/TestBean");
TestHome tt =(TestHome) PortableRemoteObject.narrow(objref, TestHome.class);
ty=tt.create();

but when i try to do this : tt.create(); an error message appear :

java.lang.NullPointerException in this line.


Looks like the object returned from the JNDI lookup is null. Are you sure the JNDI bean is bound to the JNDI name ejb/TestBean? (well, i would have expected a NameNotFoundException, if the name was incorrect). Which application server are you using and can you post the entire exception stacktrace?
[ November 06, 2007: Message edited by: Jaikiran Pai ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!