• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create ejb object by calling create method of home interface

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"lyes lyes", please check your private messages.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic