<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: Problems with JBoss 7 and remote-interface lookup with context
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/dayserivera">dayse rivera</a> in <i>Beginner's Corner</i> - <a href="https://community.jboss.org/message/756260#756260">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I'm facing the same problem. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm developing my first<span class="postbody"> ejb 3 client on jboss 7.1. But, I can't make a lookup. <br/> After EJB deploy the following message is shown on console: <br/> <br/> <strong>11:48:33,718 INFO&#160; [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-<a href="http://www.guj.com.br/images/smilies/b2eb59423fbf5fa39342041237025880.gif"><span> http://www.guj.com.br/images/smilies/b2eb59423fbf5fa39342041237025880.gif </span></a> JNDI bindings for session bean named CalculatorBean in deployment unit subdeployment "EJB3_Chap02.jar" of deployment "TesteEar.ear" are as follows: <br/> <br/> &#160;&#160;&#160;&#160;&#160;java:global/TesteEar/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote <br/> &#160;&#160;&#160;&#160;&#160;java:app/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote <br/> &#160;&#160;&#160;&#160;&#160;java:module/CalculatorBean!calc.CalculatorRemote <br/> &#160;&#160;&#160;&#160;&#160;java:jboss/exported/TesteEar/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote <br/> &#160;&#160;&#160;&#160;&#160;java:global/TesteEar/EJB3_Chap02/CalculatorBean <br/> &#160;&#160;&#160;&#160;&#160;java:app/EJB3_Chap02/CalculatorBean <br/> &#160;&#160;&#160;&#160;&#160;java:module/CalculatorBean</strong> <br/> <br/> I try to lookup as follow, but it isn't work: <br/> <br/> <strong>package calc.client; <br/> <br/> import java.util.Hashtable; <br/> <br/> import javax.naming.Context; <br/> import javax.naming.InitialContext; <br/> import javax.naming.NamingEnumeration; <br/> import javax.naming.NamingException; <br/> <br/> import calc.CalculatorRemote; <br/> <br/> public class CalculatorClient { <br/> &#160;&#160;&#160;&#160;&#160;private static CalculatorRemote remote; <br/> &#160;&#160;&#160;&#160;&#160;public static void main(String[] args) { <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;try{ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;remote = lookupRemoteStatelessCalculator(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//context.lookup("EJB3_Chap02/" + CalculatorBean.class.getSimpleName() + "/remote"); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;System.out.println(remote.add(1, 1)); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}catch (Exception e) { <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;e.printStackTrace(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> &#160;&#160;&#160;&#160;&#160;} <br/> <br/> &#160;&#160;&#160;&#160;&#160;private static CalculatorRemote lookupRemoteStatelessCalculator() throws NamingException { <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final Hashtable jndiProperties = new Hashtable(); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447"); <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //jndiProperties.put("remote.connection.default.username","dayserivera"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //jndiProperties.put("remote.connection.default.password", "dayse"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put(Context.SECURITY_PRINCIPAL, "dayserivera"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put(Context.SECURITY_CREDENTIALS, "dayse"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; /* <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("endpoint.name", "client-endpoint"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connections", "default"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connection.default.port", "4447"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connection.default.host", "localhost"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; */ <br/> jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //jndiProperties.put("jboss.naming.client.ejb.context", true); <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final Context context = new InitialContext(jndiProperties); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; NamingEnumeration&lt;?&gt; namingEnum = context.list("java"); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; while(namingEnum.hasMoreElements()){ <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;Object obj = namingEnum.nextElement(); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;System.out.println(obj); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(context.lookup("ejb:TesteEar/EJB3_Chap02//CalculatorBean!calc.CalculatorRemote")); <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // The app name is the application name of the deployed EJBs. This is typically the ear name <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // without the .ear suffix. However, the application name could be overridden in the application.xml of the <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // EJB deployment on the server. <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Since we haven't deployed the application as a .ear, the app name for us will be an empty string <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String appName = ""; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // This is the module name of the deployed EJBs on the server. This is typically the jar name of the <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // jboss-as-ejb-remote-app <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String moduleName = "EJB3_Chap02"; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // our EJB deployment, so this is an empty string <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String distinctName = ""; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // The EJB name which by default is the simple class name of the bean implementation class <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //final String beanName = CalculatorBean.class.getSimpleName(); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // the remote view fully qualified class name <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String viewClassName = CalculatorRemote.class.getName(); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // let's do the lookup <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //return (CalculatorRemote) context.lookup("ejb:" + appName + "/" + beanName); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //return (CalculatorRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName); <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return (CalculatorRemote) context.lookup("ejb:TesteEar/EJB3_Chap02//CalculatorBean!calc.CalculatorRemote"); <br/>&#160;&#160;&#160;&#160; } <br/> <br/> } <br/> </strong></span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/756260#756260">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Beginner's Corner at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>