java.lang.NoSuchMethodError - Ljava/lang/String;)Ljava/lang/String;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39198914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoSuchMethodError - Ljava/lang/String;)Ljava/lang/String;
提问by shankar jha
My code is giving an error below;
我的代码在下面给出了错误;
Exception in thread "main" java.lang.NoSuchMethodError: com/myApp/Client.cypherCBC(Ljava/lang/String;)Ljava/lang/String;
线程“main”中的异常 java.lang.NoSuchMethodError: com/myApp/Client.cypherCBC(Ljava/lang/String;)Ljava/lang/String;
But it's working fine in an another local environment. My code so far is below;
但它在另一个本地环境中运行良好。到目前为止,我的代码如下;
try {
System.out.println("Encrypted CBC passwd : "
+ Client.cypherCBC("CypherThePassword"));
} catch (Exception e) {
e.printStackTrace();
}
回答by hunter
This is due to a run-time JAR or class mismatch. the "Client" class which was there at the time you compile your application has a static method "cypherCBC" which gets String parameter, but at run-time class loader has loaded the "Client" class which doesn't have that kind of method (same name with same signature).
这是由于运行时 JAR 或类不匹配。编译应用程序时存在的“客户端”类有一个静态方法“cypherCBC”,它获取字符串参数,但在运行时类加载器加载了没有这种方法的“客户端”类(同名同名)。
if you can debug the application at runtime, put a break-point at the line which exception was thrown, then try to evaluate following expression,
如果您可以在运行时调试应用程序,请在抛出异常的行处放置一个断点,然后尝试评估以下表达式,
Client.class.getResource("Client.class")
, then you can find where the class has been leaded from, then you can decompile and try to troubleshoot the issue.
,然后可以找到该类从哪里被引导,然后您可以反编译并尝试解决问题。
回答by shamika
I got the same error while running a web application in Weblogic. The reason for this error is there are two versions of classes are in the environment.To fix this you have to figure out which .class is using at the run time. I used following to identify which class is loaded at run time.
我在 Weblogic 中运行 Web 应用程序时遇到了同样的错误。此错误的原因是环境中有两个版本的类。要解决此问题,您必须弄清楚运行时使用的是哪个 .class。我使用以下内容来确定在运行时加载了哪个类。
-verbose:class
-详细:类