Here i will show an simple JSP+Servlet web project how to call or use some ejb resource.
 
Web.xml
 
<servlet>
    <servlet-name>ParamTestServlet</servlet-name>
    <servlet-class>servlets.ParamTestServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ParamTestServlet</servlet-name>
    <url-pattern>/paramtest</url-pattern>
  </servlet-mapping>

<resource-ref id="EJBResRef_1">
    <res-ref-name>java:/EjbcaDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

  <env-entry>
    <description><![CDATA[Default content encoding used to decode form posts]]></description>
    <env-entry-name>contentEncoding</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>UTF-8</env-entry-value>
  </env-entry>
    
    
  <ejb-local-ref id="EJBLocalRef_3">
    <ejb-ref-name>ejb/UserAdminSessionLocal</ejb-ref-name><!-- 采用sun推荐的命名方式  -->
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>ejbBeans.IUserAdminSessionLocalHome</local-home>
    <local>ejbBeans.IUserAdminSessionLocal</local>
    <ejb-link>UserAdminSession</ejb-link> <!-- 必须和被应用的ejb-name匹配 -->
  </ejb-local-ref>
 
jboss-web.xml
 
<jboss-web>


  <resource-ref>
    <res-ref-name>java:/EjbcaDS</res-ref-name>
    <jndi-name>java:/EjbcaDS</jndi-name>
  </resource-ref>

  <depends>jboss.j2ee:module="ejb21.jar",service=EjbModule</depends>
    
</jboss-web>
 
ParamTestServlet.java
InitialContext ctx = new InitialContext();
      System.out.println("Got context");    
        
      useradminhome = (IUserAdminSessionHome) PortableRemoteObject.narrow(
                     ctx.lookup(IUserAdminSessionHome.JNDI_NAME), IUserAdminSessionHome.class );
      System.out.println("LOADED useradminhome BEAN");    
        
      raadminhome     = (IRaAdminSessionHome) PortableRemoteObject.narrow(
                                        ctx.lookup(IRaAdminSessionHome.JNDI_NAME), IRaAdminSessionHome.class );
      System.out.println("LOADED IRaAdminSessionHome BEAN");
        
      IRaAdminSessionRemote raadminsession = raadminhome.create();
      System.out.println("create IRaAdminSessionHome sessionbean");
      String str=raadminsession.find();
      System.out.println("run IRaAdminSessionHome.find() method");
      System.out.println("run IRaAdminSessionHome.find():"+str);
        
      IUserAdminSessionRemote adminsession = useradminhome.create();    
      System.out.println("create useradminhome sessionbean");
      String result=adminsession.setString("demo");        
      
 
 
Attention:
1.
<depends>jboss.j2ee:module="ejb2.1.jar",service=EjbModule</depends>
This ejb2.1.jar should check your jboss's jmx-console!
 
2.
In above, they are should in the same EAR.
 
More info contact me danni-505@hotmail.com