-
1. Re: Dynamically changing jboss-ejb-client.properties, again
elvisd Jul 2, 2012 8:08 AM (in response to veitg)Hi,
I have managed to connect a client to a jboss instance without using that properties file.
My code is working in JBoss AS 7.1 and 7.2 alpha 1 (and 6.0.0 EAP cause is based on 7.1)
The code looks like:
Properties clientProp = new Properties();
clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientProp.put("remote.connections", "default");
clientProp.put("remote.connection.default.host", "localhost"); // comes from JVM argument
clientProp.put("remote.connection.default.port", "4447"); // comes from JVM argument
clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming:org.jnp.interfaces");
// props.put("jboss.naming.client.ejb.context"/**/, true); // check if needed...
context = new InitialContext(props);
Hope this helps
-
2. Re: Dynamically changing jboss-ejb-client.properties, again
veitg Jul 2, 2012 8:24 AM (in response to elvisd)Yes, but your code depends on JBoss specific client classes now .
-
3. Re: Dynamically changing jboss-ejb-client.properties, again
wdfink Jul 2, 2012 11:11 AM (in response to veitg)Hi,
looks like that Elvis D, use my example, just to clarify "jboss.naming.client.ejb.context" must be set if you don't have a jboss-ejb-client.properties file in your classpath, otherwise it will not work.
Veit, for you, yes this is a lot of JBoss specific stuff in there. But we are working on it, there is an enhancement EJBCLIENT-34 for this to provide a property based solution.
But it depends on what you need. At the moment jaikiran pai and I are working on this and try to provide examples how to use this.
The examples will be available via quickstarts, so check that list.
-
4. Re: Dynamically changing jboss-ejb-client.properties, again
veitg Jul 2, 2012 11:54 AM (in response to wdfink)Great news. Thanks! I'll keep an eye on it .
-
5. Re: Dynamically changing jboss-ejb-client.properties, again
fernando46 Nov 19, 2012 8:35 AM (in response to veitg)Is there any way to write a EJB independent (jboss-client.jar) from JBoss libraries?
-
6. Re: Dynamically changing jboss-ejb-client.properties, again
wdfink Nov 19, 2012 9:51 AM (in response to fernando46)Hi Fernando,
you can use the remote-naming project or the new features of EJBCLIENT-34.
For EJBCLIENT-34 you need to have a 7.2 upstream build at the moment.
You need to set 'org.jboss.ejb.client.scoped.context' to true in your properties. All other properties are the same as in the example above.
A example how to use it is available here.
-
7. Re: Dynamically changing jboss-ejb-client.properties, again
qtm Nov 23, 2012 10:03 AM (in response to wdfink)In order to call bean1 on server1 from bean2 located on server2 without any property files or configurations on the server side it is necessary to write in bean2 something like:
final Properties env1 = new Properties();
env1.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
env1.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env1.put("remote.connections", "Server-1");
env1.put("org.jboss.ejb.client.scoped.context", true);
env1.put("remote.connection.Server-1.host", "host");
env1.put("remote.connection.Server-1.port", "port");
env1.put("remote.connection.Server-1.username", "user");
env1.put("remote.connection.Server-1.password", "pass");
final Context ctx = new InitialContext(env1);
I am missing something, since the code above doesn't work. Could somebody point what's wrong?
Thank you
-
8. Re: Dynamically changing jboss-ejb-client.properties, again
sfcoy Nov 23, 2012 8:32 PM (in response to qtm)qtm wrote:
In order to call bean1 on server1 from bean2 located on server2 without any property files or configurations ...
In my opinion the cleanest solution to this problem has always been to have federated JNDI working. I haven't yet looked into this with AS 7.x, but it was easy to do in previous JBoss versions.
Doing it this way means that applications never deal with property files at all.
-
9. Re: Dynamically changing jboss-ejb-client.properties, again
wdfink Nov 26, 2012 5:28 AM (in response to qtm)qtm schrieb:
In order to call bean1 on server1 from bean2 located on server2 without any property files or configurations on the server side it is necessary to write in bean2 something like:
final Properties env1 = new Properties();
env1.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
env1.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env1.put("remote.connections", "Server-1");
env1.put("org.jboss.ejb.client.scoped.context", true);
env1.put("remote.connection.Server-1.host", "host");
env1.put("remote.connection.Server-1.port", "port");
env1.put("remote.connection.Server-1.username", "user");
env1.put("remote.connection.Server-1.password", "pass");
final Context ctx = new InitialContext(env1);
I am missing something, since the code above doesn't work. Could somebody point what's wrong?
Thank you
This code will not work correct inside the server as the EJBClientContext is global. With EJBCLIENT-34 a new feature is introduced that will resolve this.
I've implement an example here for the multi-server quickstart, but remember that this will only work if you have a AS7.2 (nightly build ATM)