You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Per Newgro <pe...@gmx.ch> on 2007/11/02 23:20:50 UTC

Exception while using embedded openejb for testing in eclipse

Hi *,

i try to run my SLSB Tests on an embedded openejb server - without any extra 
configuration. I added all required libs (try and error :-). But now i get a 
strange exception. (OpenEJB is in eclipse classpath). How can i reuse the 
eclipse classpath for my tests?

Cheers
Per

javax.naming.NamingException: Attempted to load OpenEJB.
java.lang.NoClassDefFoundError [Root exception is
java.lang.ClassCastException: java.lang.NoClassDefFoundError]

            at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(L
ocalInitialContextFactory.java:47)

            at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

            at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)

            at javax.naming.InitialContext.init(InitialContext.java:223)

            at
javax.naming.InitialContext.<init>(InitialContext.java:197)

            at
de.yhd.buma.backend.backendtests.OpenEjbAccessTest.setUp(OpenEjbAccessTe
st.java:40)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

            at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

            at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

            at java.lang.reflect.Method.invoke(Method.java:585)

            at
org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAf
terRunner.java:74)

            at
org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfte
rRunner.java:50)

            at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf
terRunner.java:33)

            at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.j
ava:75)

            at
org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45
)

            at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestC
lassMethodsRunner.java:66)

            at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRu
nner.java:35)

            at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRun
ner.java:42)

            at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf
terRunner.java:34)

            at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)

            at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4Tes
tReference.java:38)

            at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)

Caused by: java.lang.ClassCastException: java.lang.NoClassDefFoundError

            at
org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:38)

            at
org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialCo
ntextFactory.java:59)

            at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(L
ocalInitialContextFactory.java:45)

            ... 25 more

Re: Exception while using embedded openejb for testing in eclipse

Posted by Newgro <pe...@gmx.ch>.
Hi David,

ok. I got it exactly the way you did. My fault was that i added only some
libs to my eclispe-build-path
geronimo-annotation_1.0_spec-1.1.jar
geronimo-ejb_3.0_spec-1.0.jar
geronimo-jta_1.1_spec-1.1.jar
log4j-1.2.12.jar
openejb-client-3.0-beta-1.jar
openejb-core-3.0-beta-1.jar
openejb-ejbd-3.0-beta-1.jar
openejb-loader-3.0-beta-1.jar
openejb-server-3.0-beta-1.jar

