geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neal Sanche <n...@nsdev.org>
Subject Re: Standalone Clients
Date Sat, 25 Jun 2005 23:07:51 GMT
Hi All,

Okay, just a followup to my query, it seems that the 
org.openejb.client.RemoteInitialContextFactory doesn't take its 
parameters from the System properties, because when I used a Properties 
class and passed it into the 'new InitialContext(props)' method, I was 
able to get a connection to the server and look up an EJB and make calls 
to it remotely.

I'll just do that for now, since I'm on a bit of a deadline here today. 
For the curious my code looks like this now:

    public void Connect() {
        String hostName = "127.0.0.1";
        String port = "4201";
   
        Properties props = new Properties();
       
        props.setProperty("java.naming.factory.initial",
                "org.openejb.client.RemoteInitialContextFactory");
        props.setProperty("java.naming.provider.url", hostName+":"+port);
        props.setProperty("java.naming.security.principal", "system");
        props.setProperty("java.naming.security.credentials", "manager");
       
        try {
            Context ic = new InitialContext(props);
            PhoneBookSessionHome sessionHome = (PhoneBookSessionHome)
                
PortableRemoteObject.narrow(ic.lookup(PhoneBookSessionHome.JNDI_NAME),PhoneBookSessionHome.class);
            phoneBookSession = sessionHome.create();
            fireConnectionEvent(true);
        } catch (Throwable ex) {
            ex.printStackTrace();
            fireConnectionEvent(false);
        }
    }

Cheers.

-Neal

Neal Sanche wrote:

> Hi All,
>
> I am trying to make a standalone client using Geronimo HEAD. It's not 
> going so well so far. I've done the following:
>
>    public void Connect() {
>        String hostName = "127.0.0.1";
>        String port = "4201";
>              System.setProperty("java.naming.factory.initial",
>                "org.openejb.client.RemoteInitialContextFactory");
>        System.setProperty("java.naming.provider.url", hostName+":"+port);
>        System.setProperty("java.naming.security.principal", "system");
>        System.setProperty("java.naming.security.credentials", "manager");
>              try {
>            Context ic = new InitialContext();
>            Object o = ic.lookup(PhoneBookSessionHome.JNDI_NAME);
>                      PhoneBookSession session = 
> PhoneBookSessionUtil.getHome().create();
>                      fireConnectionEvent(true);
>        } catch (Throwable ex) {
>            ex.printStackTrace();
>            fireConnectionEvent(false);
>        }
>    }
>
> The code fails on the 'new InitialContext()' with the error:
>
> javax.naming.AuthenticationException: Cannot read the response from 
> the server.; nested exception is:
>    java.io.EOFException
>    at org.openejb.client.JNDIContext.authenticate(JNDIContext.java:196)
>    at 
> org.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:181)
>    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:175)
>    at org.acme.phonebook.client.Application.Connect(Application.java:70)
>
> Should I be loading some sort of deployment into my Geronimo server 
> first? The port 4201 seems to answer telnet connections, so there's 
> something there. According to an article on the IBM site, the client 
> needs the following Jars in the classpath, which I have done:
>
>    * openejb-core-2.0-SNAPSHOT.jar
>    * geronimo-spec-j2ee-1.4-rc4.jar
>    * geronimo-kernel-1.0-SNAPSHOT.jar
>    * geronimo-security-1.0-SNAPSHOT.jar
>    * cglib-nodep-2.1.jar
>
> Any ideas?
>
> Thanks.
>
> -Neal
>
>


Mime
View raw message