tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mighty Tornado <mighty.torn...@gmail.com>
Subject Re: javax.naming.NamingException: Cannot create resource instance
Date Mon, 06 Apr 2009 16:59:59 GMT
I added the same entry to context.xml under $CATALINA/conf and it did work.
Could there be something else wrong?

On Mon, Apr 6, 2009 at 12:30 PM, Pid <p@pidster.com> wrote:

> Mighty Tornado wrote:
> > JVM: 1.5.0_16Tomcat: 6.0.16 2
> > OS: Mac OS X Leopard
> >
> > Hi,
> >
> > I defined the following context.xml under META-INF:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <Context path="/Household" docBase="Household" debug="5"
> reloadable="true"
> > crossContext="true">
> >
> > <Resource
> >
> >     auth="Container"
> >
> >     description="DB Connection"
> >
> >     name="jdbc/vhousehold"
> >
> >     type="javax.sql.DataSource"
> >
> >     password="vhousehold"
> >
> >     driverClassName="com.mysql.jdbc.Driver"
> >
> >     maxIdle="2"
> >
> >     maxWait="5000"
> >
> >     validationQuery="/* PING */ SELECT 1;"
> >
> >     username="vhousehold"
> >
> >     url="jdbc:mysql://localhost:3306/vhousehold"
> >
> >     maxActive="4"/>
> >
> > </Context>
> >
> >
> > In web.xml I have the following:
> >
> >
> >   <resource-ref>
> >
> >         <description>Connection Pool</description>
> >
> >         <res-ref-name>jdbc/vhousehold</res-ref-name>
> >
> >         <res-type>javax.sql.Datasource</res-type>
> >
> >         <res-auth>Container</res-auth>
> >
> >   </resource-ref>
> >
> >
> > I try to get this data source in my application using the following code:
> >
> >
> > DataSource ds = (DataSource)initContext.lookup(
> > "java:/comp/env/jdbc/vhousehold");
> >
> >
> > and it fails. This is the exception I get:
> >
> > javax.naming.NamingException: Cannot create resource instance
> >
> >         at
> >
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
> >
> >         at
> > javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
> >
> >         at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
> >
> >         at
> > org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
> >
> >         at javax.naming.InitialContext.lookup(InitialContext.java:351)
> >
> >         at
> > com.vhousehold.dao.RandomPhraseDAO.getPhrases(RandomPhraseDAO.java:60)
> >
> >         at
> >
> com.vhousehold.model.RandomPhraseModel.getRandomPhrase(RandomPhraseModel.java:19)
> >
> >         at
> com.vhousehold.servlet.VHController.doPost(VHController.java:52)
> >
> >         at
> com.vhousehold.servlet.VHController.doGet(VHController.java:35)
> >
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> >
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >
> >         at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> >
> >         at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> >
> >         at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> >
> >         at
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> >
> >         at
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> >
> >         at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> >
> >         at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> >
> >         at
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> >
> >         at
> >
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
> >
> >         at
> >
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> >
> >         at
> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> >
> >         at java.lang.Thread.run(Thread.java:613)
> >
> >
> > Any suggestions as to what I am doing wrong?
>
> You've added the path and docBase attributes to your
> META-INF/context.xml.  Don't do that.
>
> Are the credentials you're using for the database correct?
>
> p
>
>
> > Thanks.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message