File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB and Sun One Application server

 
Balaji Thirnrayan
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run the simple EJB given in J2EE tutorials on Sun 's application server.
I am getting following error,
javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/Conver
terBean
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
ava:137)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at ConverterClient.main(ConverterClient.java:46)
Caused by: java.lang.NullPointerException
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:108)
Please let me know what am I missing here, this is my client code. ( The server is rnning and the EJB is deployed properly)
public static void main(String[] args) {
try {
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:8080");
env.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming" );
Context initial = new InitialContext(env);
Context myEnv = (Context) initial.lookup("java:comp/env");
Object objref = initial.lookup("ejb/ConverterBean");
ConverterHome home = (ConverterHome) PortableRemoteObject.narrow(objref,
ConverterHome.class);
Converter currencyConverter = home.create();
BigDecimal param = new BigDecimal("100.00");
BigDecimal amount = currencyConverter.dollarToYen(param);
System.out.println(amount);
amount = currencyConverter.yenToEuro(param);
System.out.println(amount);
System.exit(0);
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic