tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid...@pidster.com>
Subject Re: javax.naming.NamingException: Cannot create resource instance
Date Mon, 06 Apr 2009 16:30:55 GMT
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
View raw message