Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NameNotFoundException in EJB? could anyone tell me?

 
frankie huang
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a NameNotFoundException in my EJB's client. "javax.naming.NameNotFoundException: myes not bound" ( "myes" is the name of my war).
I depoly a .jar file(EJBs) and a .war file.
The .war contains:
[index.jsp]
-------------------------------------------------
try {
//Properties props = System.getProperties();
//Context ctx = new InitialContext(props);
Context ctx = new InitialContext();
HelloHome lHome = (HelloHome) ctx.lookup("java:comp/env/ejb/myestest/Hello");
Hello hello = lHome.create();
out.println("return:"+hello.hello());
}catch( Exception e ) {
out.println( "Caugth exception: " + e.getMessage() );
e.printStackTrace();
}
-------------------------------------------------
[WEB-INF/web.xml]
-------------------------------------------------
<ejb-ref>
<ejb-ref-name>ejb/myestest/Hello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.funyear.myes.test.HelloHome</home>
<remote>com.funyear.myes.test.Hello</remote>
</ejb-ref>
-------------------------------------------------
[WEB-INF/jboss-web.xml]
-------------------------------------------------
<ejb-ref>
<ejb-ref-name>ejb/myestest/Hello</ejb-ref-name>
<jndi-name>ejb/myes/Hello</jndi-name>
</ejb-ref>
-------------------------------------------------
The .jar file contains:
[ejb-jar.xml]
-------------------------------------------------
<session >
<description><![CDATA[stateless session bean]]></description>
<ejb-name>com.funyear.myes.test.Hello</ejb-name>
<home>com.funyear.myes.test.HelloHome</home>
<remote>com.funyear.myes.test.Hello</remote>
<ejb-class>com.funyear.myes.test.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
-------------------------------------------------
[jboss.xml]
-------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>com.funyear.myes.test.Hello</ejb-name>
<jndi-name>com/funyear/myes/test/Hello</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>
-----------------------------------------------
and beans.
Is there anyone know why? could you tell me? thank you very much!
[ December 30, 2002: Message edited by: frankie huang ]
 
meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You are getting the NameNotFoundException because you are trying to lookup an object(Hello) in the location (comp/env/ejb/myestest) and your ejb object is not present over there.
Where to look for ::
1. Check and make sure that you are using the same JNDI name that you binded your object with.
go through the following links
a. http://www.jboss.org/online-manual/HTML/ch01s15.html
b. http://www.jboss.org/online-manual/HTML/ch05.html
let me know if you have any more questions
Regards
Meka Toka
 
frankie huang
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much! I got it.
and I found the template project in the jboss is a very good start point for beginer.
Originally posted by meka toka:
Hi,
You are getting the NameNotFoundException because you are trying to lookup an object(Hello) in the location (comp/env/ejb/myestest) and your ejb object is not present over there.
Where to look for ::
1. Check and make sure that you are using the same JNDI name that you binded your object with.
go through the following links
a. http://www.jboss.org/online-manual/HTML/ch01s15.html
b. http://www.jboss.org/online-manual/HTML/ch05.html
let me know if you have any more questions
Regards
Meka Toka
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic