简体   繁体   English

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

[英]Simple Stateless with Descriptor: ClassNotFoundException: LocalInitialContextFactory

I'm beginning to lean EJB, and I'm trying to run the sample: http://openejb.apache.org/examples-trunk/simple-stateless-with-descriptor/README.html 我开始学习EJB,并且尝试运行该示例: http : //openejb.apache.org/examples-trunk/simple-stateless-with-descriptor/README.html

...and I got: ...而我得到:

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$1.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$1.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

My file tree is: 我的文件树是:

在此处输入图片说明

I searched and replaced in all file the package names to meet the file tree. 我搜索并替换了所有文件中的软件包名称,以适应文件树。

Now, what's still missing? 现在,还缺少什么? Why it can't find the LocalInitialContextFactory? 为什么找不到LocalInitialContextFactory?

I'm on Windows 10 64bits, Eclipse Neon, java 6 (can't update for now). 我使用的是Windows 10 64位,Eclipse Neon,Java 6(目前无法更新)。

simpleStatelessWithDescriptor.LocalInitialContextFactory doesn't exist in your classes and you should not declare it. simpleStatelessWithDescriptor.LocalInitialContextFactory在您的类中不存在,因此不应声明它。

You should use org.apache.openejb.core.LocalInitialContextFactory if you follow the example. 如果遵循该示例,则应使用org.apache.openejb.core.LocalInitialContextFactory You have not the class in your classpath because I imagine you have not added it. 您的类路径中没有该类,因为我想您还没有添加它。 Adding each needed library may be long and complex. 添加每个所需的库可能很长且很复杂。 You should use the pom.xml as proposed in the example. 您应该按照示例中的建议使用pom.xml。

Some advices if I can : 如果可以的话,一些建议:
Install Maven, learn the basis to use it, checkout the project from scratch and build it with Maven: http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/simple-stateless-with-descriptor/ 安装Maven,学习使用它的基础,从头开始签出项目,并使用Maven进行构建: http : //svn.apache.org/repos/asf/tomee/tomee/trunk/examples/simple-stateless-with-descriptor /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM