Non-persistent EJB injection in a JSF-managed bean calls NullPointer ex in WAS 8.5

A Java EE 6 project using the JSF 2.x mojarra implementation (both for testing 2.0 and 2.1), where the beans session is injected via @EJB annotations into JSF-managed beans crashing in WebSphere Application Server 8.5, while it runs on Glassfish 3. x (tested on GF 3.0 and 3.1, respectively):

The coding approach is as follows:

SomeEJBFacade.java

@Stateless public class SomeEJBFacade() { public String testMethod() { return "testing 1 2 3"; } } 

Testbean

 @ManagedBean @ViewScoped public class TestBean implements java.io.Serializable { @EJB SomeEJBFacade facade; public String getTestStr() { return facade.testMethod(); } } 

JSF wrapper snippet:

 <h:outputText value="#{testBean.testStr}" /> 

the above leads to a Null Pointer Exception from the TestStr () method of TestBean.

Similarly, any transactional JPA method throws null-pointer exceptions to similar items.

+4
source share
1 answer

The problem is that GlassFishs and the WebSpheres class loader work differently. You must add the ejb module as a dependency in the META-INF / MANIFEST.MF web projects:

 Class-Path: EnappDaemonEJB.jar 

Where "EnappDaemonEJB.jar" is the name of the generated jar / EJB artifact, or, in other words, the name of my EJB project is "EnappDaemonEJB".

Link: WebSphere Infocenter - see Procedure 2

0
source

All Articles