NullPointerException when injecting EJB3.0 inside the taglib of web application.

(Doc ID 1325475.1)

Last updated on JUNE 09, 2016

Applies to:

Oracle WebLogic Server - Version 10.3.3 and later
Information in this document applies to any platform.

Symptoms

When injecting remote EJB into the taglibs and on using the taglibs inside the JSP page you will notice a NullpointerException.

public class MessageTag extends BodyTagSupport {
private static final long serialVersionUID = 1L;
@EJB
ITestEjb testEjb;

public int doEndTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
String message = testEjb.sayHello();
out.write(message);
} catch (IOException e) {
.printStackTrace();
System.out.println(e.getCause());
}
return EVAL_PAGE;
}
}


The class MessageTag is located in the EJB module. Below Exception is thrown when invoking the EJB.

<Error> <HTTP> <BEA-101020><[ServletContext@5049220[app:taglib module:taglibWeb path:/taglibWeb spec-version:2.5]] Servlet
failed with Exception
java.lang.NullPointerException
at com.bea.tags.MessageTag.doEndTag(MessageTag.java:26)
at jsp_servlet.__helloworld._jsp__tag0(__helloworld.java:106)
at jsp_servlet.__helloworld._jspService(__helloworld.java:73)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run (StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri tyHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav a:300)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(Servlet StubImpl.java:416)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>


This was working fine until WLS 10.3.2 and failing in the above version.
If move the taglib class(MessageTag ) from EJB module to Webapp module you will notice it works fine.

Changes

@The problem was introduced

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms