A definitive word on @EJB and CDI

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

A definitive word on @EJB and CDI

I'm using tapestry5.4 with java 8, in a JEE environment. Actually, I'm using JBoss 7.1.eap Application Server (which is, more or less, the same of WildFly8).

I'm packaging my tapestry5 WAR inside an EAR, and I need to access some stateless session beans declared in another JAR.

The current way I'm accessing the ejbeans is looking into the jndi tree in the web appModule with a code similar to the following:

public static IMyEjbInterface buildMyEjbImplementation() {
        // yes, I know that this works only under jboss :-)
        return = MyTools.jndiLookup("java:myJar/"+ MyEjbImplementation.class.getSimpleName());

This way I can inject the stateless session bean into my pages using the tapestry @Inject annotation.

I fell my solution is a little  bit clumsy, so I was wandering if there was a better way to do this.
I would be happy to learn the "tapestry5 recommended way" to reach this goal.

As first attempt, I thought that the simpler way is to inject the ejb directly into the page using an @EJB annotation.

Looking into docs and googling around I found the following options:

1) tapestry wiki: https://wiki.apache.org/tapestry/JEE-Annotation. This is a mix between flowlogix and tapestry jumpstart. This page has not been updated from 2011, so I wonder if it is something more up to date...

2) flowlogix: https://github.com/flowlogix/flowlogix. The last commit is two year old, but it seems to be stopped at tapestry 5.3

3) tapestry jump start: there is a working example, updated for tapestry 5.4, but it's scope is limited only to the @EJB annotation.

4) tapestry-cdi. This looks the most promising, I could use also some other annotation (I need @Singleton, for example), and I see that it is built inside the tapestry code source tree, so it should be updated and compatible with last version of the framework, but:

  a) I could not find a maven/gradle already built jar (eg: no org.apache.tapestry:tapstry-cdi:5.4.x)
  b) I cannot find this module in the staging/org/apache/tapestry/ repositories
  c) I could only find it by downloading sources or binaries of tapestry5 directly from tapestry5 web site.

So the question is: is tapestry-cdi the right way to go or it is "abandonware"?

Why tapestry-cdi it is not distributed with the others tapestry jars in mavencentral, jcenter or others repositories?

What is the recommended way to inject an EJB inside a tapestry page?

Thank you,

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]