Sunday, October 7, 2012

strange exception under JSF+JSP

Since we combined JSP with JSF 1.2 on websphere community edition (wasc 2.1.1.4) (same for apache geronimo/apache tomcat), i often see mysteriously looking exception: A literal value was specified for attribute actionListener (see below for stack). This looks like we cannot use #{...} expressions used by faces but only ${...} used by JSP. This is the exception itself:

Caused by: org.apache.jasper.JasperException: /portal/activity/ActivityResultInfo.jsp(377,8) A literal value was specified for attribute actionListener that is defined as a deferred method with a return type of void. JSP.2.3.4 does not permit literal values in this case
 at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
 at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
 at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
 at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1119)
 at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846)
 at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
 at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
 at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
 at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865)
 ...
Fortunately we have not only found the problem but also a cure. Assuming web.xml for server is located in C:\Tools\WASC 2.1.1.4\var\catalina\conf, make sure it contains following entries:
  
        jsp
        org.apache.jasper.servlet.JspServlet
 
        modificationTestInterval
        0
    
        
            development
            true
        
        
            fork
            false
        
        
            xpoweredBy
            false
        
        
            engineOptionsClass
            org.apache.geronimo.jasper.JspServletOptions
    
    
        scratchdir
        c:/Tools/WASC 2.1.1.4/var/catalina/worker1/

    
    
        keepgenerated
        true
    
        3
    
keepgenerated = true is very important. Now, you can get rid of problem undeploying app, stopping your app server, cleaning scratch dir and redeploying app back. Then faces should run normally.