Tomcat war deploy including extra jar directory on classpath
I need to deploy a war to tomcat and add a directory called “DB2Jars” as the application pulls them from the classpath specifically my documentation says to create them in an eclipse classpath variable “DB2Java” although I can't find references to that folder name anywhere besides an eclipse launch file. The path would be from “DB2Jars/<jar-name>.jar” - so the only way to get the application to run properly is to add them to the classpath in this manner as far as I know. It may also work just adding to the classpath but based on what I've tried it has not worked.
So far in the tomcat configuration I've tried clicking “configure” and adding the libraries manually, I've tried adding the dependencies to the module dependencies that creates the war file, and I've tried using the -Xbootclasspath/a: argument. All result in java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver when trying to deploy the war to tomcat in IntelliJ.
请先登录再写评论。
It should work if you add the jar to the module dependencies. Make sure to update the artifact so that it includes this jar as well, see https://www.jetbrains.com/help/idea/artifacts.html.
I have tried this with no luck. Here is a screenshot of the artifacts screen:

I have also tried adding them directly to the .war file itself in this screen.
Here are the dependencies I added to the module I am attempting to deploy a .war of using tomcat:

I have tried both runtime and compile on the above.
So this does not seem to work unless I'm missing something.
Jars should go into WEB-INF/lib subdirectory of the artifact to be visible by the app server. You should edit the exploded artifact instead and make sure that the jars are placed in this location (if not, create it manually).
war artifact is a wrapper for the war-exploded artifact which packs it into the archive. There is no sense to make such edits to the war artifact as you should be editing the exploded one instead.
Thanks. This worked!