hopefully this will be a simple question for someone out there.  I'm trying
to use an already configured datasource from an ejb, but i'm getting mixed
up on how the JNDI name is bound.  I'm using jboss 2.4.4 with tomcat 4.0.1.
I've tried several different JNDI names, and servlets are able to use the
literal JNDI name from the jboss.jcml, but my EJB can't connect.

any help would be greatly appreciated.  thanks.

EJB DAO source code:
--------------------
Context naming = new InitialContext();
DataSource dataSource = (DataSource)
naming.lookup("java:comp/env/jdbc/mcs/mcsuser);
connection = dataSource.getConnection();

ejb.xml
--------------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd";>

<ejb-jar>
  <description>Machine Crewing System Enterprise Java Beans</description>
  <display-name>MCS EJB</display-name>
  <enterprise-beans>
    <entity>
      <description>Employee BMP</description>
      <display-name>EmployeeEJB</display-name>
      <ejb-name>EmployeeEJB</ejb-name>
      <home>bpc.mcs.ejb.employee.EmployeeHome</home>
      <remote>bpc.mcs.ejb.employee.Employee</remote>
      <ejb-class>bpc.mcs.ejb.employee.EmployeeEJB</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>False</reentrant>
      <security-identity>
        <description></description>
        <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
        <res-ref-name>jdbc/mcs/mcsuser</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
    </entity>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      <method>
        <ejb-name>EmployeeEJB</ejb-name>
            <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
</ejb-jar>

jboss.xml
--------------------
<?xml version="1.0"?>
<jboss>
  <enterprise-beans>
    <entity>
          <ejb-name>EmployeeEJB</ejb-name>
          <jndi-name>ejb/mcs/employee</jndi-name>
          <resource-ref>
            <res-ref-name>jdbc/mcs/mcsuser</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>jdbc/mcs/database</jndi-name>
          </resource-ref>
        </entity>
  </enterprise-beans>
</jboss>

jboss.jcml
--------------------
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=jdbc/mcs/database">
  <attribute name="PoolName">jdbc/mcs/database</attribute>
  <attribute
name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attr
ibute>
  <attribute name="URL">jdbc:oracle:thin:@xxx.xx.xxx:orcl</attribute>
  <attribute name="JDBCUser">blah</attribute>
  <attribute name="Password">blah</attribute>
  <attribute name="MaxSize">20</attribute>      
  <attribute name="IdleTimeout">300000</attribute>
  <attribute name="IdleTimeoutEnabled">true</attribute>
  <attribute name="GCMinIdleTime">300000</attribute>
  <attribute name="GCEnabled">true</attribute>   
  <attribute name="GCInterval">120000</attribute>
</mbean>

_______________________________________________________________

Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to