• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exposing Spring beans to JNDI, then accessing using remote EJB

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a WAR that exposes some beans over to JNDI. I then have a Stateless SB that returns an interface to the Spring bean.

The Spring bean is :

ProductManagerImpl which implements IProductManager

The EJB is :

@javax.ejb.Stateless(name = "ProductManagerEJB")
@Local(ProductManagerLocal.class)
@Remote(ProductManagerRemote.class)
public class ProductManagerBean implements ProductManagerLocal, ProductManagerRemote {
public IProductManager getProductManager() {
IProductManager productManager=null;
try {
InitialContext context = new InitialContext();
productManager = (IProductManager) context.lookup("ProductManager"); //This is bound using Spring

} catch (NamingException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return productManager;
}
}

When lookup the bean on JNDI, I get a ClassNotFoundException for ProductManagerBeanImpl (the actual implementation). Is this needed at the client side? I'm trying to not have too much that is needed at the client side. The Jboss documentation is all very confusing to me.

InitialContext initialContext = new InitialContext();
ProductManagerRemote productManagerRemote = (ProductManagerRemote) initialContext.lookup(G_EJB_BRIDGE_PRODUCT_MANAGER_EJB_REMOTE);
System.out.println(productManagerRemote.getProductManager().getName());

-Avi
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I then have a Stateless SB that returns an interface to the Spring bean.


It is not sufficient to have the interface of the Spring bean on the client - you will need the implementation of the Spring bean because the Spring bean is not remote, only the EJB is remote. In other words, when you make this method call on the EJB, what you get back is the Spring bean, not a proxy to it. (Unless I am completely misunderstanding what you are doing...)
 
Avinash Ramana
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter,

Is there a way to have the Spring bean a Proxy that implements its interface? For some reason, I thought that the JBoss proxied remote EJB could make calls to any implementation given that it implements an interface.

What would you recommend if I want to expose Spring beans to JNDI and be able to use them remotely through their interface without requiring the implementation be on the client jar?

Thank you so much BTW!

-Avi
reply
    Bookmark Topic Watch Topic
  • New Topic