Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to invoke remote ejb services in osgi?

Avatar

Former Community Member

Hi 

Im a new bibe to AEM, Im looking to call the ejb service which is hosted in Jboss 7.0.1 Final in osgi bundle. I have added all the supporting client jars by converting them to bundle and deployed in Felix console. The exact problem is, the properties that are set in InitialContext[Javax.naming] is not looking up the remote jndi name.

Can any one help me on this.

Regards,

Jaisudha

1 Accepted Solution

Avatar

Correct answer by
Level 10

HI Jaisudha,

   I would recommend to avoid it or else try to engage with profession service. It is little challenging & need to take care of couple of things like Exported as system bundle, might have to implement Thread Context ClassLoader which is incorrect etc...

Thanks,

Sham

View solution in original post

6 Replies

Avatar

Level 10

In this case - CQ is the external Java client calling the EJB service. See: 

Calling EJB Session Beans from External Java Clients

Are you saying the Look up is failing - for example:

InitialContext context = new InitialContext(); Object sbobj = context.lookup("sssw://" + servername + "/RMI/" + sbjndiname);

Avatar

Former Community Member

Hi..

Below is an elaboration on how im trying to do, which is actually working in stand alone java code.

1. Setting the below properties in jboss-ejb-client.properties file which is placed in src folder directly.

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

2. Adding the url prefixes to the property and 

  Properties propsIC = new Properties();
  propsIC.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");                      
  InitialContext ctx = new InitialContext(propsIC);  

3. Looking up using initial context

EjbPocRemote --> This is the stub interface which is kept at client side [packaged same like an service remote for lookup] 

  EjbPocRemote ejbRemote = (EjbPocRemote)ctx.lookup("ejb:/HelloWorldSessionBean//EjbPoc!com.cts.ejbtest.EjbPocRemote");                      
 

Problem: now if i try to print the ejbRemote i get null when i deploy the same code in osgi felix console.. 

Please correct me if the look up name is wrong wrt osgi. is this the correct way ? Can you provide a guide on how to write a EJB client as a osgi bundle while the EJB is hosted in jboss.

Regards,

Jaisudha

Avatar

Former Community Member


I would need a guide to set the thread context classloader (TCCL) for InitialContext and lookup in osgi filex client.

Regards,

Jaisudha

Avatar

Former Community Member
Can any one reply on this. Im still stuck  up on this.

Avatar

Level 10

As sham has suggested, this is not a straight forward AEM use case and not supported out of the box (explains why you are getting null). In this case, contact AEM professional services as Sham suggested.

Avatar

Correct answer by
Level 10

HI Jaisudha,

   I would recommend to avoid it or else try to engage with profession service. It is little challenging & need to take care of couple of things like Exported as system bundle, might have to implement Thread Context ClassLoader which is incorrect etc...

Thanks,

Sham