java.lang.classnotfoundexception:org.mockserver.version.version

发布于 2025-01-30 09:22:26 字数 925 浏览 4 评论 0原文

我正在尝试使用Mockserver-netty-5.13.2启动模拟服务器 Java版本: 11.0.9

像这样的粗糙外壳代码:

java -version
echo "start shell before java -jar line"
java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log 

java -jar./mockserver-netty-5.13.2.2.2.2.2.2.jar -serverport 9090引发的异常

Exception in thread "main" java.lang.NoClassDefFoundError: org/mockserver/version/Version
    at org.mockserver.cli.Main.<clinit>(Main.java:27)
Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more

。 任何帮助将不胜感激!!!

I am trying to start mock server with mockserver-netty-5.13.2 from shell,
java version:
11.0.9

Rough shell code like this:

java -version
echo "start shell before java -jar line"
java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log 

The exception thrown from java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090

Exception in thread "main" java.lang.NoClassDefFoundError: org/mockserver/version/Version
    at org.mockserver.cli.Main.<clinit>(Main.java:27)
Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more

Has anyone run into this issue and resolved it ?
Any help would be much appreciated !!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗酒趁年少 2025-02-06 09:22:26

我能够在非常相似的环境中复制问题。
问题是因为您使用错误的罐子。
要从命令行运行MOCKSERVER您应该使用-Shaded jar ,其中包括依赖关系。
您使用的JAR不包括所需的依赖项,并且不应在命令行中运行它,而无需手动提供作为class Path的一部分的一部分。
您收到的错误

Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version

几乎支持了此结论,并告诉您org.mockserver.version.version.version.version class在您运行此特定JAR时不会提供。
在这里,是指示您应该使用阴影罐运行的官方文档从命令行。
< “>这里您可以下载MockServer 5.13.2阴影jar。
然后,像希望有帮助的希望一样运行它

java -jar ./mockserver-netty-5.13.2-shaded.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log 

I was able to replicate the problem within a very similar environment as yours.
The issue is caused because your are using the wrong jar.
To run the mockserver from the command line you should use a -shaded jar, where it's dependencies are included.
The jar you are using does not include the required dependencies and it is not supposed to be ran in the command line without providing them by hand as part of the classpath.
The error you get

Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version

pretty much supports this conclusion, and tells you that the org.mockserver.version.Version class is not provided when you run this specific jar.
Here, is the official docs that indicate you should use the shaded jar to run mockserver from the command line.
Here you can download the mockserver 5.13.2 shaded jar.
Then, run it like this

java -jar ./mockserver-netty-5.13.2-shaded.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log 

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文