Simple Stateless with Descriptor: ClassNotFoundException: LocalInitialContextFactory - java

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
...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?
I'm on Windows 10 64bits, Eclipse Neon, java 6 (can't update for now).

simpleStatelessWithDescriptor.LocalInitialContextFactory doesn't exist in your classes and you should not declare it.
You should use org.apache.openejb.core.LocalInitialContextFactory if you follow the example. 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.
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/

Related

tar-file repository error with jackrabbit oak

i am working since a few months with jackrabbit oak. While everything works fine with MongoDB as backend, i got problems by using a tar file based Segment NodeStore.
Here, working just with nt:folder nodes works like with MongoDB, but when i try to handle files (nt:file) i get following error massage (when writing nodes to repository):
java.lang.NoSuchMethodError: com.google.common.io.ByteStreams.equal(Lcom/google/common/io/InputSupplier;Lcom/google/common/io/InputSupplier;)Z
at org.apache.jackrabbit.oak.plugins.memory.AbstractBlob.equal(AbstractBlob.java:68)
at org.apache.jackrabbit.oak.plugins.segment.SegmentBlob.equals(SegmentBlob.java:217)
at com.google.common.base.Objects.equal(Objects.java:60)
at org.apache.jackrabbit.oak.plugins.memory.AbstractPropertyState.equal(AbstractPropertyState.java:53)
at org.apache.jackrabbit.oak.plugins.memory.AbstractPropertyState.equals(AbstractPropertyState.java:90)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:748)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:726)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:726)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:726)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:726)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter$ChildNodeCollectorDiff.childNodeChanged(SegmentWriter.java:877)
at org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.compareAgainstBaseState(ModifiedNodeState.java:416)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter$ChildNodeCollectorDiff.diff(SegmentWriter.java:892)
at org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.writeNode(SegmentWriter.java:714)
at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeBuilder.getNodeState(SegmentNodeBuilder.java:111)
at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore.rebase(SegmentNodeStore.java:269)
at org.apache.jackrabbit.oak.core.MutableRoot.rebase(MutableRoot.java:223)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.refresh(SessionDelegate.java:506)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:611)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:205)
at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1363)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:506)
at org.opencms.file.OnOffRepoCustomUnique.putResource(OnOffRepoCustomUnique.java:1229)
at org.opencms.file.OnOffRepoTest.testVersioning(OnOffRepoTest.java:873)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
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:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
it seems to be a problem with guava.. Is this a bug in oak or it is my fault? But where could the problem be?
Most probably you have multiple / invalid versions of Guava in your classpath. Please check what does mvn dependency:tree print regarding Guava.

run error in eclipse when trying to run cucumber file

This Error is appears when i trying to run junit test on eclipse using cucumber
ava.lang.NoClassDefFoundError: cucumber/runtime/snippets/SummaryPrinter
at cucumber.api.junit.Cucumber.run(Cucumber.java:90)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: cucumber.runtime.snippets.SummaryPrinter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
I got this error while upgrading the Cucumber version in my Maven based project.
Turn out that I updated <artifactId>cucumber-java</artifactId> version from 1.1.5 to 1.2.4, but I didn't update <artifactId>cucumber-junit</artifactId> - it was still on 1.1.5.
On the moment I updated both to the same version, this error was gone.
Class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.
Update cucumber-core,cucumber-java and cucumber-junit to the same version ( i have used 1.1.5 version ).The issue is resolved for me.

Error trying to test XML parsing with Robolectric

