Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI Driver not found with Derby database connection

 
John Storta Jr.
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web app which uses a Derby database. The connection to the database establishes fine while using DriverManager.getConnection(), but if I try to establish the connection using JNDI, I get an error that the driver cannot be found.

context.xml


web.xml


Database Access Code


Error Message
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'


The obvious expected cause is that the DerbyClient.jar file is not in the classpath. But that is not the case here. The jar file is exactly where it should be and this can be verified by switching to the DriverManager method.

What am I missing?

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use the DriverManager, the web application loads the Driver and creates the Connection so therefore the Driver jar should be placed in the <CONTEXT>/WEB-INF/lib directory.
When you use JNDI, the connection gets managed and created by the container, so the Driver jar needs to be visible to the container in the container lib directory (not sure what you're using)
 
John Storta Jr.
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhhhhhh. It makes perfect sense now. Definitely one of those that seems obvious after the fact.

Thank you for getting me back on track.

John S.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No charge!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic