Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Configuring DataSources

Configuring DataSources

2004-02-05       - By Stefan Maric

 Back
Reply:     1     2  

Don't understand why this seems to be so difficult to resolve

Am using JWSDP1.3 - ie Tomcat 5 (Beta ???)  + J2SDK1.4.2

from my initialization Code
      System.out.println("Getting Context info");
  Context initCtx = new InitialContext();
  System.out.println("Got Initial Context");
  Context envCtx = (Context)initCtx.lookup("java:comp/env");
  System.out.println("Got JWSDP Environment Context");
  System.out.println("Getting AIMS DataSource");
  DataSource ds = (DataSource)envCtx.lookup("jdbc/AIMS_DB");
  if(ds != null)
  {
    System.out.println("Got AIMS DataSource");
    try{
      Connection conn = ds.getConnection();
      System.out.println("Got AIMS DB Connection from
Pool");
    }catch(Exception eX){
      eX.printStackTrace();
    }
  }
from my Web.xml
   <!--    JNDI Resources   -->
   <resource-ref>
  <description>AIMS DB Connection</description>
  <res-ref-name>jdbc/AIMS_DB</res-ref-name>
  <res-type>javax.sql.DataSource Source code of javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
   </resource-ref>
from my <xyzContext>.xml
   <ResourceLink name="jdbc/AIMS_DB" global="AIMS_DB"
type="javax.sql.DataSource Source code of javax.sql.DataSource"/>
       </Context>
from my server.xml
      <GlobalNamingResources>
      ....
      <Resource auth="Container" description="AIMS DB" name="AIMS_DB"
scope="Shareable" type="javax.sql.DataSource Source code of javax.sql.DataSource"/>
      ....
      <ResourceParams name="AIMS_DB">
            <parameter>
              <name>factory</name>
              <value>com.pervasive.jdbc.v2.DataSourceFactory</value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:pervasive://<Host>:<Port>/<DBName></value>
            </parameter>
            <parameter>
              <name>password</name>
              <value><Passwrod></value>
            </parameter>
            <parameter>
              <name>maxWait</name>
              <value>5000</value>
            </parameter>
            <parameter>
              <name>maxActive</name>
              <value>3</value>
            </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>com.pervasive.jdbc.v2.Driver</value>
            </parameter>
            <parameter>
              <name>username</name>
              <value><Username></value>
            </parameter>
            <parameter>
              <name>maxIdle</name>
              <value>2</value>
            </parameter>
          </ResourceParams>
        </GlobalNamingResources>
Deplyment
<xyzContext>.xml is in ...<Catalina>/conf/Catalina/localhost
& I drop my WAR file in ...<Catalina>/myWebApps as referenced by docbase in
<xyzContext>.xml

If I stop/start Tomcat the webApp is picked up
Have checked this with Tomcat WebApp Manager & Tomcat Web Server Admin

Have used these tools to check env/resource settings - all look OK

WHEN I invoke my webApp
I get the following code trace in the log files
  Getting Context info
  Got Initial Context
  javax.naming.NameNotFoundException Source code of javax.naming.NameNotFoundException: Name java:comp is not bound in
this Context
  at org.apache.naming.NamingContext Source code of org.apache.naming.NamingContext(NamingContext.java:814)
  at org.apache.naming.NamingContext Source code of org.apache.naming.NamingContext(NamingContext.java:197)
  at javax.naming.InitialContext Source code of javax.naming.InitialContext(InitialContext.java:347)
  at FDPCalculator.<clinit>(Unknown Source)


ie this line of code fails
  Context envCtx = (Context)initCtx.lookup("java:comp/env");



NOTE I have had the code working fine BEFORE I tried using DataSources

WHAT I am trying to achieve is the REMOVAL of env variables from my web.xml
(that provide DB setting)
So that I can start using DB Connection pools
(I have other WebApps in a similar state & want to start making use of some
Container managed global DB resources)



Hope someone can help


Sorry this has been a bit long-winded
But I've been going round in circles on this

Regards
Stefan Maric
European Aviation Air Charter
01202 581111 x184



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.