I'm using Robolectric and trying to test parsing a XML response. I'm getting the following exception:
java.lang.NoClassDefFoundError: java/lang/AutoCloseable
at android.util.Xml.parse(Xml.java:80)
at com.test.app.network.parser.soap.BaseSoapParser.doParse(BaseSoapParser.java:57)
at com.test.app.network.parser.soap.RecipeParser.parse(RecipeParser.java:57)
at com.test.app.network.command.RecipeCommand.searchRecipes(RecipeCommand.java:64)
at com.test.app.data.PrepopulateDB.prepopulateDB(PrepopulateDB.java:53)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:230)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:172)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: java.lang.AutoCloseable
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 org.robolectric.bytecode.AsmInstrumentingClassLoader.loadClass(AsmInstrumentingClassLoader.java:100)
at android.util.Xml.$$robo$$Xml_e8aa_parse(Xml.java:80)
at android.util.Xml.parse(Xml.java)
at com.test.app.network.parser.soap.BaseSoapParser.doParse(BaseSoapParser.java:57)
at com.test.test.app.network.parser.soap.RecipeParser.parse(RecipeParser.java:57)
at com.test.app.network.command.RecipeCommand.searchRecipes(RecipeCommand.java:64)
at com.test.app.data.PrepopulateDB.prepopulateDB(PrepopulateDB.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
... 22 more
The thing is that "AutoCloseable" was only added in Java 7 and since Android uses Java 6 I can understand why the class isn't found - any help will be appreciated.
Libraries:
robolectric-2.3-20140204.032758-112-jar-with-dependencies.jar
android-all-4.4_r1-robolectric-0.jar /
android-all-4.3_r2-robolectric-0.jar
Update:
I tested this using JDK 6 and Target API 18 with the same result.
Update 2:
It seems that the source of the problem is this class: org.apache.harmony.xml.ExpatReader it is using AutoClosable which isn't available on Java 6 or Android API 18.
Actually this interface is in the Android SDK : https://developer.android.com/reference/java/lang/AutoCloseable.html
Added in API level 19
Before level 19, it was there but "hidden".
This error happens when you compile your project with a higher API version than some of your required classes, your target is API 18, but as Guillaume sais, when you use AutoCloseable you're trying to load a class which is not added until API 19. So your application crashes at runtime. You need to modify your minSDK version of your project or consider an alternative.
Download the SDK bundle [1], extract it and then update/overwrite your Eclipse and Android SDK (just make a backup copy of eclipse and android-sdk folder beforehand).
Of course afterwards make all the necessary updates within the SDK and Eclipse IDE
[1] https://developer.android.com/sdk/index.html

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing in Intellij

I used Intellij Idea 12 Community edition. I am trying to create test case for my class by creating test case. When i run my test case it says
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
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 org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:44)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
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)
... 25 more
How would i run test case in Intellij. I included the junit4.11 jar file to my module
Did you include the hamcrest-core-1.3.jar file in your classpath? If not included means include that jar and try once again.
add junit.jar to your project dependence.
you may also need to add hamcrest.jar in addition.
Open File->Project Structure,Click Modules->Dependences,add junit.jar.
Latest version of hamcrest-all is available at:
https://search.maven.org/search?q=a:hamcrest-all
Download this version (as opposed to the hamcrest-core) and that should do it.
If you come across this (and a few other threads) on this error and adding the jar to dependencies doesn't work, you will need to add to the general java classpath.
I encountered this error in OSX where maven would download the dependency, but not find it when in fork mode.
Adding all the hamcrest jars to Library/Java/Extensions finally fixed the problem when nothing else would.

NullPointerException when calling webservice in Weblogic 9.2

I am trying to call a webservice. The client was generated with weblogic's ant task clientgen. But when I use the client, following exception happens:
java.lang.ExceptionInInitializerError
at com.bea.xbean.xb.xsdschema.SchemaDocument$Factory.parse(SchemaDocument.java:799)
at weblogic.wsee.wsdl.WsdlSchema.parse(WsdlSchema.java:104)
at weblogic.wsee.wsdl.WsdlSchema.parse(WsdlSchema.java:73)
at weblogic.wsee.wsdl.WsdlTypes.parse(WsdlTypes.java:165)
at weblogic.wsee.wsdl.WsdlDefinitions.parseChild(WsdlDefinitions.java:480)
at weblogic.wsee.wsdl.WsdlExtensible.parse(WsdlExtensible.java:98)
at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:428)
at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:385)
at weblogic.wsee.wsdl.WsdlFactory.parse(WsdlFactory.java:78)
at weblogic.wsee.wsdl.WsdlFactory.parse(WsdlFactory.java:65)
at weblogic.wsee.jaxrpc.ServiceImpl.loadWsdlDefinition(ServiceImpl.java:437)
at weblogic.wsee.jaxrpc.ServiceImpl.<init>(ServiceImpl.java:108)
[...]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at com.bea.xml.XmlBeans.typeSystemForClassLoader(XmlBeans.java:769)
at com.bea.xbean.xb.xsdschema.SchemaDocument.<clinit>(SchemaDocument.java:19)
... 36 more
Does anybody know what could be the problem?
I found the solution. It was a classpath problem. I needed the following jars on my classpath:
weblogic.jar
weblogic-container-binding.jar
xbean.jar
stax-api-1.0.1.jar
webservices.jar
ant.jar
There is one more way to fix this issue.
Include under and add all weblogic server library jars in build.xml
Run setDomainEnv of your domain directory.
Now build webserivces.

Categories

Resources