Hi All

I'm having trouble getting a stateless session bean to lookup a
<resource-ref> element defined in ejb-jar.xml. I have the following setup:

In ejb-jar.xml :

  <session>
  <ejb-name>ProductBrowser</ejb-name>
  <home>aremissoft.construction.ejb.pricing.ProductBrowserHome</home>
  <remote>aremissoft.construction.ejb.pricing.ProductBrowser</remote>

<ejb-class>aremissoft.construction.ejb.pricing.ProductBrowserBean</ejb-class
>
  <session-type>Stateless</session-type>
  <transaction-type>Container</transaction-type>
  <resource-ref>
    <description>Reference to the database</description>
    <res-ref-name>ProductBrowserDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
   </session>

In jboss.xml :

     <resource-managers>
       <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
          <res-name>PriceDatabase</res-name>
         <res-jndi-name>Interbase</res-jndi-name>
       </resource-manager>
     </resource-managers>

     <enterprise-beans>
       <session>
          <ejb-name>ProductBrowser</ejb-name>
          <jndi-name>ProductBrowser</jndi-name>
          <configuration-name>Default Stateless
SessionBean</configuration-name>
          <resource-ref>
            <res-ref-name>ProductBrowserDataSource</res-ref-name>
            <resource-name>PriceDatabase</resource-name>
          </resource-ref>
       </session>
      <secure>true</secure>
     </enterprise-beans>

In jboss.conf :

<MLET CODE = "org.jboss.jdbc.DataSourceImpl"
ARCHIVE="jboss.jar,interclient.jar" CODEBASE="../lib/ext/">
   <ARG TYPE="java.lang.String"
VALUE="jdbc:interbase://localhost/C:/interdbs/prices1.gdb">
   <ARG TYPE="java.lang.String" VALUE="Interbase">
   <ARG TYPE="java.lang.String" VALUE="interbase.interclient.Driver">
   <ARG TYPE="java.lang.String" VALUE="TERRY">
   <ARG TYPE="java.lang.String" VALUE="xxxxx">
</MLET>

The bean jar deploys okay but when I try to do a lookup within the bean
using:

try {
         InitialContext ic = new InitialContext();
          DataSource ds =
(DataSource)ic.lookup("java:comp/env/ProductBrowserDataSource");
            return ds.getConnection();
        } catch (SQLException se) {
     throw new GeneralFailureException(se);
        } catch (NamingException ne) {
     throw new GeneralFailureException(ne);
        }

I get the following exception:

[Default] General Failure Exception:javax.naming.NameNotFoundException:
ProductBrowserDataSource not
 bound:ProductBrowserDataSource not bound

but if I use the direct JNDI name of the datasource i.e.:

DataSource ds = (DataSource)ic.lookup("Interbase");

It works okay. This however removes the separation between development and
deployment.

Any suggestions? (I'm using the latest CVS - when this was posted ;-)

Regards

Terry Child



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to