- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 tomcat 和 eclipse。
根据tomcat的文档:
从 Web 应用程序的角度来看,类或资源加载按以下顺序查看以下存储库:
所以当加载类时,tomcat 会先查找WEB-INF/classes,然后再查找WEB-INF/lib。并且我们可以覆盖WEB-INF/lib中jar文件中的一些类,tomcat会拾取被覆盖的那个。
但是现在如果我通过选中“Serve modules with out publishing”来更改 tomcat 服务器选项,那么被覆盖的类将不再被加载。
是否有任何解决方案可以让它再次工作,但我仍然希望 tomcat 无需发布即可提供模块服务。
编辑:
我发现一些东西可能有用,在这个文件夹中 f:\eclipse_projects\.metadata.plugins\org.eclipse.wst.server.core\tmp0\conf有一个 server.xml 它包含这样的内容:
<Resources className="org.eclipse.jst.server.tomcat.loader.WtpDirContext"
extraResourcePaths=""
virtualClasspath="F:\eclipse_projects\ALS7C3\bin"/>
<Loader className="org.eclipse.jst.server.tomcat.loader.WtpWebappLoader"
useSystemClassLoaderAsParent="false"
virtualClasspath="F:\eclipse_projects\ALS7C3\bin"/>
似乎在运行 tomcat 并选中“Serve modules without publishing”选项时,eclipse 将使用它自己的加载程序。此加载程序包含在一个 jar 文件中,该文件将被复制到 f:\eclipse_projects\.metadata。 plugins\org.eclipse.wst.server.core\tmp0\lib** 当你在 eclipse 中启动 tomcat 时。这是 **org.eclipse.jst.server.tomcat.loader.WtpDirContext 的部分源代码:
public Object lookup(String name) throws NamingException {
if (name.startsWith("/WEB-INF/") && name.endsWith(".tld")) {
String tldName = name.substring(name.lastIndexOf("/") + 1);
if (virtualMappings != null && virtualMappings.containsKey(tldName)) {
return new FileResource(virtualMappings.get(tldName));
}
} else if (tagfileMappings != null && name.startsWith("/META-INF/tags")
&& (name.endsWith(".tag") || name.endsWith(".tagx"))) {
// already loaded tag file
return new FileResource(tagfileMappings.get(name));
}
Object retSuper;
NamingException superEx;
try {
retSuper = super.lookup(name);
return retSuper;
} catch (NamingException ex) {
retSuper = null;
superEx = ex;
}
if (mappedResourcePaths != null) {
// Perform lookup using the extra resource paths
for (Map.Entry<String, List<String>> mapping : mappedResourcePaths.entrySet()) {
String path = mapping.getKey();
List<String> dirList = mapping.getValue();
if (name.equals(path)) {
for (String resourcesDir : dirList) {
File f = new File(resourcesDir);
if (f.exists() && f.canRead()) {
if (f.isFile()) {
return new FileResource(f);
}
else {
// TODO Handle directory
}
}
}
}
path += "/";
if (name.startsWith(path)) {
String res = name.substring(path.length());
for (String resourcesDir : dirList) {
File f = new File (resourcesDir + "/" + res);
if (f.exists() && f.canRead()) {
if (f.isFile()) {
return new FileResource(f);
}
else {
// TODO Handle directory
}
}
}
}
}
}
throw superEx;
}
好像是先处理jsp标签库再调用super.lookup,如果在super.lookup中找不到,会尝试加载资源在 virtualClasspath 中,在我的示例中为“F:\eclipse_projects\ALS7C3\bin”,它是在不发布的情况下提供模块时 eclipse 输出类文件的位置。
所以,我想,如果我可以覆盖 org.eclipse.jst.server.tomcat.loader.WtpDirContext 的 lookup 方法,我就能得到我想要的东西,但是这个 jar 文件包含在 org.eclipse.jst.server.tomcat.core.jar 中,它们都已签名。
我不知道如何覆盖这样的 jar 文件。
有人可以帮忙吗?
最佳答案
以下是我使用 eclipse/tomcat 进行热部署的方法:
如果您更改了配置文件,也许可以尝试使用新的 tomcat。
关于java - 在不发布的情况下提供模块时的 Tomcat 类加载顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19675931/
我是 Java 新手,这是我的代码, if( a.name == b.name && a.displayname == b.displayname && a.linknam
在下面的场景中,我有一个 bool 值。根据结果,我调用完全相同的函数,唯一的区别是参数的数量。 var myBoolean = ... if (myBoolean) { retrieve
我是一名研究 C++ 的 C 开发人员: 我是否正确理解如果我抛出异常然后堆栈将展开直到找到第一个异常处理程序?是否可以在不展开的情况下在任何 throw 上打开调试器(即不离开声明它的范围或任何更高
在修复庞大代码库中的错误时,我观察到一个奇怪的情况,其中引用的动态类型从原始 Derived 类型更改为 Base 类型!我提供了最少的代码来解释问题: struct Base { // some
我正在尝试用 C# 扩展给定的代码,但由于缺乏编程经验,我有点陷入困境。 使用 Visual Studio 社区,我尝试通过控制台读出 CPU 核心温度。该代码使用开关/外壳来查找传感器的特定名称(即
这可能是一个哲学问题。 假设您正在向页面发出 AJAX 请求(这是使用 Prototype): new Ajax.Request('target.asp', { method:"post", pa
我有以下 HTML 代码,我无法在所有浏览器中正常工作: 我试图在移动到
我对 Swift 很陌生。我如何从 addPin 函数中检索注释并能够在我的 addLocation 操作 (buttonPressed) 中使用它。我正在尝试使用压力触摸在 map 上添加图钉,在两
我设置了一个详细 View ,我是否有几个 Nib 文件根据在 Root View Controller 的表中选择的项目来加载。 我发现,对于 Nibs 的类,永远不会调用 viewDidUnloa
我需要动态访问 json 文件并使用以下代码。在本例中,“bpicsel”和“temp”是变量。最终结果类似于“data[0].extit1” var title="data["+bpicsel+"]
我需要使用第三方 WCF 服务。我已经在我的证书存储中配置了所需的证书,但是在调用 WCF 服务时出现以下异常。 向 https://XXXX.com/AHSharedServices/Custome
在几个 SO 答案(1、2)中,建议如果存在冲突则不应触发 INSERT 触发器,ON CONFLICT DO NOTHING 在触发语句中。也许我理解错了,但在我的实验中似乎并非如此。 这是我的 S
如果进行修改,则会给出org.hibernate.NonUniqueObjectException。在我的 BidderBO 类(class)中 @Override @Transactional(pr
我使用 indexOf() 方法来精细地查找数组中的对象。 直到此刻我查了一些资料,发现代码应该无法正常工作。 我在reducer中尝试了上面的代码,它成功了 let tmp = state.find
假设我有以下表格: CREATE TABLE Game ( GameID INT UNSIGNED NOT NULL, GameType TINYINT UNSIGNED NOT NU
代码: Alamofire.request(URL(string: imageUrl)!).downloadProgress(closure: { (progress) in
我是一名优秀的程序员,十分优秀!