Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to lookup Remote EJB in JBoss 7.x
    primarykey
    data
    text
    <p>I am trying to connect to a Remote EJB that is deployed in a JBoss 7 Server. I tried to figure out what the JNDI name is by looking at the JNDI dump that I got from the JBoss CLI.<br> No matter what I try I cannot lookup the EJB.</p> <p>I think that the jndi name should be: java:global/XNet/api/ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote</p> <p>Here is the client that I am using:</p> <pre><code>package com.mycompany.mavenproject1; import com.mycompany.receiving.api.ReceivingAPI_EJBRemote; import com.mycompany.receiving.api.ReceivingAPI; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Properties; /** * Hello world! * */ public class App { public static void main( String[] args ) throws NamingException { System.out.println( "Hello World!" ); //ReceivingAPI ejbRemote = DomainHelper.getHQApi(com.mycompany.receiving.api.ReceivingAPI.class); ReceivingAPI_EJBRemote ejbRemote = App.lookupRemoteStatelessCalculator(); ejbRemote.getOpenRcvdocForSite(null, 7); } // private static ReceivingAPI_EJBRemote lookupRemoteStatelessReceiving() throws NamingException { // // } // private static ReceivingAPI_EJBRemote lookupRemoteStatelessCalculator() throws NamingException { final Properties jndiProperties = new Properties(); jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProperties.put(Context.PROVIDER_URL,"remote://someserver.xmx.com:1199"); // username jndiProperties.put(Context.SECURITY_PRINCIPAL, "mycompany1"); // password jndiProperties.put(Context.SECURITY_CREDENTIALS, "&lt;removed&gt;"); //final Context context = new InitialContext(jndiProperties); jndiProperties.put("jboss.naming.client.ejb.context", true); InitialContext context = new InitialContext( jndiProperties ); // The app name is the application name of the deployed EJBs. This is typically the ear name // without the .ear suffix. However, the application name could be overridden in the application.xml of the // EJB deployment on the server. // Since we haven't deployed the application as a .ear, the app name for us will be an empty string final String appName = "XNet"; // This is the module name of the deployed EJBs on the server. This is typically the jar name of the // EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml // In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is // jboss-as-ejb-remote-app final String moduleName = "api"; // AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for // our EJB deployment, so this is an empty string final String distinctName = "hq"; // The EJB name which by default is the simple class name of the bean implementation class final String beanName = com.mycompany.receiving.api.ReceivingAPI.class.getSimpleName(); // the remote view fully qualified class name final String viewClassName = ReceivingAPI_EJBRemote.class.getName(); // let's do the lookup try { ReceivingAPI test1 = (ReceivingAPI)context.lookup("java:global/XNet/api/" + beanName + "_EJB!" + viewClassName); System.out.println("Test1 = " + test1.getClass().getName()); } catch(Throwable t) { System.out.println(t); } try { ReceivingAPI test = (ReceivingAPI)context.lookup("java:global/XNet/api/hq/" + beanName + "_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote"); System.out.println("Test = " + test.getClass().getName()); } catch(Throwable t) { System.out.println(t); } try { ReceivingAPI test = (ReceivingAPI)context.lookup("ejb:XNet/api/hq/" + beanName + "_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote"); System.out.println("Test = " + test.getClass().getName()); } catch(Throwable t) { System.out.println(t); } return (ReceivingAPI_EJBRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "_EJB!" + viewClassName); } } </code></pre> <p>The output from the run of the previous java class:</p> <pre><code>Hello World! javax.naming.NameNotFoundException: global/XNet/api/ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote -- service jboss.naming.context.java.jboss.exported.global.XNet.api."ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote" javax.naming.NameNotFoundException: global/XNet/api/hq/ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote -- service jboss.naming.context.java.jboss.exported.global.XNet.api.hq."ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote" javax.naming.NameNotFoundException: ejb:XNet/api/hq/ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote -- service jboss.naming.context.java.jboss.exported.ejb:XNet.api.hq."ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote" Exception in thread "main" javax.naming.NameNotFoundException: ejb:XNet/api/hq/ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote -- service jboss.naming.context.java.jboss.exported.ejb:XNet.api.hq."ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote" at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) </code></pre> <p>Here is the dump of the JNDI CLI Command:</p> <pre><code>[jboss1@hmudev01 bin]$ ./jboss-cli.sh --connect controller=localhost:10099 [standalone@localhost:10099 /] /subsystem=naming:jndi-view { "outcome" =&gt; "success", "result" =&gt; { "java: contexts" =&gt; { "java:global" =&gt; { "XNet" =&gt; { "class-name" =&gt; "javax.naming.Context", "children" =&gt; { "api" =&gt; { "class-name" =&gt; "javax.naming.Context", "children" =&gt; { "ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBLocal" =&gt; { "class-name" =&gt; "com.mycompany.receiving.api.ReceivingAPI_EJBLocal$$$view46", "value" =&gt; "Proxy for view class: com.mycompany.receiving.api.ReceivingAPI_EJBLocal of EJB: ReceivingAPI_EJB" }, "ReceivingAPI_EJB!com.mycompany.receiving.api.ReceivingAPI_EJBRemote" =&gt; { "class-name" =&gt; "com.sun.proxy.$Proxy272", "value" =&gt; "Proxy for remote EJB StatelessEJBLocator{appName='XNet', moduleName='api', distinctName='hq', beanName='ReceivingAPI_EJB', view='interface com.mycompany.receiving.api.ReceivingAPI_EJBRemote'}" }, } } } } } } ... } } [standalone@localhost:10099 /] </code></pre> <p>Any my maven deps are as follows:</p> <pre><code> &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;com.mycompany.receiving&lt;/groupId&gt; &lt;artifactId&gt;xnet-domain-receiving-client&lt;/artifactId&gt; &lt;version&gt;2.5.0-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.as&lt;/groupId&gt; &lt;artifactId&gt;jboss-as-naming&lt;/artifactId&gt; &lt;version&gt;7.1.3.Final&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.marshalling&lt;/groupId&gt; &lt;artifactId&gt;jboss-marshalling-river&lt;/artifactId&gt; &lt;version&gt;1.4.0.Final&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.client&lt;/groupId&gt; &lt;artifactId&gt;jbossall-client&lt;/artifactId&gt; &lt;version&gt;5.0.0.GA&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.spec.javax.ejb&lt;/groupId&gt; &lt;artifactId&gt;jboss-ejb-api_3.1_spec&lt;/artifactId&gt; &lt;version&gt;1.0.2.Final&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload