JBoss 中的 Jmockit
在 jboss 服务中,我需要使用 JMockit 模拟一些内部类(不是 EJB)。只是为了测试,我创建了内部类 ToBeMocked
和另一个 Mock。部署到 jboss 时,我收到错误 NoClassDefFoundError
in line:
Mockit.setUpMock(ToBeMocked.class, new Mock());
with message:
java.lang.NoClassDefFoundError: mockit/Mockit
jmockit.jar
is added to the classpath in jboss_service.xml
。
有什么想法吗?
In a jboss service I need to mock some inner class (not EJB) with JMockit. Just for tests I've created inner class ToBeMocked
and another one Mock. While deploying to jboss I get error NoClassDefFoundError
in line:
Mockit.setUpMock(ToBeMocked.class, new Mock());
with message:
java.lang.NoClassDefFoundError: mockit/Mockit
jmockit.jar
is added to the classpath in jboss_service.xml
.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jboss_service 中的“类路径”在 jar 位置以及标签属性如何工作方面非常具有误导性。首先,首先将 Mockit jar 放入服务器 lib 目录中(如果您没有执行任何花哨的操作,即
server/default/lib
)并重新启动 JBoss。如果有效,那么您可以阅读有关如何正确设置该类路径属性 此处(搜索单词classpath
)。The "classpath" in jboss_service is very misleading in terms of jar location and how the attributes of the tag work. First, start by putting the Mockit jar in the server lib directory (if you didn't do anything fancy that is
server/default/lib
and restarting JBoss. If that works, then you can read more about how to correctly set that classpath attribute here (search for the wordclasspath
).