tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Galbayar" <galba...@mobinet.mn>
Subject JNDI configuration in server.xml
Date Wed, 22 Oct 2003 06:44:22 GMT
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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message