You should change your lookup from "java:comp/env/com/sample/HelloWorld" to "java:/com/sample/HelloWorld".  The "comp/env" scope is only used to lookup bean specific environment attributes that are defined in ejb-jar.xml that is deployed with the ejb.
 
Hope that helps,
 
Dustin
-----Original Message-----
From: jonathan wong [mailto:[EMAIL PROTECTED]
Sent: Monday, June 09, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: [JBoss-user] Hello ! The problem of JNDI in JSP !

Dear all ,
 Hello ! I am a beginner of JBoss 3.0.7 . I encounter a problem of JNDI in JSP . The file structure like follow :
E:\JBoss3T\test_EJB\com\sample\HelloWorld.class
E:\JBoss3T\test_EJB\com\sample\HelloWorldBean.class
E:\JBoss3T\test_EJB\com\sample\HelloWorldHome.class
 
And the ejb-jar.xml like follow :
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar>
    <description>JBoss Hello World Application</description>
    <display-name>Hello World EJB</display-name>
    <enterprise-beans>
        <session>
            <ejb-name>HelloWorld</ejb-name>
            <home>com.sample.HelloWorldHome</home>
            <remote>com.sample.HelloWorld</remote>
            <ejb-class>com.sample.HelloWorldBean</ejb-class>
            <session-type>Stateless</session-type>
     !        <transaction-type>Container</transaction-type>
        </session>
    </enterprise-beans>
</ejb-jar>
 
The jboss.xml like follow :
<jboss>
    <enterprise-beans>
        <session>
            <ejb-name>HelloWorld</ejb-name>
            <jndi-name>com/sample/HelloWorld</jndi-name>
        </session>
    </enterprise-beans>
</jboss>
 
The JSP is as follow :
<%@ page
   session="false"
   isThreadSafe="true"
   isErrorPage="false"
   import="javax.naming.*,
           com.sample.*"
%>
<%
   try {
      Context lContext = new InitialContext();
      HelloWorldHome lHome = (HelloWorldHome) lContext.lookup(
         "java:comp/env/com/sample/HelloWorld"
   );
      HelloWorld lSession = lHome.create();
      out.println( "" + lSession.hello() );
   }
   catch( Exception e ) {
      out.println( "Caugth exception: " + e.getMessage() );
      e.printStackTrace();
   }
%>
 
I also reside the jndi.properties with WEB-INF ( I use the standalone Tomcat ) . The JNDI is displayed in global JNDI Namespace in jmx-console . However , the Tomcat says "Name com is not bound in this Context" . Therefore , what should I further configue ?  


Jonathan
(Wong Yat Sing)
Jonathan Studio
M.P (852) - 91235947
NetMeeting : [EMAIL PROTECTED]
ICQ# 57646152


Do you Yahoo!?
Free online calendar with sync to Outlook(TM).

Reply via email to