I have component deployed in common/lib/component.jar and configured many
webapplications
each webapplication use global component through JNDI and my configuration
in server.xml is

<GlobalNamingResources>
<Resource name="vasLogger" auth="Container" type="javax.sql.DataSource"/>

  <ResourceParams name="component">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>

    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>

    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>

  </ResourceParams>
....
</GlobalNamingResources>

Servlet calling components method example is but it doesnot work What
happened?

public void CallJNDIContext {
        InitialContext iCtx = null;
        Context ctx = null;

        try {
            iCtx = new InitialContext();
            ctx = (Context) iCtx.lookup("java:comp/env");

            if (ctx != null) {
                DataSource ds = (DataSource) ctx.lookup("jdbc/component");

                if (ds != null) {
                    connection = ds.getConnection();
                }
            }
        } catch (NamingException e) {
                e.printStackTrace();
        } catch (SQLException e) {
                e.printStackTrace();
        }
    }







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to