-
-
2. Re: ExternalContext in AS7?
franbekh Feb 24, 2012 1:40 AM (in response to pmm)I have the same problem while proting my configuration from JBoss 6.1 to JBoss 7.1. I have configured the JNDI connection to LDAP. Does the configuration still work
with AS 7 or by which means can it be replaced?
Thanx
-
3. Re: ExternalContext in AS7?
pmm Apr 27, 2012 8:43 AM (in response to pmm)To answer my own question:
- even though org.jboss.system.ServiceMBean and org.jboss.system.ServiceMBeanSupport are gone SARs are still supproted so in theory it could be ported to AS7
- however the JNDI context is read-only in AS7 so this won't work
- I'm now looking into creating programatic JNDI bindings
-
4. Re: ExternalContext in AS7?
holger.lierse Feb 21, 2013 12:59 AM (in response to pmm)Hi Philippe,
We'ere currently migrating from JBoss 4.2.3 to JBoss AS7 and are using ExternalContexts. Do you have an example on how to replace a <mbean code="org.jboss.naming.ExternalContext"...>?
Is there any way to avoid programatic JNDI bindings and initialize a remote context at startup?
Basically I'm trying to avoid having to define and create and InitialContext for remote ejbs calls (on another server) . For example:
Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); properties.put("jnp.socket.Factory", "org.jnp.interfaces.TimedSocketFactory"); properties.setProperty("java.naming.provider.url", "jnp://"+ otherhost +":"+port); InvestorService remoteBean = (InvestorService) new InitialContext(properties).lookup("investor-service/InvestorService/remote"); remoteBean.getInvestor(); Can "investor-service" be added to the jndi context so it is already available?
Thanks
-
5. Re: ExternalContext in AS7?
j_ri Feb 21, 2013 2:52 AM (in response to holger.lierse)Hello Holger,
yes something like that is poosible.
You have to Implement the Interface "javax.naming.spi.ObjectFactory", put it as module in the "modules" folder of JBoss and then you have to register this class(es) in the standalone.xml/domain.xml:
/subsystem=naming/binding=java\:jboss\/exported\/MyExportedContext/:add(binding-type="object-factory",module="de.yourdomain.jndi",class="de.yourdomain.jndi.YourContextObjectFactory")
I found how to do it here: http://middlewaremagic.com/jboss/?p=1690
Good luck;-)
Jochen
-
6. Re: ExternalContext in AS7?
holger.lierse Feb 22, 2013 1:08 AM (in response to j_ri)Hi Jochen,
Thanks for the link. I've created an ObjectFactory which initializes the external context to do remote ejb lookups. Is there any way to integrate/bind this external context so I can do lookups such as:
@EJB(lookup="external-context/investorService/remote")
private InvestorService investorService;
Here's my ObjectFactory code:
{code}
public class JBoss4InitialContext implements ObjectFactory {
private static final Log LOG = LogFactory.getLog(JBoss4InitialContext.class);
private InitialContext context;
public JBoss4InitialContext() throws NamingException {
LOG.info("Initializing JBoss4InitialContext");
String host = "localhost";
String port = "10399";
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
properties.put("jnp.socket.Factory", "org.jnp.interfaces.TimedSocketFactory");
properties.setProperty("java.naming.provider.url", "jnp://" + host + ":" + port);
context = new InitialContext(properties);
}
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws Exception {
Object result = context.lookup(name);
return result;
}
}
{code}
Thanks
Holger
-
7. Re: ExternalContext in AS7?
pmm Feb 22, 2013 1:37 AM (in response to holger.lierse)To which version of JBoss AS 7 are you migrating? JBoss AS 7.2 again has full mbean support like previous versions. I don't know whether this is also available in JBoss AS 7.1.3. In the end we ended up putting the JNDI code from ExternalContextMBean into a resource adapter because that's a portable solution.