运行 JAR 时出现“java.lang.ClassNotFoundException: javax.ejb.EJBObject”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2788360/
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.ClassNotFoundException: javax.ejb.EJBObject" when running JAR
提问by
I'm getting a java.lang.ClassNotFoundException: javax.ejb.EJBObjecterror when I'm running my application as a JAR file. When running it in Eclipse everything is working fine.
java.lang.ClassNotFoundException: javax.ejb.EJBObject当我将应用程序作为 JAR 文件运行时出现错误。在 Eclipse 中运行它时一切正常。
The application properly access the main class and the main method. But when it tries to load the application context it cannot resolve a reference to an EJB bean. I then get the following error:
应用程序正确访问主类和主方法。但是当它尝试加载应用程序上下文时,它无法解析对 EJB bean 的引用。然后我收到以下错误:
Error creating bean with name 'bc' defined in class path resource [blabla.xml]:
Initialization of bean failed;
nested exception is
java.lang.NoClassDefFoundError: javax/ejb/EJBObject
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
...
Caused by:
java.lang.ClassNotFoundException: javax.ejb.EJBObject
I've included all runtime-scoped dependencies with Maven in the JAR file.
我已经在 JAR 文件中包含了 Maven 的所有运行时范围的依赖项。
Do you know any further information regarding this error?
您知道有关此错误的更多信息吗?
采纳答案by Henning
A little list of things to check:
需要检查的小清单:
- Is the
EJBObjectclass located in a dependency withprovidedscope? - Is the JAR containing the
EJBObjectclass really on the classpath? I.e., do you either add it to the class path when running the JAR, or do you use the onejar-pluginto put your dependencies into the JAR? - If you are using onejar: Are you really running the JAR created by onejar (
myproject.one-jar.jar), and not the one without the dependencies (myproject.jar)?
EJBObject该类是否位于具有provided作用域的依赖项中?- 包含
EJBObject类的 JAR真的在类路径上吗?即,您是在运行 JAR 时将其添加到类路径中,还是使用onejar-plugin将您的依赖项放入 JAR? - 如果您使用的是 onejar:您真的运行的是 onejar (
myproject.one-jar.jar)创建的 JAR ,而不是没有依赖项 (myproject.jar)的 JAR吗?

