Discussions

EJB programming & troubleshooting: DataSource mapping in ejb-jar.xml & weblogic-ejb-jar.xml

  1. Hi All,

    I am trying to execute a BMP entity bean using weblogic5.1.
    I am getting NameNotFoundException for dma1 while accessing the DataSource using lookup method.
    I am using the following code to access the connection pool.
    Context ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
    ctx = new InitialContext(ht);
    javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("dma1");

    My resource reference tags in ejb-jar.xml is
    - <resource-ref>
      <description />
      <res-ref-name>dma1</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Application</res-auth>
      </resource-ref>

    in weblogic-ejb-jar.xml it is
    - <reference-descriptor>
    - <resource-description>
      <res-ref-name>dma1</res-ref-name>
      <jndi-name>DMA</jndi-name>
      </resource-description>
      </reference-descriptor>

    The connection pool definition in weblogic.properties is
    weblogic.jdbc.connectionPool.DMA=\
           url=jdbc:weblogic:oracle,\
           driver=weblogic.jdbc.oci.Driver,\
           loginDelaySecs=1,\
           initialCapacity=4,\
           maxCapacity=10,\
           capacityIncrement=2,\
           allowShrinking=true,\
           shrinkPeriodMins=15,\
           refreshMinutes=10,\
           testTable=dual,\
           props=user=xyz;password=xyz;server=xyz
    weblogic.jdbc.TXDataSource.DMA=DMA
    weblogic.allow.reserve.weblogic.jdbc.connectionPool.DMA=guest

    Please help me in solving the problem.
    Thanks
    Srinivas.J
  2. I think the lookup should be thru the JNDI name (DMA).
    Try this out.
    Neeraj...