-
1. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
shadowcreeper May 24, 2012 7:37 PM (in response to shadowcreeper)Assumed answer: This cannot be done because JBoss 7.1 is broken by design.
-
2. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink May 25, 2012 2:05 AM (in response to shadowcreeper)1 of 1 people found this helpfulThis behaviour of the ejb-client is subject to change.
I would not say "broken by design" but I aggree that there are some functional differences.
The main issue was the standartization of the JNDI name.
First the EJB is identified by its name
* application name (i.e. ear name)
* module name (i.e. name of the ejb-jar inside the ear)
* distinct name
* Bean name
* Bean Interface
See the documentation
There are many different approaches to achieve the wanted behaviour.
Could you describe a bit what you want and how your deployment topology is?
-
3. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
shadowcreeper May 29, 2012 3:11 PM (in response to wdfink)We have an application (EAR) which connects to several other services (EJBs within EARs on other JBoss servers).
EJB 1 may be on Server A, while EJB 2 may be on Server B (there are several EJBs on several different servers).
In JBoss 5 we just told the app which servers each EJB was located on. It would then only check Server B for EJB 2, and would not use EJB 2 on Server A even if one existed.
This is the behavior I am trying to replicate. Always use Server B for EJB 2 (and ignore EJB 2 on any server but Server B). EJB 1 may be an optional service, so that if Server A is down, we run with limited functionality, but we do not need to keep trying to connect to Server A when trying to get/use EJB 2 which we already know exists on Server B.
-
4. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 5, 2012 4:06 AM (in response to shadowcreeper)At the moment the EJB is identified by its name. If you have a client-context which contains different servers you can not decide which server is taken if you have an EJB with the same identifier depoyed on each.
The only way to do it for the moment is to have a 'distinct' name in the jboss-ejb3.xml inside the application or defined in the server configuguration (ejb3 subsystem).
But this behaviour is subject to change.
-
5. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
jaikiran Jun 6, 2012 2:29 AM (in response to wdfink)Wolf-Dieter Fink wrote:
The only way to do it for the moment is to have a 'distinct' name in the jboss-ejb3.xml inside the application or defined in the server configuguration (ejb3 subsystem).
But this behaviour is subject to change.
Just to be clear - the distinct name behaviour is not going to change.
-
6. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 6, 2012 5:40 AM (in response to jaikiran)Sorry for confusion and thanks to Jaikiran for clarify it.
I meant that the behaviour of the client context, regarding the selection and influence what server handle the request, is subject to change.
The JNDI names and the distinct name are not part of that as Jakiran mentioned.
-
7. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
shadowcreeper Jun 6, 2012 2:59 PM (in response to wdfink)When you say "the distinct name behavior is not going to change"...
Do you mean that if you fix this later and allow us to determine which server to connect to per EJB, that it will fail to work if it finds another EJB with that same "distinct name" on another server that it knows about event though I told it specifically to use a different server?
Or do you mean that the way we specify "distinct name" (ear/jar/class!interface) is not going to change?
-
8. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 6, 2012 3:11 PM (in response to shadowcreeper)I'm not sure what you exactly mean.
But the distinct name can be used to differencing two deployed application with the same name.
If the client-context allows you to decide which server you mean this is only another option.
If you use the distinct name as workaround for the moment, sure you have to change the name if you decide to use the server-selection instead of distinct name.
-
9. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
shadowcreeper Jun 6, 2012 8:14 PM (in response to wdfink)I was asking for clarification on your previous post: What may change? What may not?
You used the phrases "distinct name" and "JNDI names" in ways that I did not understand.
I had incorrectly assumed the following definitions:
JNDI name (when looking up remote EJBs): java:jboss/exported/ear-name/jar-name/EJB-name!interface-class
distinct name: the part of "JNDI name" following "jboss:/jboss/exported/"
Thanks
-
10. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 7, 2012 6:02 AM (in response to shadowcreeper)From client side the bean is identified by its name.
There are different options how to setup the client see [1]
* InitialContext without a property file (using PROVIDER_URL remote:/host:4447)
* InitialContext with jboss-ejb-client.property file
* Using the JBoss specific API
The identifier of the Bean is
ejb:/ear/jar/distinct name/beanname!Interface
or
ear/jar/beanname!interface
so the distinct name is part of the identifier and can be set in the META-INF/jboss-ejb3.xml of the application or global in the ejb subsystem for all applications of the server.
This behaviour will not change as Jaikiran mentioned.
Only the method how the client side select the server is subject to change.
[1] https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
-
11. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
shadowcreeper Jun 7, 2012 8:22 PM (in response to wdfink)Are you saying that we can still use "remote:/host:4447" to determine where to lookup the bean?
If so, how? I have found no examples anywhere. Nor have I been the least bit successful in my attempts to figure it out. I have never gotten the JBoss 7.1.1.Final server to recognize PROVIDER_URL.
When I leave the servers out of the jboss-ejb-client properties file (or remove the file entirely) I get failure no matter what is in the PROVIDER_URL. When I add in all servers to the properties file, it checks all servers no matter what I put into PROVIDER_URL (and if multiple servers have the same bean, then both are used in a sort of load-balancing/sharing way).
-
12. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 8, 2012 4:17 AM (in response to shadowcreeper)This should work:
{code}
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
final Hashtable<Object,Object> jndiProperties = new Hashtable<Object,Object>();
jndiProperties.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProperties.put(InitialContext.PROVIDER_URL, "remote://localhost:4447");
final Context context = new InitialContext(jndiProperties);
slsb = (StatelessSession) context.lookup(EJB3SLSB/ejb/StatelessSessionBean!"+StatelessSession.class.getName());
{code}
-
13. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
jaikiran Jun 8, 2012 4:27 AM (in response to wdfink)Wolf-Dieter Fink wrote:
This should work:
import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; final Hashtable<Object,Object> jndiProperties = new Hashtable<Object,Object>(); jndiProperties.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProperties.put(InitialContext.PROVIDER_URL, "remote://localhost:4447"); final Context context = new InitialContext(jndiProperties); slsb = (StatelessSession) context.lookup("ear/jar/StatelessSessionBean!"+StatelessSession.class.getName());
Wolf is right, although that code is missing an (important) property. Don't forget to add the following property if you want to do EJB invocations, using the same connection that was established via PROVIDER_URL:
jndiProperties.put("jboss.naming.client.ejb.context", true);
-
14. Re: How to specify host/port in remote JNDI lookup on JBoss 7.1.1.Final?
wdfink Jun 8, 2012 5:07 AM (in response to jaikiran)Yes, Jaikiran you're right, normally I add this.
But I took this from a working code example. Is there a difference between the AS7 versions?
Other thing is that it looks like this is working by accident if you have a valid jboss-ejb-client.properties in the classpath, maybe this force the behaviour also ?!
If I remove it you definitly need this property!