Saturday, February 16, 2013

Classloader Classpath problems in WebSphere 7.0

Whenever I tried to experiment with classpaths in WebSphere 7.0 for example, change the classloader policy to "parent last" or set isolated classloader for a shared library to true, I ran into issues. More specifically, the Admin Console which is a system application that runs under the moniker of "isclite" web application would not run. The WAS server raised the following
exceptions:

E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet
/error.jsp in application isclite.
Exception created : com.ibm.websphere.servlet.error.ServletErrorReport: javax.servlet.jsp.JspException:
Cannot find message resources under key org.apache.struts.action.MESSAGE
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:695)
at _ibmjsp._error._jspService(_error.java:243)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)


Caused by: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
at org.apache.struts.util.RequestUtils.retrieveMessageResources(Unknown Source)
at org.apache.struts.util.RequestUtils.message(Unknown Source)
at org.apache.struts.taglib.bean.MessageTag.doStartTag(Unknown Source)
at _ibmjsp._error._jspx_meth_bean_message_0(_error.java:315)
javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.SAXParserFactory cannot be found
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at org.apache.struts.action.WebXMLServletMappingParser.getParser(Unknown Source)
at org.apache.struts.action.WebXMLServletMappingParser.getXMLReader(Unknown Source)
at org.apache.struts.action.WebXMLServletMappingParser.parse(Unknown Source)
at org.apache.struts.action.ActionServlet.initServlet(Unknown Source)
at org.apache.struts.action.ActionServlet.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)

A work around to correct a classpath issue is to stop the server, directly access the classpath setting at the following location (libraries.xml) and restart the server.

C:\WAS70\profiles\AppSrv01\config\cells\US-L3L5666-LNode05Cell\nodes\US-L3L5666-LNode05\servers\server1

setAsText: Cannot find FacesContext warning / error

I was recently converting a project from Faces (JSF) to NonFaces using JSTL, JSP, AJAX and jQuery.

I was making changes to a JSP page.  All of a sudden, the page which was working before stopped working.  The console logged the warning:setAsText: Cannot find FacesContext
Also, the error " com.ibm.ws.jsp.JspCoreException: com.ibm.ws.jsp.JspCoreException: javax.faces.Face
sException: Cannot find FacesContext."

I started to panic - do I still need the JSF config?

The cause of the issue happens to be
< jsp:setProperty name="tsdec" property="entryDate" value="${pped1}"  / >

Whenever JSTL needs to convert "string" value to a complex data type for example java.util.Date and it does not find a custom tag for its conversion,  it applies setAsText() method.  If it does not find the JSF implementation files, it throws the above error.   I find it odd that this method is bundled into JSF implementation.

In the above case, I added the fmt tag to parse the date:

< fmt:parseDate var="pped1" value="${s_pped}" type="date" pattern="MM/dd/yyyy" scope="request"  / >


That resolved the issue.