Thanks for the help. Don't I feel like the idiot!! -----Original Message----- From: p niemandt [mailto:[EMAIL PROTECTED] Sent: Friday, March 14, 2003 11:29 AM To: 'Tomcat Users List' Subject: RE: Cannot create resource instance
Aah: On the other hand, and I should have caught this earlier, but anyways: I assume you copied your server.xml exactly in the post? In that case a definite problem is ... <value>ora.apache.commons.dbcp.BasicDataSourceFactory</value> Getting confused with Oracle? This should surely be org.apache.commons.dbcp.BasicDataSourceFactory ??? typo: org <--> ora On Fri, 2003-03-14 at 16:00, Appel, Jeremy D wrote: > That still did not work. Given the fact that I can list the binding, I have > to think that the DBCP related class files are not getting loaded to handle > the request. Is there anyway to check this? > > -----Original Message----- > From: p niemandt [mailto:[EMAIL PROTECTED] > Sent: Friday, March 14, 2003 10:46 AM > To: 'Tomcat Users List' > Subject: RE: Cannot create resource instance > > > OK: This is basically what I do, and it has never given me any problems. > Maybe try that? > > *** server.xml *** > Define a resource ... > <Resource name="jdbc/chfs" auth="Container" > type="javax.sql.DataSource"/> > > *** where you need the connection *** > { > String DatasourceName = "java:comp/env/jdbc/chfs"; > > Connection conn = null; > try { > Context ctx = new InitialContext(); > DataSource ds = (DataSource)ctx.lookup(DatasourceName); > conn = ds.getConnection(); > try { > PreparedStatement prep = conn.prepareStatement(SQL) ... > > ****** > > The java:comp/env needs to be prefixed. > I think the Context envCtx = (Context) initCtx.lookup("java:comp/env") > is probably causing your problems. > > Hope this helps: I use the same code for Oracle8, 9, MySQL, and SAP/DB: > Works well for all of them, as long as your Resource is properly defined > (I do it in server.xml, could probably be done elsewhere, > but "If it's not broken, don't fix it? ") > > regards, > Paul > > > > On Fri, 2003-03-14 at 15:24, Appel, Jeremy D wrote: > > Yes the classes.jar file is in %CATALINA_HOME/common/lib > > > > Here is snippet of code, disregard the list bindings call (debug statement > > which prints out the binding) > > > > > > Context initCtx = new InitialContext(); > > Context envCtx = (Context) initCtx.lookup("java:comp/env"); > > NamingEnumeration enum = initCtx.listBindings("java:comp/env/jdbc"); > > while (enum.hasMoreElements()) { > > writer.print("Binding : "); > > writer.println(enum.nextElement().toString()); > > } > > DataSource ds = (DataSource) envCtx.lookup("jdbc/prod_d"); > > Connection conn = ds.getConnection(); > > > > Thanks, > > Jeremy > > > > -----Original Message----- > > From: p niemandt [mailto:[EMAIL PROTECTED] > > Sent: Friday, March 14, 2003 10:27 AM > > To: Tomcat Users List > > Subject: RE: Cannot create resource instance > > > > > > No need to change the policy file. > > Make sure the oracle drivers are in the correct directory ... > > $TOMCAT_HOME/common/lib > > and that the classes.zip file has been renamed to classes.jar > > > > Also, maybe mail a sniplet of the code you use to do your lookup: Maybe > > we can see something funny. > > > > hth. > > Paul > > > > > > On Fri, 2003-03-14 at 15:06, Appel, Jeremy D wrote: > > > Yes, I am doing the lookup exactly the same way. I should not have to > > > modify the catalina.policy file for security, correct? > > > > > > -----Original Message----- > > > From: Ferrer, J.C. [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, March 13, 2003 7:18 PM > > > To: 'Tomcat Users List' > > > Subject: RE: Cannot create resource instance > > > > > > > > > > > > I'm using v4.1.21 and instead of using "user" as the parameter name, I'm > > > using "username". > > > > > > Are you doing the resource lookup using "java:comp/env/jdbc/prod_d" ? > > > > > > > > > > > > -----Original Message----- > > > From: Appel, Jeremy D [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, March 13, 2003 1:29 PM > > > To: '[EMAIL PROTECTED]' > > > Subject: Cannot create resource instance > > > > > > > > > All, > > > > > > I am running Tomcat 4.0.4 and I am trying to use Jakarta DBCP. I > > > have download the necessary jar files and placed them in > > > %CATALINA_HOME%/common/lib. I am receiving the following error: > > > > > > javax.naming.NamingException: Cannot create resource instance > > > at > > > > > > org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. > > > java) > > > at > > > javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java) > > > at org.apache.naming.NamingContext.lookup(NamingContext.java) > > > at org.apache.naming.NamingContext.lookup(NamingContext.java) > > > at org.apache.naming.NamingContext.lookup(NamingContext.java) > > > at org.apache.naming.NamingContext.lookup(NamingContext.java) > > > > > > When I list bindings on the resource below, It appears that the JNDI > > > resource exists but when I try to look it up I receive the error above. > > Any > > > thoughts or advice? > > > > > > Snapshot from web.xml: > > > > > > <resource-ref> > > > <res-ref-name>jdbc/prod_d</res-ref-name> > > > <res-type>javax.sql.DataSource</res-type> > > > <res-auth>Container</res-auth> > > > </resource-ref> > > > > > > Snapshot from server.xml: > > > > > > > > > <Resource name="jdbc/prod_d" auth="Container" > > > type="javax.sql.DataSource"/> > > > <ResourceParams name="jdbc/prod_d"> > > > <parameter> > > > <name>user</name> > > > <value>jappel</value> > > > </parameter> > > > <parameter> > > > <name>password</name> > > > <value>jappel</value> > > > </parameter> > > > <parameter> > > > <name>driverClassName</name> > > > <value>oracle.jdbc.driver.OracleDriver</value> > > > </parameter> > > > <parameter> > > > <name>url</name> > > > > > > <value>jdbc:oracle:thin:@hpcat159.qwest.net:1521:prod_d</value> > > > </parameter> > > > <parameter> > > > <name>factory</name> > > > > > > <value>ora.apache.commons.dbcp.BasicDataSourceFactory</value> > > > </parameter> > > > </ResourceParams> > > > > > > > > > Thanks, > > > Jeremy Appel > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > CONFIDENTIALITY NOTICE: The information in this e-mail is privileged > and > > > confidential. Any use, copying or dissemination of any portion of this > > > e-mail by or to anyone other than the intended recipient(s) is > > unauthorized. > > > If you have received this e-mail in error, please reply to sender and > > delete > > > it from your system immediately. > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] -- p niemandt <[EMAIL PROTECTED]> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]