Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002451 [Resin] major always 02-20-08 04:09 03-05-08 15:37
Reporter anloci View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.1.6 Product Version 3.1.4
  Product Build
Summary 0002451: In EL lib getType(...) must not be getValue(...).getClass()
Description I'm working with JSF 1.2 with the following example:
BEANS:

public class Register {
  ...
  protected Tutorial[] tutorials=null;

  public Tutorial[] getTutorials() {
    ...
  }

  public void setTutorials(Tutorial[] tutorials) {
    ...
  }
}

public class RegistrationInfo {
  public Tutorial[] getTutorials() {
   ...
  }
}

CONVERTER:
public class TutorialConverter implements Converter {
  public Object getAsObject(FacesContext ctxt, UIComponent component, String str) throws ConverterException {
    Tutorial tutorial=null;
    ...
    return tutorial;
  }
     
  public String getAsString(FacesContext ctxt, UIComponent component, Object value) throws ConverterException {
    String str=null;
    Tutorial tutorial=(Tutorial)value;
    ...
    return str;
  }
}

JSF FORM:
   <f:view>
     <h:form id="form1">
       ...
       <h:selectManyCheckbox id="tuts" value="#{register.tutorials}">
         <f:converter converterId="TutorialConverter" />
         <f:selectItem itemValue="#{RegistrationInfo.tutorials[0]}" itemLabel="Tutorial 1"/>
         <f:selectItem itemValue="#{RegistrationInfo.tutorials[1]}" itemLabel="Tutorial 2"/>
         <f:selectItem itemValue="#{RegistrationInfo.tutorials[2]}" itemLabel="Tutorial 3"/>
       </h:selectManyCheckbox>
       <h:commandButton action="check" value="Submit" />
     </h:form>
   </f:view>

MANAGED BEANS:
  <managed-bean>
    <managed-bean-name>registrationForm</managed-bean-name>
      <managed-bean-class>Register</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
  <managed-bean>
    <managed-bean-name>RegistrationInfo</managed-bean-name>
    <managed-bean-class>RegistrationInfo</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
  </managed-bean>

SEQUENCE:
When I submit the form with some boxes checked with some tutorials, Resin (through JSF) raise me an "java.lang.IllegalArgumentException - argument type mismatch" exception.

PROBLEM:
After debuging the submision of the form I detected that: when the JSF implementation (MyFaces 1.2.2) ask for the type of the expresion '#register.tutorials' (delegated to the implementation of the EL lib), return a null value because the implementation of the method getType(...) (lines 467-477) is:
package com.caucho.el;
...
public abstract class Expr extends ValueExpression {
...
  public Class<?> getType(ELContext context)
    throws PropertyNotFoundException,
       ELException
  {
    Object value = getValue(context);

    if (value == null)
      return null;
    else
      return value.getClass();
  }
...
}

because the method returns a null value, the implementation of JSF tries to call the method setTutorials using as parameter an Object[] class... so, it fails.
The origin of the problem is because the implementation of getType(...) calls getValue(...).getClass() and that implementation is not complete.
Steps To Reproduce
Additional Information I solve manually the problem:
1) changing some implementation of some classes adding a getType method. P.e:
com.caucho.el.ArrayResolverExpr
  @Override
  public Class<?> getType(ELContext env)
    throws ELException
  {
    Object aObj = _left.getValue(env);

    if (aObj == null)
      return null;

    Object fieldObj = _right.getValue(env);
    if (fieldObj == null)
      return null;

    return env.getELResolver().getType(env, aObj, fieldObj);
  }

com.caucho.el.PathExpr
  @Override
  public Class<?> getType(ELContext env)
    throws ELException
  {
    Class<?> type = _expr.getType(env);

    if (type != null)
      return type;

    return env.getELResolver().getType(env, _path, null);
  }

2) Including the el-api.jar library from Tomcat 6.0.16. Because the implementation of the method getType(...) in javax.el.CompositeELResolver returns the correct class, Tutotrial[]. The implementation given in resin return a null value.
Attached Files

- Relationships

- Notes
(0002821)
ferg
03-05-08 15:37

jsp/3160
 

- Issue History
Date Modified Username Field Change
02-20-08 04:09 anloci New Issue
03-05-08 15:37 ferg Note Added: 0002821
03-05-08 15:37 ferg Assigned To  => ferg
03-05-08 15:37 ferg Status new => closed
03-05-08 15:37 ferg Resolution open => fixed
03-05-08 15:37 ferg Fixed in Version  => 3.1.6


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker