You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Simphoukham, Southin" <So...@westgroup.com> on 2001/09/21 22:06:31 UTC

Request for help with Oracle 8i connection on Tomcat 4.0

Hi,

I am porting a J2EE app to Tomcat 4.0.  However I keep getting a null for my
datasource retrieval.  I am not sure if Tyrex datasource would do the job.
Or do I need to create my own Oracle datasource.  I should not have too but
who knows.Any help would be appreciated.

I have the Classes12.zip and jdbc2_0-stdext in the \lib directory.

I have the following in my server.xml for Tomcat 4.0.

				<!-- Power Context -->
				<Context path="/PowerSouthin"
docBase="PowerSouthin.war" debug="0" reloadable="true">
					<Logger
className="org.apache.catalina.logger.FileLogger" prefix="Power_log."
suffix=".txt" timestamp="true"/>
					<Resource name="jdbc/OracleDB"
auth="Container" type="javax.sql.DataSource"/>
					<ResourceParams
name="jdbc/OracleDB">
						<parameter>
							<name>user</name>
							<value>xxxxx</value>
						</parameter>
						<parameter>
	
<name>password</name>
							<value>xxxxx</value>
						</parameter>
						<parameter>
	
<name>driverClassName</name>
	
<value>oracle.jdbc.driver.OracleDriver</value>
						</parameter>
						<parameter>
	
<name>driverName</name>
	
<value>jdbc:oracle:thin:@xxx.xxx.xxx.xxx</value>
						</parameter>
					</ResourceParams>
				</Context>
				

I have the following in my web.xml for my application:
<web-app>
	<!-- Standard Action Servlet Configuration (with debugging) -->
	<servlet>
		<servlet-name>action</servlet-name>
	
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
		<init-param>
			<param-name>application</param-name>
			<param-value>ApplicationResources</param-value>
		</init-param>
		<init-param>
			<param-name>config</param-name>
	
<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>debug</param-name>
			<param-value>2</param-value>
		</init-param>
		<init-param>
			<param-name>detail</param-name>
			<param-value>2</param-value>
		</init-param>
		<init-param>
			<param-name>validate</param-name>
			<param-value>true</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<!-- Standard Action Servlet Mapping -->
	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>

	<!-- Resource Ref -->
	<resource-ref>
		<resource-ref-name>
    			jdbc/OracleDB
  		</resource-ref-name>
  		<res-type>
    			javax.sql.DataSource
 		 </res-type>
		<res-auth>
    			Container
  		</res-auth>
	</resource-ref>

I am getting the following console output:

----> In Try
----> ctx is: javax.naming.InitialContext@6de49c
----> envCtx is: org.apache.naming.NamingContext@7f0dde
----> have the initial context
----> dataSourceName =jdbc/OracleDB
----> m_jdbcSource = null

My JDBCSource.java is:

   try {

      if (DEBUG_ON) {
            System.out.println("----> In Try");
        }

        //InitialContext ctx = new InitialContext();
        Context ctx = new InitialContext();
        if (DEBUG_ON) {
            System.out.println("----> ctx is: "+ ctx);
        }
        Context envCtx = (Context) ctx.lookup("java:comp/env");

        if (DEBUG_ON) {
            System.out.println("----> envCtx is: " + envCtx);
        }

        synchronized (ctx) {
        if (DEBUG_ON) {
            System.out.println("----> have the initial context");
        }

        String dataSourceName ="jdbc/OracleDB";
      
        if (DEBUG_ON) {
          System.out.println("----> dataSourceName ="+ dataSourceName);
        }

        //m_jdbcSource = (DataSource) ctx.lookup(dataSourceName);
        m_jdbcSource = (DataSource) envCtx.lookup(dataSourceName);

        if (DEBUG_ON) {
          System.out.println("----> m_jdbcSource = "+ m_jdbcSource);
        }

      } //synchronized
    } catch (Exception e) {
      if (DEBUG_ON) {
        System.out.println(THIS +".initializeJDBCBean() failed. Exception: "
+ e.toString());
    }

      sErrorMessage = e.toString() +" " + THIS + ", method:
initializedJDBCBean.";
      ls.logError(sErrorMessage);
    } // catch