带有描述符的简单无状态:ClassNotFoundException:LocalInitialContextFactory

Simple Stateless with Descriptor: ClassNotFoundException: LocalInitialContextFactory

我开始学习 EJB,我正在尝试 运行 示例:http://openejb.apache.org/examples-trunk/simple-stateless-with-descriptor/README.html

...我得到了:

javax.naming.NoInitialContextException: Cannot instantiate class: simpleStatelessWithDescriptor.LocalInitialContextFactory [Root exception is java.lang.ClassNotFoundException: simpleStatelessWithDescriptor.LocalInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:197)
    at simpleStatelessWithDescriptor.CalculatorTest.setUp(CalculatorTest.java:17)
    at junit.framework.TestCase.runBare(TestCase.java:139)
    at junit.framework.TestResult.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:252)
    at junit.framework.TestSuite.run(TestSuite.java:247)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: simpleStatelessWithDescriptor.LocalInitialContextFactory
    at java.net.URLClassLoader.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:249)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
    ... 18 more

我的文件树是:

我在所有文件中搜索并替换了包名称以满足文件树。

现在,还缺少什么?为什么找不到 LocalInitialContextFactory?

我在 Windows 10 64 位,Eclipse Neon,java 6(暂时无法更新)。

simpleStatelessWithDescriptor.LocalInitialContextFactory 在您的 class 中不存在,您不应该声明它。

如果您按照示例进行操作,则应该使用 org.apache.openejb.core.LocalInitialContextFactory。您的 class 路径中没有 class,因为我想您还没有添加它。添加每个需要的库可能是漫长而复杂的。 您应该使用示例中建议的 pom.xml。

一些建议,如果可以的话:
安装 Maven,了解使用它的基础,从头开始检查项目并使用 Maven 构建它: http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/simple-stateless-with-descriptor/