You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by ApolloX <sc...@selikoff.net> on 2008/05/16 19:39:54 UTC
Remote EJB Connect - Initial Context, host unknown Exception
I'm trying to setup an EJB connection to a remote server but am getting a
host unknown exception. I tried setting it to the local server itself
(127.0.0.1) but the exception is the same regardless.
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
properties.setProperty(Context.SECURITY_PRINCIPAL, "system");
properties.setProperty(Context.SECURITY_CREDENTIALS, "----");
final Context context = new InitialContext(properties);
generates the following error:
javax.naming.ConfigurationException: Invalid provider
URL:ejbd://127.0.0.1:4201: host unknown: ejbd: ejbd
at
org.apache.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:158)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
...
Is this just a server configuration issue, a jar/classpath issue, or
something else? I've checked the config.xml file and the open ejb service
is defined on port 4201 although I don't see it running in the admin
console.
Any suggestions? I'm using G1 although I'd imagine the problem I'm having
would be in G2 as well.
--
View this message in context: http://www.nabble.com/Remote-EJB-Connect---Initial-Context%2C-host-unknown-Exception-tp17280392s134p17280392.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: Remote EJB Connect - Initial Context, host unknown Exception
Posted by David Blevins <da...@visi.com>.
On May 16, 2008, at 10:39 AM, ApolloX wrote:
>
> I'm trying to setup an EJB connection to a remote server but am
> getting a
> host unknown exception. I tried setting it to the local server itself
> (127.0.0.1) but the exception is the same regardless.
>
> final Properties properties = new Properties();
> properties
> .setProperty
> (Context
> .INITIAL_CONTEXT_FACTORY
> ,"org.apache.openejb.client.RemoteInitialContextFactory");
> properties.setProperty(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
> properties.setProperty(Context.SECURITY_PRINCIPAL, "system");
> properties.setProperty(Context.SECURITY_CREDENTIALS, "----");
> final Context context = new InitialContext(properties);
>
> generates the following error:
>
> javax.naming.ConfigurationException: Invalid provider
> URL:ejbd://127.0.0.1:4201: host unknown: ejbd: ejbd
> at
> org
> .apache
> .openejb.client.JNDIContext.getInitialContext(JNDIContext.java:158)
> at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> 662)
> at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
> at javax.naming.InitialContext.init(InitialContext.java:219)
> at javax.naming.InitialContext.<init>(InitialContext.java:195)
> ...
>
> Is this just a server configuration issue, a jar/classpath issue, or
> something else? I've checked the config.xml file and the open ejb
> service
> is defined on port 4201 although I don't see it running in the admin
> console.
>
> Any suggestions? I'm using G1 although I'd imagine the problem I'm
> having
> would be in G2 as well.
In G1 you must leave the prefix off as such:
final Properties properties = new Properties();
properties
.setProperty
(Context
.INITIAL_CONTEXT_FACTORY
,"org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, "127.0.0.1:4201");
final Context context = new InitialContext(properties);
And I'm not certain if the SECURITY_PRINCIPAL and SECURITY_CREDENTIALS
parameters work in G1.
In G2 the PROVIDER_URL works with or without the prefix and
SECURITY_PRINCIPAL and SECURITY_CREDENTIALS definitely do work.
-David
Re: Remote EJB Connect - Initial Context, host unknown Exception
Posted by Viet Nguyen <vh...@gmail.com>.
I'm not positive if the problem exists in G2, but I'm certain that it
is possible to do this in G2.1 and above.
--Viet
Re: Remote EJB Connect - Initial Context, host unknown Exception
Posted by ApolloX <sc...@selikoff.net>.
I did some exploring into the source code of openejb 2.1 and stripped away
the offending code:
final String serverURL = "ejbd://127.0.0.1:4201";
final URL url = new URL("http://"+serverURL);
final InetAddress inet = InetAddress.getByName(url.getHost());
Now, if I catch the exception it, it throws a similar exception openejb
reported:
java.net.UnknownHostException: ejbd: ejbd
at java.net.InetAddress.getAllByName0(InetAddress.java:1145)
at java.net.InetAddress.getAllByName(InetAddress.java:1072)
at java.net.InetAddress.getAllByName(InetAddress.java:1008)
at java.net.InetAddress.getByName(InetAddress.java:958)
Its adding http + ejb for connection strings resulting in a url of:
"http://ejbd://127.0.0.1:4201". First question, is this an invalid URL?
The URL class does not throw an error on creating this URL. The method
url.getHost() returns "ejbd".
Next, I took the code snippet and removed the "http://" and tried this code:
final String serverURL = "ejbd://127.0.0.1:4201";
final URL url = new URL(serverURL);
But I get an exception on the second line of:
java.net.MalformedURLException: unknown protocol: ejbd
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
Any suggestions?
--
View this message in context: http://www.nabble.com/Remote-EJB-Connect---Initial-Context%2C-host-unknown-Exception-tp17280392s134p17317520.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.