You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Francisco Borges <fr...@x-hive.com> on 2007/07/05 15:08:10 UTC

Geronimo & JUnit problems

Hello,

I'm trying to add Geronimo support to this database we have. I've started 
with Geronimo1.2.

I'm already able to run our sample application, but I couldn't get any of 
the unittests to run. 

Is there some special setup to run junitejb with Geronimo?

They all invariably fail with:

==============================================
Cannot read the response from the server (OEJP/2.0) : null; nested 
exception is: java.io.EOFException:
 
 javax.naming.AuthenticationException: Cannot read the response from the 
server (OEJP/2.0) : null; nested exception is: java.io.EOFException at 
org.apache.openejb.client.JNDIContext.authenticate(JNDIContext.java:178) 
at 
org.apache.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:163) 
at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) 
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) 
at javax.naming.InitialContext.init(InitialContext.java:223) at 
javax.naming.InitialContext.<init>(InitialContext.java:175) at 
net.sourceforge.junitejb.EJBTestCase.getEJBTestRunner(EJBTestCase.java:85) 
at net.sourceforge.junitejb.EJBTestCase.runBare(EJBTestCase.java:59) at 
net.sourceforge.junitejb.EJBTestCase.run(EJBTestCase.java:48)
===============================================

Would this be cause by the fact that with Geronimo I need to explicitly 
pass the System properties in order to log in, and that JUnitEJB is 
perhaps not doing that?

Would Geronimo2.0 be any better regarding JUnit integration? 

Cheers,
-- 
Francisco Borges

Re: Geronimo & JUnit problems

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 7/12/07, Francisco Borges <fr...@x-hive.com> wrote:

> Glad you sent this link ;-)

You're welcome.

> I'll submit the issue there. (and I know of at least another couple of
> other bugs :-/)

Go Francisco go! The more the better. It's not that you report issues
and they'll get fixed in the coming version, but some surely will ;-)

> Geronimo1.2 will *fail* if:
>
> 1. From an application (outside Geronimo) trying to connect to a EJB in
> the server;
> 2. I try to get the InitialContext without explicitly passing the System
> properties:
>
> jndiCntx = new InitialContext();
>
> [java] javax.naming.AuthenticationException: Cannot read the response from
> the server (OEJP/2.0) : null; nested exception is:
>      [java]     java.io.EOFException
>      [java]     at
> org.apache.openejb.client.JNDIContext.authenticate(JNDIContext.java:178)
>      [java]     at
> org.apache.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:163)
>      [java]     at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
>      [java]     at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>      [java]     at
> javax.naming.InitialContext.init(InitialContext.java:223)
>      [java]     at
> javax.naming.InitialContext.<init>(InitialContext.java:175)
>
> If I use:
>
>  InitialContext jndiCntx = new InitialContext(System.getProperties());
>
> The code behaves as expected. I don't know for sure if this is Geronimo's
> fault or OpenEjb but it certainly happens, and is perfectly reproducible.

I can't reproduce it in Geronimo 2. I'm running the sample with

-Djava.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
 -Djava.naming.provider.url=127.0.0.1:4201

and the following snippet

        System.out.println("JNDI command line properties: ");
        System.out.println("\t" + Context.INITIAL_CONTEXT_FACTORY + "="
                + System.getProperty(Context.INITIAL_CONTEXT_FACTORY));
        System.out.println("\t" + Context.PROVIDER_URL + "=" +
System.getProperty(Context.PROVIDER_URL));
        Context initialCtx = new InitialContext();
        Object mejbObj =
initialCtx.lookup("MEJBGBean/MEJB/javax.management.j2ee.Management");
        ManagementHome mejbHome = (ManagementHome) mejbObj;
        Management mejb = mejbHome.create();
        System.out.println("...checking status of MEJBGBean - MBean
count=" + mejb.getMBeanCount());

works fine.

JNDI command line properties:
	java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
	java.naming.provider.url=127.0.0.1:4201
...checking status of MEJBGBean - MBean count=608

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Geronimo & JUnit problems

Posted by Francisco Borges <fr...@x-hive.com>.
On Thursday 12 July 2007, Jacek Laskowski wrote:
> On 7/12/07, Francisco Borges <fr...@x-hive.com> wrote:
> > On Wednesday 11 July 2007, Jacek Laskowski wrote:

> versions. Report issues you run into in JIRA [1] so we can track how
> much is done. Report anything you feel is relevant and what might
> improve Geronimo and thus user experience with it.
>
> [1] http://issues.apache.org/jira/browse/GERONIMO

Glad you sent this link ;-)

I'll submit the issue there. (and I know of at least another couple of 
other bugs :-/)

