By default server.xml contains have a  <GlobalNamingResources>. You
have to add your resources in there.

rgds
Antony Paul


On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi <[EMAIL PROTECTED]> wrote:
> As just moved the GlobalNamingResources inside the
> main <server> in my server.xml residing in
> TOMCAT_HOME/conf directory. When i restart tomcat
> 5.5.7 it's throwing up following exception.
> INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.realm.UserDatabaseRealm start
> SEVERE: Exception looking up UserDatabase under key
> UserDatabase
> javax.naming.NameNotFoundException: Name UserDatabase
> is not bound in this Conte
> xt
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:769)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>         at
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> ava:222)
>         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> 
>         at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> )
>         at
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> 50)
>         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> )
>         at
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>         at java.lang.reflect.Method.invoke(Unknown
> Source)
>         at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.startup.Catalina start
> SEVERE: Catalina.start:
> LifecycleException:  No UserDatabase component found
> under key UserDatabase
>         at
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> ava:228)
>         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> 
>         at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> )
>         at
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> 50)
>         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> )
>         at
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>         at java.lang.reflect.Method.invoke(Unknown
> Source)
>         at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.startup.Catalina start
> INFO: Server startup in 391 ms
> 
> Pls help to fix the problem.
> 
> Thanks,
> Laxmi
> 
> --- Antony Paul <[EMAIL PROTECTED]> wrote:
> 
> > It seems you still have problem. You can google for
> > the answer. One
> > thing I know is GlobalNamingResources should come
> > inside the Server
> > element and not inside Context element.
> >
> > rgds
> > Antony Paul
> >
> >
> > On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi
> > <[EMAIL PROTECTED]> wrote:
> > > I could able to get thro' JarperException. Thanks
> > for
> > > replies.
> > >
> > > Now facing new problem.
> > >
> > > I'm getting "NameNotFoundException" -  Name jdbc
> > is
> > > not bound in this Context
> > >
> > > Environment what i'm using is: Apache 2, Tomcat
> > 5.5,
> > > Netscape 7.2, MsAccess 2003 on windows 2000
> > machine.
> > >
> > > I integrated tomcat and apache as apache doesn't
> > > support jsps. I wrote a JSP called test-db.jsp
> > which
> > > in turn calls java program TestSQLLoad.java. This
> > > TestSQLLoad.java performs dattabase operation,
> > fetches
> > > the data from table and that data is displayed on
> > > Netscape thro' jsp.
> > >
> > > 1. test-db.jsp resides ina directory
> > > TOMCAT_HOME/webapps/web/JSP. Contents are as
> > follows:
> > >
> > > <%@ page contentType="text/html"
> > > import="testpkg.TestSQLLoad"%>
> > >
> > >         <html>
> > >       <head>
> > >         <title>DB Test</title>
> > >       </head>
> > >       <body>
> > >
> > >       <%
> > >         TestSQLLoad tst = new TestSQLLoad();
> > >         tst.init();
> > >       %>
> > >
> > >       <h2>Results</h2>
> > >         User -> <%= tst.getUser() %><br/>
> > >         Pwd -> <%= tst.getPassword() %><br/>
> > >         Id -> <%= tst.getID() %>
> > >
> > >       </body>
> > >     </html>
> > >
> > > 2. TestSQLLoad.java is residing in following
> > > directory. TOMCAT_HOME/webapps/web/classes/testpkg
> > > direcotry. Contents of this file are as follows:
> > >
> > >         package testpkg;
> > >
> > >         import javax.naming.*;
> > >     import javax.sql.*;
> > >     import java.sql.*;
> > >
> > >     public class TestSQLLoad
> > >     {
> > >
> > >      String user = "Not Connected";
> > >      String pwd = "no pwd";
> > >      int id = -1;
> > >
> > >      public void init() {
> > >       try{
> > >        Context ctx = new InitialContext();
> > >        if(ctx == null ) {
> > >         throw new Exception("Boom - No Context");
> > >        }
> > >
> > >            Context envCtx = (Context)
> > > ctx.lookup("java:comp/env");
> > >        DataSource ds = (DataSource)
> > > envCtx.lookup("jdbc/db1");
> > >
> > >        //DataSource ds =
> > > (DataSource)ctx.lookup("java:comp/env/jdbc/db1");
> > >
> > >        if (ds != null) {
> > >         Connection conn = ds.getConnection();
> > >
> > >         if(conn != null) {
> > >          user = "Got Connection "+conn.toString();
> > >          Statement stmt = conn.createStatement();
> > >          String q = "select name, password, id
> > from
> > > user";
> > >          ResultSet rst = stmt.executeQuery(q);
> > >          if(rst.next()) {
> > >           user=rst.getString(1);
> > >           pwd=rst.getString(2);
> > >           id = rst.getInt(3);
> > >          }
> > >          conn.close();
> > >         }
> > >        }
> > >       }catch(Exception e) {
> > >        e.printStackTrace();
> > >       }
> > >      }
> > >
> > >      public String getUser() {
> > >       return user;
> > >      }
> > >
> > >      public String getPassword() {
> > >       return pwd;
> > >      }
> > >
> > >      public int getID()
> > >      {
> > >       return id;
> > >      }
> > >     }
> > >
> > > 3. I created a jar file using testpkg directory &
> > put
> > > it in TOMCAT_HOME/common/lib as well as
> > > TOMCAT_HOME/webapps/web/WEB-INF/lib directory.
> > >
> > > 4. I created MsAccess database called db1.mdb and
> > put
> > > it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I
> > created
> > > a table called user with fields name, password and
> > ID.
> > > ID is the primary key.
> > >
> > > 5. I included following in the server.xml of
> > > TOMCAT_HOME/conf directory.
> > >
> > > <Context path="/db1"
> > docBase="C:/tomcat/webapps/db1"
> > >             debug="5" reloadable="true"
> > > crossContext="true">
> > >
> > > <GlobalNamingResources>
> > >   <Resource name="jdbc/db1" auth="Container"
> > >     type="javax.sql.DataSource"
> > >
> > >
> >
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> > >     driverClassName="sun.jdbc.odbc.JdbcOdbcDrive"
> > >     url="jdbc:odbc://localhost/db1"
> > >         maxActive="20" maxIdle="10" maxWait="-1"
> > />
> > >         </GlobalNamingResources>
> > > </Context>
> > >
> > > 6. I included following in context.xml of
> > > TOMCAT_HOME/conf directory.
> > >
> > > <ResourceLink global="jdbc/db1" name="jdbc/db1"
> > > type="javax.sql.DataSource"/>
> > >
> > > 7. I included following in web.xml of
> > > TOMCAT_HOME/webapps/web/WEB-INF directory.
> > >
> > >    <resource-ref>
> > >         <res-ref-name>jdbc/db1</res-ref-name>
> > >         <res-type>javax.sql.DataSource</res-type>
> > >         <res-auth>Container</res-auth>
> > >     </resource-ref>
> > >
> > > 8. I copied commons-collections-2.1.1.jar,
> > > commons-dbcp-1.2.1.jar and commons-pool-1.2.jar
> > into
> > > TOMCAT_HOME/common/lib directory.
> > >
> > > 9. I started apache, tomcat and then opened a
> > browser
> > > and typed http://localhost/web/JSP/test-db.jsp.
> > >
> > > 10. I get following on the browser.
> > >
> > > "Results
> > > User -> Not Connected
> > > Pwd -> no pwd
> > > Id -> -1"
> > >
> > > 11. On the tomcat window where tomcat is running
> > i'm
> > > getting following error.
> > >
> > > javax.naming.NameNotFoundException: Name jdbc is
> > not
> >
> === message truncated ===
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250
>

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

Reply via email to