|
I have a JNDI resource defined in my application's context.xml like so:
<?xml version="1.0" encoding="UTF-8"?> <Context reloadable="true" debug="true" allowLinking="true"> <Resource name="jdbc/v5/myjndi" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" password="password" maxIdle="2" maxWait="5000" validationQuery="Select 'Hello' from Dual" username="username" url="jdbc:oracle:thin:@host:port:instance" maxActive="4"/> </Context> When I try to put the ojdbc14.jar in the /WEB-INF/lib/*.jar of my web application, it results in the following error: Could not get JDBC Connection; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver' However, if I merely move ojdbc14.jar to the common lib folder, it works: C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib I'd like to package the ojdbc14.jar inside of my application--not so much because I expect it to be different across applications, but so as to minimize Tomcat setup necessary to run my applications. As much as possible, I'd like my applications to be self-contained. How do I get the class loader used for this JNDI resource to use my application's /WEB-INF/lib folder's jars? Thanks, Mark McEahern Lead Architect Division of Public Health Informatics and Surveillance Wisconsin State Lab of Hygiene --------------------------------------------------------------------- To start a new topic, e-mail: [hidden email] To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
McEahern, Mark S wrote:
> I have a JNDI resource defined in my application's context.xml like so: > > <?xml version="1.0" encoding="UTF-8"?> > <Context reloadable="true" debug="true" allowLinking="true"> > <Resource > name="jdbc/v5/myjndi" > type="javax.sql.DataSource" > driverClassName="oracle.jdbc.driver.OracleDriver" ... > maxActive="4"/> > </Context> > > When I try to put the ojdbc14.jar in the /WEB-INF/lib/*.jar of my web > application, it results in the following error: > > Could not get JDBC Connection; nested exception is > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver > class 'oracle.jdbc.driver.OracleDriver' That happens because the resources are set up with the server classpath (Common classloader), which does not include any of the webapp libraries. See http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html for classloader details. It has to be this way, because the resources actually do not belong into the webapp, but are part of the container. > I'd like to package the ojdbc14.jar inside of my application--not so > much because I expect it to be different across applications, but so as > to minimize Tomcat setup necessary to run my applications. As much as > possible, I'd like my applications to be self-contained. > > How do I get the class loader used for this JNDI resource to use my > application's /WEB-INF/lib folder's jars? I don't think you can; you'll need to weigh the pros and cons of different approaches here. You already have a feeling about the pros and cons of the standard, JNDI-based, approach. The other way (in order to be able to package the Oracle JARs within your application) would be to let go of JNDI, and declare your database dependencies in a more direct way. Just place the connection descriptor and account details into a properties file within WEB-INF, and have a database interface class to pick them up from there at application startup. -- ..Juha --------------------------------------------------------------------- To start a new topic, e-mail: [hidden email] To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
remembering every lookup is a complete roundtrip which can be slow during peak periods try to maintain as direct a path as possible to the DB with as few lookups as possible to ensure best performance thanks, Martin ______________________________________________ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. > Date: Mon, 6 Oct 2008 20:39:35 +0300 > From: [hidden email] > To: [hidden email] > Subject: Re: Cannot load JDBC driver class in WebApp-specific lib > > McEahern, Mark S wrote: > > I have a JNDI resource defined in my application's context.xml like so: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <Context reloadable="true" debug="true" allowLinking="true"> > > <Resource > > name="jdbc/v5/myjndi" > > type="javax.sql.DataSource" > > driverClassName="oracle.jdbc.driver.OracleDriver" > ... > > > maxActive="4"/> > > </Context> > > > > When I try to put the ojdbc14.jar in the /WEB-INF/lib/*.jar of my web > > application, it results in the following error: > > > > Could not get JDBC Connection; nested exception is > > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver > > class 'oracle.jdbc.driver.OracleDriver' > > That happens because the resources are set up with the server classpath > (Common classloader), which does not include any of the webapp libraries. > See http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html > for classloader details. > > It has to be this way, because the resources actually do not belong > into the webapp, but are part of the container. > > > I'd like to package the ojdbc14.jar inside of my application--not so > > much because I expect it to be different across applications, but so as > > to minimize Tomcat setup necessary to run my applications. As much as > > possible, I'd like my applications to be self-contained. > > > > How do I get the class loader used for this JNDI resource to use my > > application's /WEB-INF/lib folder's jars? > > I don't think you can; you'll need to weigh the pros and cons of different > approaches here. You already have a feeling about the pros and cons of the > standard, JNDI-based, approach. The other way (in order to be able to > package the Oracle JARs within your application) would be to let go of > JNDI, and declare your database dependencies in a more direct way. Just > place the connection descriptor and account details into a properties file > within WEB-INF, and have a database interface class to pick them up from > there at application startup. > -- > ..Juha > > --------------------------------------------------------------------- > To start a new topic, e-mail: [hidden email] > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > _________________________________________________________________ Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 |
| Powered by Nabble | Edit this page |
