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