Reputation: 339837
When using Tomcat 8 to run my Servlets while programming in NetBeans 8 under Java 8, I placed my JDBC driver jar in the correct location: Tomcat's home holder, in its /lib
folder, amongst the catalina.jar and servlet-api.jar and such.
When trying to run, NetBeans shows errors saying the JDBC driver cannot be found.
I tried both the Build button and the Clean & Build button.
I tried manually deleting contents of the Private Configuration Folder (Catalina Base)
folder that I had established when configuring the connection between NetBeans & Tomcat.
I tried quitting and restarting NetBeans.
Why is my JDBC jar not found?
Upvotes: 0
Views: 994
Reputation: 339837
You need to remove that Tomcat configuration from NetBeans. Then recreate that configuration.
Apparently when first run from NetBeans, a list of jar files in that /lib
folder is somehow recorded. Jars added later are ignored.
You can verify this list by examining the NetBeans↔Tomcat configuration’s properties.
To access properties, context-click the Tomcat server’s item in NetBeans Services
> Servers
list. Choose Properties
.
Click the Classes
tab to see a list of jars known from the Tomcat /lib
folder. The two JDBC driver jars shown here did not appear when I first dropped them into /lib
. They appeared only after removing and re-creating the NetBeans↔Tomcat configuration.
To remove the NetBeans↔Tomcat configuration, context-click the Tomcat server's item in NetBeans Services
> Servers
list. Choose Remove
.
Re-create the Tomcat configuration by context-clicking the Servers
grouping, and choose Add Server…
.
Now you can check the Properties
> Classes
again, and you'll see any extra jars added now appear in the list. Your JDBC driver will now be available to your servlets.
Aside: I found that NetBeans was cranky about my re-using the previous Private Configuration Folder (Catalina Base)
folder. I had to manually delete the folder from the file system (the Finder on a Mac), create a new folder in the same place, and pasted to give the new folder the same old name.
Upvotes: 0