aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Remote EJB URL Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Remote EJB URL Issue" Watch "Remote EJB URL Issue" New topic
Author

Remote EJB URL Issue

Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

I'm trying to setup an EJB connection to a remote server in Geronimo 1.2 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 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?


My Blog: Down Home Country Coding with Scott Selikoff
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

I'm curious to know what happens if the provider URL is just "ejbd:" Seems very odd that your system would interpret that string as a host when the URL is clearly in correct form.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

I removed the ejbd: and it gave me a malformed URL exception. Sigh.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

What if you leave in "ejbd:" but remove the rest?
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

With just "ejbd:"

ERROR [ActionUtils] getRemoteFacade...
javax.naming.ConfigurationException: Invalid provider URL:ejbd:: 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)
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

I did some exploring into the source code of openejb 2.1 and stripped away the offending code:


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)

Note: url.getHost() returns "ejbd"

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? There's no error on creating the URL.

Next, I took the code snippet and removed the "http://" and tried this code:

But I get an exception on creating the URL:
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? BTW if I can solve the malformed url exception, I could solve the entire problem by passing in a Hashtable (instead of a Properties set) with the URL object all ready initialized.
[ May 19, 2008: Message edited by: Scott Selikoff ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Remote EJB URL Issue