> > I'm running the tests from Ant, using a reworked version of JunitEJB
> > (project on sourceforge, last released Jar is from 2001).
> >
> > The problem I had was indeed the lack of passing
> > System.getProperties() when initializing the context. It is solved
> > now.
>
> I'm glad I can hear it. If I could read what exactly the problem was
> and how you solved it it'd be even better.

Geronimo1.2 will *fail* if:

1. From an application (outside Geronimo) trying to connect to a EJB in 
the server;
2. I try to get the InitialContext without explicitly passing the System 
properties:

jndiCntx = new InitialContext();

[java] javax.naming.AuthenticationException: Cannot read the response from 
the server (OEJP/2.0) : null; nested exception is:
     [java]     java.io.EOFException
     [java]     at 
org.apache.openejb.client.JNDIContext.authenticate(JNDIContext.java:178)
     [java]     at 
org.apache.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:163)
     [java]     at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
     [java]     at 
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
     [java]     at 
javax.naming.InitialContext.init(InitialContext.java:223)
     [java]     at 
javax.naming.InitialContext.<init>(InitialContext.java:175)

If I use:

 InitialContext jndiCntx = new InitialContext(System.getProperties()); 

The code behaves as expected. I don't know for sure if this is Geronimo's 
fault or OpenEjb but it certainly happens, and is perfectly reproducible.

Cheers,
-- 
Francisco Borges

Re: Geronimo & JUnit problems

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 7/12/07, Francisco Borges <fr...@x-hive.com> wrote:
> On Wednesday 11 July 2007, Jacek Laskowski wrote:
...
> > exceptional* == throwing lots of exceptions OR of a high quality.
> > Choose what suits better ;-)
>
> Sounds good. Specially the when you talk about "high quality exceptions".

You didn't notice the alternative (OR), did you? ;-) So, depending on
how far you are with Geronimo 'exceptional' does mean different
things.

http://dictionary.cambridge.org/define.asp?key=26754&dict=CALD
exceptional
adjective APPROVING
much greater than usual, especially in skill, intelligence, quality, etc:
an exceptional student
exceptional powers of concentration
The company has shown exceptional growth over the past two years.

As we're programming in Java the meaning of 'exceptional' can
sometimes be quite different.

> If there is one thing that I didn't like about Geronimo(1.2), is the lack
> of informative exceptions & error messages.

Yeah. You're not alone to have expressed it. We're working on it and
it seems to be a priority one to have it improved in the coming
versions. Report issues you run into in JIRA [1] so we can track how
much is done. Report anything you feel is relevant and what might
improve Geronimo and thus user experience with it.

[1] http://issues.apache.org/jira/browse/GERONIMO

> I'm running the tests from Ant, using a reworked version of JunitEJB
> (project on sourceforge, last released Jar is from 2001).
>
> The problem I had was indeed the lack of passing System.getProperties()
> when initializing the context. It is solved now.

I'm glad I can hear it. If I could read what exactly the problem was
and how you solved it it'd be even better.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Geronimo & JUnit problems

Posted by Francisco Borges <fr...@x-hive.com>.
On Wednesday 11 July 2007, Jacek Laskowski wrote:
> On 7/5/07, Francisco Borges <fr...@x-hive.com> wrote:
> > Would Geronimo2.0 be any better regarding JUnit integration?
>
> I can't claim it to be any better in this regard, but it's definitely
> worth to try out because of its Java EE 5 compliancy and exceptional*
> m2 support.

> exceptional* == throwing lots of exceptions OR of a high quality.
> Choose what suits better ;-)

Sounds good. Specially the when you talk about "high quality exceptions".

If there is one thing that I didn't like about Geronimo(1.2), is the lack 
of informative exceptions & error messages.

I've tried Geronimo2.0, but then there are new errors, and I still haven't 
had the time to look at it. (I'll probably send another mail ot the list 
about these later today.)

> How do you run the unit tests? What properties do you specify on the
> command line/to junit testcase?

I'm running the tests from Ant, using a reworked version of JunitEJB 
(project on sourceforge, last released Jar is from 2001).

The problem I had was indeed the lack of passing System.getProperties() 
when initializing the context. It is solved now.

Cheers,
-- 
Francisco Borges

Re: Geronimo & JUnit problems

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 7/5/07, Francisco Borges <fr...@x-hive.com> wrote:

> Would Geronimo2.0 be any better regarding JUnit integration?

I can't claim it to be any better in this regard, but it's definitely
worth to try out because of its Java EE 5 compliancy and exceptional*
m2 support.

How do you run the unit tests? What properties do you specify on the
command line/to junit testcase?

exceptional* == throwing lots of exceptions OR of a high quality.
Choose what suits better ;-)

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl