Getting java.lang.AbstractMethodError on creation of the FacesContext.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.2.1
- Java Server Faces (JSF)
- 1.2
- IceFaces
- 1.8.2
Issue
- Getting
JBWEB000236: Servlet.service() for servlet Persistent Faces Servlet threw exception: java.lang.AbstractMethodError: com.icesoft.faces.webapp.http.servlet.ServletExternalContext$1.login(Ljava/lang/String;Ljava/lang/String;)when using the following code excerpt in JSF 1.2:-
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext eCtx = ctx.getExternalContext();
HttpServletRequest req = (HttpServletRequest) eCtx.getRequest();
HttpServletRequest request = (HttpServletRequest)externalContext.getRequest();
request.login(username, password);
Resolution
- This is an
icefacesissue asgetRequestin the below code returns an inner class instead of the actual HttpServletRequest:
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext eCtx = ctx.getExternalContext();
System.out.println("ExternalContext is loaded from: " + getCodeLocation(eCtx));
System.out.println("ExternalContext runtime class is: " + eCtx.getClass().getName());
HttpServletRequest req = (HttpServletRequest) eCtx.getRequest();
System.out.println("HttpServletRequest is loaded from: " + getCodeLocation(req));
System.out.println("HttpServletRequest runtime class is: " + req.getClass().getName());
Root Cause
- The following excerpt is used in the application:-
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext eCtx = ctx.getExternalContext();
System.out.println("ExternalContext is loaded from: " + getCodeLocation(eCtx));
System.out.println("ExternalContext runtime class is: " + eCtx.getClass().getName());
HttpServletRequest req = (HttpServletRequest) eCtx.getRequest();
System.out.println("HttpServletRequest is loaded from: " + getCodeLocation(req));
System.out.println("HttpServletRequest runtime class is: " + req.getClass().getName());
- And the outout pf the above code is as follows:
FacesContext is loaded from: vfs:/content/abc.war/WEB-INF/lib/icefaces.jar
ExternalContext is loaded from: vfs:/content/abc.war/WEB-INF/lib/icefaces.jar
ExternalContext runtime class is: com.icesoft.faces.webapp.http.servlet.ServletExternalContext
HttpServletRequest is loaded from: vfs:/content/abc.war/WEB-INF/lib/icefaces.jar
HttpServletRequest runtime class is: com.icesoft.faces.webapp.http.servlet.ServletExternalContext$1
- This shows that,In some scenarios where
ICEFACESlibrary is used in the web application thegetRequestreturns an inner class instead of the actual HttpServletRequest which causes the issue.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
