JNDI url problem

G

gk

in ejb tutorial i have found the following code for JNDI set up

code
====
import javax.naming.*;
javax.rmi.PortableRemoteObject;
import java.util.Properties;
............
............


public class BeanClient {
public static void main(String[] args) {
// preparing properties for constructing an InitialContext object
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");




My question is:

Question 1 :

what is this url "localhost:1099" ?
i am using JBoss application server. my application directory(context
path ) is "/myapps"



should i change this url to "localhost:1099/myapps" ??


question 2: what is this port "1099" . is it the admin server port ? is
it the port of local server ?
 
B

Bjorn Abelli

...

[snipped code]
what is this url "localhost:1099" ?

"localhost" is simply the adress to the server.

1099 is the number for the port where JBoss is listening for your
JNDI-reguests.
i am using JBoss application server. my application
directory(context path ) is "/myapps"

should i change this url to "localhost:1099/myapps" ??

Nope, that doesn't make any sense. Just leave it as in the example, unless
you're working with a client on a different machine than where JBoss
resides.

The port doesn't have any directories... ;-)

From that port you can retrieve a "root context", from which you can do the
actual requests.

Something similar to this:

Context context = (Context) new InitialContext(properties);
Object e = context.lookup("Name of the service");

etc...


// Bjorn A
 
B

Bjorn Abelli

...

Nope, that doesn't make any sense. Just leave it as in the example, unless
you're working with a client on a different machine than where JBoss
resides.

On the other hand, that depends on how you configured the JNDI-names in
JBoss.

"/myapps" in "localhost:1099/myapps" could then mean that you have a
root-context named "myapps", and not just as a simple lookupname.

Then it could probably work, although I would rather use even that in the
actual lookup instead.
From that port you can retrieve a "root context", from which
you can do the actual requests.

Something similar to this:

Context context = (Context) new InitialContext(properties);
Object e = context.lookup("myapps/Name of the service");

etc...

// Bjorn A
 
R

Roedy Green

question 2: what is this port "1099" . is it the admin server port ? is
it the port of local server ?

It looks like some sort of local server is going to be set up using
port 1099. Both ends have to agree on the port, same as they do for
port 80 for HTTP. Presumably you could change it, if you changed the
server and all the clients.
 
R

Roedy Green

should i change this url to "localhost:1099/myapps" ??

I would say no. Read the docs to be sure. A service on 1099 has
nothing to do with the file system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top