仅在 1 台或 4 台服务器上出现 java/tomcat 异常

getting an java/tomcat exception only on 1 or 4 servers

我在 4 台服务器上安装了这个 java 网络应用程序 运行。 最新的服务器(刚刚设置)失败并出现错误 "java.lang.NoSuchMethodError: org.htmlparser.lexer.Lexer.parseCDATA()Lorg/htmlparser/Node" 当运行下面的代码。

我有 1 个服务器 运行 在我的 mac 本地。 2台服务器是 运行 Centos 6.10 / java 1.8.0_242 / tomcat-8.5.54 最新的服务器(失败的服务器)是 运行 Centos 6.10 / java 1.8.0_242 / tomcat-8.5.54

我已经将所有 jar 从工作的 Centos 服务器复制到损坏的服务器

我很茫然。很想听听关于如何 debug/resolve 这个....

的一些想法

代码运行非常简单 另一个让我感到困惑的部分是,如果找不到 jar 就不会 Parser.createParser 爆炸,我添加了调试代码以确保 parser_c 不为 null

import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.tags.ImageTag;
import org.htmlparser.tags.LinkTag;
import org.htmlparser.util.ParserException;

public class SignatureTools {
    public static String getURLFromSignature(String signature) throws ParserException {
        System.out.println("[getURLFromSignature]");
        if ( signature == null ){ return null;}
        Parser parser_c = Parser.createParser(signature, null);
        Node nodes_c[] = parser_c.extractAllNodesThatAre(LinkTag.class);
        String mkURL = null;
        for (Node node : nodes_c) {
            if (node != null && node instanceof LinkTag && ((LinkTag) node).getAttribute("href") != null) {
                String href = ((LinkTag) node).getAttribute("href");
                if ( href.contains("https://www.thedomain.com") ){
                    mkURL = href;
                }
            }
        }
        return URL;
    }
}

发现问题..

我使用了这段代码,发现 Lexer 是从另一个 jar 而不是 htmllexer.jar

Lexer lexer = new Lexer();
        try {
            System.out.println( "Lexer---->" + new File(Lexer.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath());
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }