

Inject EJB 3 into Tapestry 4 page

this text is a copy of the mail : "RE: Inject EJB 3 into Tapestry 4 page" by Denis Souza-3 Jan 20, 2007; 08:48pm

I sent an e-mail a few weeks ago asking about injecting EJBs in tapestry pages. I found a way to do it, so I'm sharing it with the list since there were other people interested. It's really very easy.

All you have to do is create a hivemind object provider that will supply you with the information you want. Something like this:

public class EJBObjectProvider implements ObjectProvider {


This is a bit simplified. In my case I use a caching mechanism to save on jndi lookups.

Then you have to tell hivemind about your new object provider by adding to you hivemodule.xml:

<service-point id="EJBObjectProvider" interface="org.apache.hivemind.service.ObjectProvider">


I'm also injecting an application state manager for my own logic, but you can use anything here. Also add the following:

<contribution configuration-id="hivemind.ObjectProviders">


That's it. Now you can inject any EJBs by simply adding something like this in your page or component:

@InjectObject("ejb:myBeanJndiName") public abstract MyBean getMyBean();

I hope it was helpful. I really don't know that much about hivemind use so it took me some tapestry source code exploring to figure this one out. I welcome any suggestions on how to improve this.

Cheers, Denis

InjectEJB3 (last edited 2011-01-02 02:29:23 by BobHarner)