Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:54:42+00:00 2026-06-15T05:54:42+00:00

I am new to Java EE. At present I am going through The Java

  • 0

I am new to Java EE. At present I am going through The Java EE 6 Tutorial, Volume 1 (Basic Concepts Beta) by Sun Microsystems. To escape from monotonous reading time to time I play with few Java EE projects/codes written by others.

I came from SE. My head is still filled with SE. In SE (two tier application) I use

DATABASE_URL = "jdbc:mysql://something.db_server.com/db_name"

This is how my client knows where the database server is.

In one Java EE example I saw

// Access JNDI Initial Context.

Properties p = new Properties();

p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
p.put("java.naming.provider.url","jnp://localhost:1099");
p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

InitialContext ctx = new InitialContext(p);

// Change jndi name according to your server and ejb

HelloRemote remote = (HelloRemote) ctx.lookup("HelloBean/remote");

msg = "Message From EJB --> " + remote.sayHello();

This I understand. The code has url and port number. There is this line

p.put("java.naming.provider.url","jnp://localhost:1099");

Client side knows where is the server by the url and which port to knock. I think the code was written at the time of Java EE 5.

Today I have found another example where Netbeans 7, Java EE 6, and GlassFish 3 are used. The client side code

@EJB
private static MySessionRemote mySession;

/**
 * @param args the command line arguments
 */

public static void main(String[] args) {
    JOptionPane.showMessageDialog(null, 
            "result = " + mySession.getResult());
}

Here is the link
http://netbeans.org/kb/docs/javaee/entappclient.html

No url and port number are given.

Java EE 6 Development with Netbeans 7 by David R. Heffelfinger has a similar example in chapter 7. The author did not explain how it is done in the book. I think he has done it but I probably missed it…

My question is how the client side locate the server without url? Is it stated in one of those xml files? Client can be in California and the GlassFish Server can be in New York. Can anyone explain it to me or point to any tutorial/blog/article where I can find the answer?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:54:44+00:00Added an answer on June 15, 2026 at 5:54 am

    There are two things that are going on here.

    The first thing is that the way in which to obtain a reference to a remote EJB is not specified in Java EE. You are at the mercy of how an individual vendor thinks it should be done.

    Although JNDI is the de facto standard used for this, even this itself is not mandated.

    Example: JBoss up till AS7

    In JBoss AS up till AS 7, the following sequence was used to obtain a remote reference:

    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    env.put(Context.PROVIDER_URL, "jnp://myserver.example.com:1099");
    InitialContext context = new InitialContext(env);
    
    Bean bean = (Bean) context.lookup("myear/MyBean/remote");
    

    Here, the URL of the remote server is provided to the initial context and from that context a bean is retrieved. (Note that you must NOT add the well known “java:/” prefix here, or else it will be intercepted by JNDI and resolved locally, despite doing the lookup on a remote context)

    Since this method was as mentioned not standardized, a single vendor can change it completely between releases of implementations. Even for implementations for the same Java EE version.

    Example: JBoss AS7

    In JBoss AS 7, JBoss wanted to move away from JNDI (because it was not specified that JNDI had to be used) and now it happens in approximately the following way:

    You’ll first need to put a jboss-ejb-client.properties file on your classpath with the following context:

    endpoint.name = client-endpoint
    remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED = false
    remote.connections = default
    remote.connection.default.host = myserver.example.com
    remote.connection.default.port = 4447
    remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS = false
    

    And use code as the following:

    Properties env = new Properties();
    env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    InitialContext context = new InitialContext(env);
    
    Bean bean = (Bean) context.lookup("ejb:/myear/mymodule/MyBean!com.example.Bean");
    

    So from the code it looks like no URL is given, but it’s statically hidden in a config file.


    Application Client Container

    Today I have found another example where Netbeans 7, Java EE 6, and GlassFish 3 are used. The client side code […]

    This is yet another thing. What’s demonstrated there is a so-called Application Client Container (aka ACC).

    This is different from the example above, where a Java SE application used JNDI to contact the remote server. The Application Client Container is a bit of an obscure thing in Java EE. The idea seems to be that you download the client code dynamically from the Server (like an Applet or Java Web Start app), and that it then magically ‘knows’ where it originated from. There is very limited support for (static) injection in the main class, which you can use to inject remote beans directly.

    The Application Client Container is an idea from the early days of Java EE and as far as I know has never gotten much attention. After all these years it has never advanced much after its initial conception. Since it still requires a ton of vendor specific things to be done, I think most people don’t bother with it and just use JNDI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to draw a directed arrow line through Java. At present, I am
I'm interested in becoming more fluent in Java so I have been going through
I am new to java technology so please excuse me if I present a
When I start a new Java project in eclipse, the first popup screen allow
We are starting a new Java EE project and am looking for suggestions regarding
When creating a new Java project in IntelliJ IDEA, the following directories and files
I am starting a new Java web project that will be worked on by
Eclipse and MyEclipse create new Java files with an extra blank line after the
java.util.Date date = new java.util.Date(); java.sql.Date today = new java.sql.Date(date.getTime()); //2012-03-23 java.sql.Time time =
We are starting a new java web-project with Cassandra as the database. The team

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.