我在Tomcat 7中有Custom SharedClassLoader来加载共享库jar,该Tomcat jar中的不同应用程序使用该共享库。我们已迁移到Tomcat 9,但现在无法正常工作。如何在tomcat 9中实现相同的功能。
在Tomcat 9中,它期望传递资源。我找不到任何有关如何填充资源的示例代码。
我尝试如下
private var exitToast: Toast? = null
override fun onBackPressed() {
if (exitToast == null || exitToast!!.view == null || exitToast!!.view.windowToken == null) {
exitToast = Toast.makeText(this, "Press again to exit", Toast.LENGTH_LONG)
exitToast!!.show()
} else {
exitToast!!.cancel()
super.onBackPressed()
}
}
没有用。
public CustomSharedClassLoader(ClassLoader parent) throws Exception {
super(parent);
//The below three lines are added by me to work for Tomcat 9.
StandardRoot standardRoot = new StandardRoot();
standardRoot.addPreResources(new DirResourceSet());
setResources(standardRoot);
// End for tomcat 9 changes.
for (URL urlForJars : getClassPath(SHARED_LIB)) {
addURL(urlForJars);
}
start();
}
答案 0 :(得分:0)
shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/*.jar
文档:
# List of comma-separated paths defining the contents of the "shared" # classloader. Prefixes should be used to define what is the repository type. # Path may be relative to the CATALINA_BASE path or absolute. If left as blank, # the "common" loader will be used as Catalina's "shared" loader. # Examples: # "foo": Add this folder as a class repository # "foo/*.jar": Add all the JARs of the specified folder as class # repositories # "foo/bar.jar": Add bar.jar as a class repository # Please note that for single jars, e.g. bar.jar, you need the URL form # starting with file:.