Soefara, You're going to kick yourself ... the required element name is <res-ref-name>, not <resource-ref-name> :-).
With regards to your question about portability, the answer is yes -- resource references declared in the web.xml are portable, as long as the servlet container you plan to run on supports a JNDI naming context for each web application. That covers *all* J2EE-compatible servers and Tomcat 4 -- for anything else, you will want to double check. Note, however, that the actual mechanism for defining what connection pool the resource reference actually refers to is server dependent. For Tomcat 4, that means setting things up in server.xml. For other servers, consult the documentation for that server. Craig On Sat, 16 Mar 2002, Soefara Redzuan wrote: > Date: Sat, 16 Mar 2002 12:36:42 +0800 > From: Soefara Redzuan <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Re: jndi versus database connection pooling > > > > DataSource ds = null; > > Context initCtx = new InitialContext(); > > Context envCtx = (Context)initCtx.lookup( "java:comp/env" ); > > ds = (DataSource)envCtx.lookup( "jdbc/DB" ); > > > >The problem is that returned datasource is always null. > > I wish I could get that far. I am using a web.xml that is almost identical > to your own below and yet Tomcat will not start without reporting this XML > parsing error. > > org.xml.sax.SAXParseException: Element "resource-ref" does not allow > "resource-ref-name" here. > > > >From: "Taavi Tiirik" <[EMAIL PROTECTED]> > > > >In web.xml I have following resource-ref defined: > > > > <resource-ref> > > <description> > > Resource reference to a factory for javax.sql.DataSource > > instances that may be used for talking to a particular > > database that is configured in the server.xml file. > > </description> > > <res-ref-name>jdbc/DB</res-ref-name> > > <res-type>javax.sql.DataSource</res-type> > > <res-auth>Container</res-auth> > > </resource-ref> > > My own web.xml is contains almost the same resource-ref > > <resource-ref> > <description> > Resource reference to a factory for java.sql.Connection > instances that may be used for talking to a particular > database that is configured in the server.xml file. > </description> > <resource-ref-name> > jdbc/mydb > </resource-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > The error I get is an XML parsing error and the actual values are actually > irrelevant. I'm using Tomcat 4.0.1 on Windows 2000. How come nobody else is > reporting this error regardless if you're using Postgres, Oracle or mysql > > org.xml.sax.SAXParseException: Element "resource-ref" does not allow > "resource-ref-name" here. > > Also, IF I ever get this to work, will this also work on other java servers > like Websphere or will your own database pool manager be more cross platform > ? > > Thank you, Soefara. > > > > _________________________________________________________________ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx > > > -- > To unsubscribe: <mailto:[EMAIL PROTECTED]> > For additional commands: <mailto:[EMAIL PROTECTED]> > Troubles with the list: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
