Version 8

    J2EE Clients

     

    J2EE defines an application client module. This is essentially just a client-side local environment naming context within which JNDI names are resolved with the prefix java:/comp/env. This is identical to the usage on the server side; the additional level of indirection means you can avoid using hard-coded names in the client. The name mapping is effected by the use of the proprietary jboss-client.xml which resolves the references defined in the standard application-client.xml. See the docs/jboss-client_4_0.dtd for the syntax of the jboss-client.xml descriptor.

     

    One issue with a Java client is how it bootstraps itself into the system, how it manages to connect to the correct JNDI server to lookup the references it needs. The information is supplied by using standard Java properties. You can find details of these and how they work in the JDK API documentation for the javax.naming.Context class. The properties can either be hard-coded, or supplied in a file named jndi.properties on the classpath, for example:

     

    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    java.naming.provider.url=jnp://localhost:1099
    
    java.naming.factory.url.pkgs=org.jboss.naming.client
    j2ee.clientName=bank-client
    

     

    The first three are standard properties, which are set up in order to use the default JBoss JNDI implementation. The j2ee.clientName property identifies the client deployment information on the server side. The name must match the jndi-name specified in the META-INF/jboss-client.xml descriptor of the application client jar deployment:

     

    <jboss-client> 
        <jndi-name>bank-client</jndi-name> 
        <ejb-ref> 
            <ejb-ref-name>ejb/customerController</ejb-ref-name> 
            <jndi-name>MyCustomerController</jndi-name> 
        </ejb-ref> 
        <ejb-ref> 
            <ejb-ref-name>ejb/accountController</ejb-ref-name> 
            <jndi-name>MyAccountController</jndi-name> 
        </ejb-ref> 
    </jboss-client> 
    

     

    The java client application itself is run the same as any other java program. There is no special launcher entry point required.

     

    JavaEE5 Clients

    See this article for a sample of how to use EJB injection in application clients:

    How to use an application client in JBoss-5