Now i added all libs from the project and ... it's running, but not working
:-(
I open another thread for my new problems.

Thanks alot for your great help and project
Cheers
Per
-- 
View this message in context: http://www.nabble.com/Exception-while-using-embedded-openejb-for-testing-in-eclipse-tf4740984.html#a13664420
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Exception while using embedded openejb for testing in eclipse

Posted by David Blevins <da...@visi.com>.
On Nov 6, 2007, at 9:37 PM, David Blevins wrote:

> Hi Per,
>
> It isn't clear what's causing the issue based on the stack trace  
> (NoClassDefFoundErrors usually require some debugging).  I'm going  
> to try and convert one of our examples into an eclipse project and  
> see if I can't get something working.  I'll post the workspace when  
> I'm done.
>
> If you'd like to post a workspace that reproduces the issue as well,  
> that'd be great too.  Even if the space I create works, I'd be nice  
> to know what happened for support reasons.

I was able to get something running using an example from the  
downloadable examples zip as follows:

On Command line:
  1.  cd examples/calculator-stateless-pojo
  2.  mvn eclipse:eclipse

In Eclipse:
  3.  Open Eclipse
  4.  Import "examples/calculator-stateless-pojo" selecting "General- 
 >Existing Projects into Workspace"

That will get your project into eclipse, but there'll be an "M2_REPO"  
variable you have to define.  For that you:
  5.  Preferences -> navigate to "Java -> Build Path -> Classpath  
Variables"
  6.  click New...
  7.  enter the values Name: "M2_REPO", Path: "/Users/dblevins/.m2/ 
repository/"  (adjust for your machine)
  8.  OK

That should do the trick.  From there you can run the  
CalculatorTest.java which will show everything running embedded.

I made some screen shots, but don't have an art program to mark them  
up or shrink down the file sizes.  None the less, here are a few along  
with generated eclipse project:

  http://people.apache.org/~dblevins/eclipse-howto/

Hope this helps.  Let us know how it goes.

-David

P.S. Anyone out there want to turn this into an article?  Could  
probably recommend you to a publisher.


Re: Exception while using embedded openejb for testing in eclipse

Posted by David Blevins <da...@visi.com>.
Hi Per,

It isn't clear what's causing the issue based on the stack trace  
(NoClassDefFoundErrors usually require some debugging).  I'm going to  
try and convert one of our examples into an eclipse project and see if  
I can't get something working.  I'll post the workspace when I'm done.

If you'd like to post a workspace that reproduces the issue as well,  
that'd be great too.  Even if the space I create works, I'd be nice to  
know what happened for support reasons.

-David

On Nov 2, 2007, at 3:20 PM, Per Newgro wrote:

> Hi *,
>
> i try to run my SLSB Tests on an embedded openejb server - without  
> any extra
> configuration. I added all required libs (try and error :-). But now  
> i get a
> strange exception. (OpenEJB is in eclipse classpath). How can i  
> reuse the
> eclipse classpath for my tests?
>
> Cheers
> Per
>
> javax.naming.NamingException: Attempted to load OpenEJB.
> java.lang.NoClassDefFoundError [Root exception is
> java.lang.ClassCastException: java.lang.NoClassDefFoundError]
>
>             at
> org 
> .apache.openejb.client.LocalInitialContextFactory.getInitialContext(L
> ocalInitialContextFactory.java:47)
>
>             at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java: 
> 667)
>
>             at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
>
>             at javax.naming.InitialContext.init(InitialContext.java: 
> 223)
>
>             at
> javax.naming.InitialContext.<init>(InitialContext.java:197)
>
>             at
> de 
> .yhd.buma.backend.backendtests.OpenEjbAccessTest.setUp(OpenEjbAccessTe
> st.java:40)
>
>             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
>             at
> sun 
> .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>
>             at
> sun 
> .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
>
>             at java.lang.reflect.Method.invoke(Method.java:585)
>
>             at
> org 
> .junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAf
> terRunner.java:74)
>
>             at
> org 
> .junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfte
> rRunner.java:50)
>
>             at
> org 
> .junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf
> terRunner.java:33)
>
>             at
> org 
> .junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.j
> ava:75)
>
>             at
> org 
> .junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45
> )
>
>             at
> org 
> .junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestC
> lassMethodsRunner.java:66)
>
>             at
> org 
> .junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRu
> nner.java:35)
>
>             at
> org.junit.internal.runners.TestClassRunner 
> $1.runUnprotected(TestClassRun
> ner.java:42)
>
>             at
> org 
> .junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf
> terRunner.java:34)
>
>             at
> org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java: 
> 52)
>
>             at
> org 
> .eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4Tes
> tReference.java:38)
>
>             at
> org 
> .eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
> va:38)
>
>             at
> org 
> .eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:460)
>
>             at
> org 
> .eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:673)
>
>             at
> org 
> .eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:386)
>
>             at
> org 
> .eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:196)
>
> Caused by: java.lang.ClassCastException:  
> java.lang.NoClassDefFoundError
>
>             at
> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java: 
> 38)
>
>             at
> org 
> .apache.openejb.client.LocalInitialContextFactory.init(LocalInitialCo
> ntextFactory.java:59)
>
>             at
> org 
> .apache.openejb.client.LocalInitialContextFactory.getInitialContext(L
> ocalInitialContextFactory.java:45)
>
>             ... 25 more
>