Perhaps one of the possibilities could be to expand the tomcat classloader so that this classloader searches in other directories than WEB-INF/lib , as follows:
Extension org.apache.catalina.loader.WebappClassLoader and overriding the findClassInternal method.
Configure Tomcat to use the advanced class loader.
This is done in the corresponding webapp configuration file in the Tomcat conf/Catalina/hostname path with the following element:
...
Then, in eclipse, you can set your overall project to โRequired projects on the build path,โ which makes it part of the class path.
This means that your advanced classloader should be able to look for another class:
- either in a fixed predetermined path
- or in a predefined class path.
I have not tested myself, but maybe this can give you an edge on this issue.
The comments suggest a much simpler noselasd solution using the GlobalNamingResources Tomcat Component .
However, frequently asked questions :
When you create a new Tomcat server in Eclipse, the New Server wizard assumes that it is unsafe to influence the current Tomcat installation behavior that this new server will use.
WTP may not affect the behavior of the installed Tomcat, using Tomcat's ability to run multiple server instances from the same installation. Thus, the default configuration for each new Tomcat segment you create will be a new instance of the Tomcat installation server associated with the Tomcat runtime selected in the wizard.
If you expect the new Tomcat server in Eclipse to run the same instance as the default batch files in your Tomcat installation start, you will probably be surprised if the Tomcat server in Eclipse does not behave as expected.
The configuration of your Tomcat server can be changed to run the same instance as your Tomcat installation.
You will find here to modify the server.xml file in WTP .
source share