javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-67

Usability of JSF RI Exceptions and Stack Traces

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1_01
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      67

      Description

      One of the things that has caused Creator grief in the field is that many of the
      stack traces from exceptions deep inside the JSF RI (especially when thrown
      during a value binding or method binding evaluation) are not helpful in
      diagnosing the underlying cause. Just as an example, try this scenario:

      • Create a backing bean named "foo", and put a "public String logon()" method in it
        (I was building a login page)
      • Declare the backing bean as a managed bean, but forget to add the
        <managed-bean-scope> element.
      • Connect this to the "action" property of a button on the form ("# {foo.logon}")
        and run the app.

        The result you get is

        javax.servlet.ServletException: #{foo.logon}

        :
        javax.faces.el.EvaluationException: javax.faces.FacesException: Assertion Failed

      In order to debug the cause, you have to go to the server log, down to the third
      nested exception inside, where you find that the exception came from line 271 of
      com.sun.faces.application.ApplicationAssociate in the
      createAndMaybeStoreManagedBeans method. The culprit is the code:

      // add bean to appropriate scope
      String scope = managedBean.getScope();
      // scope cannot be null
      Utikl.doAssert(null != scope);

      Now, can you imagine any way to figure this out if you're just a developer
      trying to use JSF, and to figure it out without access to the source code of the
      RI, or (even with source access) if you don't have a pretty detailed knowledge
      of how the RI is put together? Wouldn't it really be better to throw an
      exception that says:

      No scope declared for managed bean 'foo'

      and make sure that gets included in the top-level stack trace echoed to the JSP
      page?

      Creator is using JSF 1.1_01 (plus the portlet fix) for our Reef release in
      December ... it's too late to integrate anything newer for that. But for our
      Thresher release in March, we'd really really like to see the JSF team put some
      attention into improving the helpfulness of exception messages. If you need to
      narrow the scope of this task because of resource constraints, here's a suggestion:

      • Go through the entire RI and banish Util.doAssert() calls – "Assertion failed"
        is not going to help anyone.
      • Focus on the kinds of exceptions that might get thrown in the com.sun.faces.el
        package as a result of user mistakes in their binding expressions. It should only
        take a few deliberate mistakes, and an observation of what you get back, to apply
        the "could an application developer figure out what happened without the JSF RI
        source code" litmus test.

        Activity

        Hide
        Ryan Lubke added a comment -

        Phase 2 towards resolution of this issue. This change bundle is fairly minor.
        Removed/Added assertions where necessary. Minor cleanup and i18n additions
        corrected while reviewing assertion usage.

        SECTION: Modified Files
        ----------------------------
        M jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java

        • i18n'd pending i18n comments
        • removed unused var

        M jsf-ri/src/com/sun/faces/application/ApplicationImpl.java

        • follow sun style guidlines

        M jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java

        • removed unneeded assert

        M jsf-ri/src/com/sun/faces/util/Util.java

        • added message constants
        • removed unnedded assert

        M jsf-ri/src/javax/faces/Messages.properties
        M jsf-ri/src/javax/faces/Messages_de.properties
        M jsf-ri/src/javax/faces/Messages_es.properties
        M jsf-ri/src/javax/faces/Messages_fr.properties

        • new messages

        M jsf-ri/test/com/sun/faces/util/TestUtil_messages.java

        • updated unit test to reflect new additions

        SECTION: Diffs
        ----------------------------
        Index: jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java,v
        retrieving revision 1.6
        diff -u -r1.6 ApplicationAssociate.java
        — jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java 23 Nov 2004
        19:26:52 -0000 1.6
        +++ jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java 30 Nov 2004
        19:08:07 -0000
        @@ -80,21 +80,25 @@
        private boolean responseRendered = false;

        private static final String ASSOCIATE_KEY = RIConstants.FACES_PREFIX +

        • "ApplicationAssociate";
          + "ApplicationAssociate";
        • public ApplicationAssociate() {
        • ExternalContext externalContext = null;
        • if (null == (externalContext =
        • ConfigureListener.getExternalContextDuringInitialize())) { - // PENDING I18N - throw new IllegalStateException("ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized()"); - }
        • // PENDING I18N
        • if (null != externalContext.getApplicationMap().get(ASSOCIATE_KEY)) { - throw new IllegalStateException("ApplicationAssociate already exists for this webapp"); - }
        • externalContext.getApplicationMap().put(ASSOCIATE_KEY, this);
          + public ApplicationAssociate()
          Unknown macro: {+ + ExternalContext externalContext;+ if (null == (externalContext =+ ConfigureListener.getExternalContextDuringInitialize())) { + throw new IllegalStateException( + Util.getExceptionMessageString( + Util.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID)); + }++ if (null != externalContext.getApplicationMap().get(ASSOCIATE_KEY)) { + throw new IllegalStateException( + Util.getExceptionMessageString( + Util.APPLICATION_ASSOCIATE_EXISTS_ID)); + }+ externalContext.getApplicationMap().put(ASSOCIATE_KEY, this); managedBeanFactoriesMap = new HashMap(); caseListMap = new HashMap(); wildcardMatchList = new TreeSet(new SortIt());@@ -239,14 +243,13 @@ return null; }
        • Object bean = null;
          + Object bean;
          try
          Unknown macro: { bean = managedBean.newInstance(context); if (log.isDebugEnabled()) { log.debug("Created bean " + managedBeanName + " successfully "); } }

          catch (Exception ex) {

        • Object[] params = {ex.getMessage()}

          ;
          if (log.isErrorEnabled())

          { log.error("Managedbean " + managedBeanName + " could not be created " + ex.getMessage(), ex); Index: jsf-ri/src/com/sun/faces/application/ApplicationImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationImpl.java,v retrieving revision 1.55 diff -u -r1.55 ApplicationImpl.java --- jsf-ri/src/com/sun/faces/application/ApplicationImpl.java 23 Nov 2004 19:26:53 -0000 1.55 +++ jsf-ri/src/com/sun/faces/application/ApplicationImpl.java 30 Nov 2004 19:08:09 -0000 @@ -251,7 +251,7 @@ }
        • public MethodBinding createMethodBinding(String ref, Class params[]) {
          + public MethodBinding createMethodBinding(String ref, Class[] params) {

        return this.methodBindingFactory.createMethodBinding(ref, params);

        Index: jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java,v
        retrieving revision 1.12
        diff -u -r1.12 CoreValidator.java
        — jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java 12 Oct 2004
        14:39:54 -0000 1.12
        +++ jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java 30 Nov 2004
        19:08:15 -0000
        @@ -11,7 +11,6 @@

        import com.sun.faces.taglib.FacesValidator;
        import com.sun.faces.taglib.ValidatorInfo;
        -import com.sun.faces.util.Util;
        import org.xml.sax.Attributes;
        import org.xml.sax.helpers.DefaultHandler;

        @@ -86,8 +85,7 @@

        • @param uri Tag library uri
          */
          protected String getFailureMessage(String prefix, String uri) {
        • // we should only get called if this Validator failed
        • assert (failed);
          + // we should only get called if this Validator failed
          StringBuffer result = new StringBuffer();

        if (idTagParser.hasFailed()) {
        @@ -112,7 +110,7 @@

        • @param ns Element name space.
        • @param ln Element local name.
        • @param qn Element QName.
        • * @param a Element's Attribute list.
          + * @param attrs Element's Attribute list.
          */
          public void startElement(String ns,
          String ln,
          @@ -136,9 +134,9 @@
        • <p>Parse the ending element. If it is a specific JSTL tag
        • make sure that the nested count is decreased.</p>
          *
          + * @param ns Element name space.
        • @param ln Element local name.
        • @param qn Element QName.
        • * @param a Element's Attribute list.
          */
          public void endElement(String ns, String ln, String qn) {
          validatorInfo.setQName(qn);
          Index: jsf-ri/src/com/sun/faces/util/Util.java
          ===================================================================
          RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v
          retrieving revision 1.147
          diff -u -r1.147 Util.java
            • jsf-ri/src/com/sun/faces/util/Util.java 23 Nov 2004 19:26:54 -0000 1.147
              +++ jsf-ri/src/com/sun/faces/util/Util.java 30 Nov 2004 19:08:19 -0000
              @@ -40,6 +40,7 @@
              import javax.faces.render.RenderKitFactory;
              import javax.faces.render.ResponseStateManager;
              import javax.servlet.ServletContext;
              +import javax.servlet.jsp.jstl.fmt.LocalizationContext;

        import java.io.IOException;
        import java.lang.reflect.Constructor;
        @@ -292,6 +293,12 @@

        public static final String MANAGED_BEAN_TYPE_CONVERSION_ERROR_ID =
        "com.sun.faces.MANAGED_BEAN_TYPE_CONVERSION_ERROR";
        +
        + public static final String APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID =
        + "com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK";
        +
        + public static final String APPLICATION_ASSOCIATE_EXISTS_ID =
        + "com.sun.faces.APPLICATION_ASSOCIATE_EXISTS";

        // README - make sure to add the message identifier constant
        @@ -672,7 +679,8 @@
        getLocaleFromContextOrComponent(FacesContext context,
        UIComponent component) {
        Locale result = null;

        • String bundleName = null, bundleAttr = "bundle";
          + String bundleName = null;
          + String bundleAttr = "bundle";

        Util.parameterNonNull(context);
        Util.parameterNonNull(component);
        @@ -681,12 +689,10 @@
        if (null !=
        (bundleName = (String) component.getAttributes().get(bundleAttr))) {
        // verify there is a Locale for this localizationContext

        • javax.servlet.jsp.jstl.fmt.LocalizationContext locCtx = null;
        • if (null != (locCtx =
        • (javax.servlet.jsp.jstl.fmt.LocalizationContext)
        • (Util.getValueBinding(bundleName)).getValue(context)))
          Unknown macro: {+ LocalizationContext locCtx = (LocalizationContext)+ Util.getValueBinding(bundleName).getValue(context);+ if (locCtx != null) { result = locCtx.getLocale(); - assert (null != result); } }

          if (null == result) {
          @@ -715,10 +721,9 @@
          if (null == attrs)

          { return false; }
        • int i = 0;
          Object attrVal;
          String empty = "";
        • for (i = 0; i < passthruAttributes.length; i++) {
          + for (int i = 0; i < passthruAttributes.length; i++)
          Unknown macro: { if (null != (attrVal = attrs.get(passthruAttributes[i])) && !empty.equals(attrVal)) { @@ -727,7 +732,7 @@ } }

          if (!result) {

        • for (i = 0; i < booleanPassthruAttributes.length; i++) {
          + for (int i = 0; i < booleanPassthruAttributes.length; i++) {
          if (null !=
          (attrVal = attrs.get(booleanPassthruAttributes[i]))
          &&
          @@ -761,15 +766,14 @@
          assert (null != writer);
          assert (null != component);
        • int i = 0, len = booleanPassthruAttributes.length, j,
        • jLen = (null != excludes ? excludes.length : 0);
        • Object value = null;
          + Object value;
          boolean result;
        • boolean skip = false;
        • for (i = 0; i < len; i++) {
          + boolean skip;
          +
          + for (int i = 0, len = booleanPassthruAttributes.length; i < len; i++) {
          skip = false;
          if (null != excludes) {
        • for (j = 0; j < jLen; j++) {
          + for (int j = 0, jLen = excludes.length; j < jLen; j++) {
          if (null != excludes[j] &&
          excludes[j].equals(booleanPassthruAttributes[i])) {
          skip = true;
          @@ -827,14 +831,12 @@
          assert (null != writer);
          assert (null != component);
        • int i = 0, len = passthruAttributes.length, j,
        • jLen = (null != excludes ? excludes.length : 0);
        • Object value = null;
        • boolean skip = false;
        • for (i = 0; i < len; i++) {
          + Object value;
          + boolean skip;
          + for (int i = 0, len = passthruAttributes.length; i < len; i++) {
          skip = false;
          if (null != excludes) {
        • for (j = 0; j < jLen; j++) {
          + for (int j = 0, jLen = excludes.length; j < jLen; j++) {
          if (null != excludes[j] &&
          excludes[j].equals(passthruAttributes[i])) {
          skip = true;
          @@ -1069,21 +1071,19 @@

        public static ResponseStateManager getResponseStateManager(FacesContext
        context, String renderKitId)
        throws FacesException

        { - RenderKit renderKit = null; - RenderKitFactory renderKitFactory = null; - ResponseStateManager result = null; - renderKitFactory = (RenderKitFactory) + assert (null != renderKitId); + assert (null != context); + + RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); assert (null != renderKitFactory); - assert (null != renderKitId); - - renderKit = renderKitFactory.getRenderKit(context, renderKitId); + RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId); assert (null != renderKit); - result = renderKit.getResponseStateManager(); - return result; + return renderKit.getResponseStateManager(); + }

        @@ -1263,7 +1263,6 @@
        public static String stripBracketsIfNecessary(String expression)
        throws ReferenceSyntaxException {
        assert (null != expression);

        • int len = 0;
          // look for invalid expressions
          if ('#' == expression.charAt(0)) {
          if ('{' != expression.charAt(1))
          Unknown macro: {@@ -1271,6 +1270,8 @@ Util.INVALID_EXPRESSION_ID, new Object[]{expression})); }

          +
          + int len;
          if ('}' != expression.charAt((len = expression.length()) - 1))

          { throw new ReferenceSyntaxException(Util.getExceptionMessageString( Util.INVALID_EXPRESSION_ID, @@ -1411,7 +1412,7 @@ }

          List result = new ArrayList();
          int i, j, len = expressionString.length(), cur = 0;

        • while (cur < len &&
          + while (cur < len &&
          -1 != (i = expressionString.indexOf("#{", cur))) { if (-1 == (j = expressionString.indexOf("}

          ", i + 2)))

          Unknown macro: { throw newReferenceSyntaxException(Util.getExceptionMessageString(Util.INVALID_EXPRESSION_ID,new Object[]{expressionString}));@@ -1463,7 +1464,7 @@ return ""; }
        • StackTraceElement stacks[] = e.getStackTrace();
          + StackTraceElement[] stacks = e.getStackTrace();
          StringBuffer sb = new StringBuffer();
          for (int i = 0; i < stacks.length; i++) {
          sb.append(stacks[i].toString() + "\n");
          Index: jsf-ri/src/javax/faces/Messages.properties
          ===================================================================
          RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages.properties,v
          retrieving revision 1.20
          diff -u -r1.20 Messages.properties
            • jsf-ri/src/javax/faces/Messages.properties 23 Nov 2004 19:26:54 -0000 1.20
              +++ jsf-ri/src/javax/faces/Messages.properties 30 Nov 2004 19:08:20 -0000
              @@ -70,6 +70,8 @@
        1. IMPLEMENTATION DEFINED MESSAGES
        2. ==============================================================================

        +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate
        ctor not called in same callstack as ConfigureListener.contextInitialized().
        +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists
        for this webapp.
        com.sun.faces.ASSERTION_FAILED=Assertion Failed
        com.sun.faces.ATTRIBUTE_NOT_SUPORTED=Attribute ''

        {0}'' not supported for
        component type ''{1}''.
        com.sun.faces.CANT_CONVERT_VALUE=Can''t convert property: ''{0}

        '' to value
        type: ''

        {1}''.
        Index: jsf-ri/src/javax/faces/Messages_de.properties
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_de.properties,v
        retrieving revision 1.19
        diff -u -r1.19 Messages_de.properties
        — jsf-ri/src/javax/faces/Messages_de.properties 23 Nov 2004 19:26:54 -0000 1.19
        +++ jsf-ri/src/javax/faces/Messages_de.properties 30 Nov 2004 19:08:20 -0000
        @@ -121,6 +121,8 @@
        com.sun.faces.TYPECONVERSION_ERROR_detail=Konvertierungs-Fehler: Wert ''{0}''
        f\u00fcr Modell ''{1}

        '' : Ausnahme:

        {2}.
        com.sun.faces.MODELUPDATE_ERROR_detail=ertes ''{0}'' f\u00fcr Modell
        ''{1}''.nahme: {2}

        .
        com.sun.faces.INVALID_EXPRESSION=Invalid expression: ''

        {0}''.
        +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate
        ctor not called in same callstack as ConfigureListener.contextInitialized().
        +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists
        for this webapp.

        com.sun.faces.NULL_FORVALUE=Bestandteil "{0}

        " nicht gefunden\
        com.sun.faces.EMPTY_PARAMETER=Parameter ist empty
        Index: jsf-ri/src/javax/faces/Messages_es.properties
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_es.properties,v
        retrieving revision 1.19
        diff -u -r1.19 Messages_es.properties
        — jsf-ri/src/javax/faces/Messages_es.properties 23 Nov 2004 19:26:54 -0000 1.19
        +++ jsf-ri/src/javax/faces/Messages_es.properties 30 Nov 2004 19:08:21 -0000
        @@ -122,6 +122,8 @@
        com.sun.faces.TYPECONVERSION_ERROR_detail=Error de conversion en el valor
        puesto ''

        {0}'' del modelo ''{1}'': excepci\u00f3n de: {2}
        com.sun.faces.MODELUPDATE_ERROR_detail=Error de poner al d\u00edda valor
        ''{0}

        '' para modelo ''

        {1}'' : excepci\u00f3n de: {2}.
        com.sun.faces.INVALID_EXPRESSION=Invalid expression: ''{0}''.
        +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate
        ctor not called in same callstack as ConfigureListener.contextInitialized().
        +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists
        for this webapp.

        com.sun.faces.NULL_FORVALUE=Componente "{0}" no encontrado
        com.sun.faces.EMPTY_PARAMETER=Parameter no encondrado
        Index: jsf-ri/src/javax/faces/Messages_fr.properties
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_fr.properties,v
        retrieving revision 1.18
        diff -u -r1.18 Messages_fr.properties
        — jsf-ri/src/javax/faces/Messages_fr.properties 23 Nov 2004 19:26:55 -0000 1.18
        +++ jsf-ri/src/javax/faces/Messages_fr.properties 30 Nov 2004 19:08:22 -0000
        @@ -122,6 +122,8 @@
        com.sun.faces.TYPECONVERSION_ERROR_detail=Erreur de conversion quand la valeur
        ''{0}'' est commise pour le mod\u00e9le ''{1}

        '' : Exception:

        {2}.
        com.sun.faces.MODELUPDATE_ERROR_detail=Erreur lors de la mise \u00b4 jour de la
        valeur ''{0}'' pour le mod\u00e9le ''{1}'' : Exception: {2}

        .
        com.sun.faces.INVALID_EXPRESSION=Invalid expression: ''

        {0}''.
        +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate
        ctor not called in same callstack as ConfigureListener.contextInitialized().
        +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists
        for this webapp.

        com.sun.faces.NULL_FORVALUE=Composant "{0}

        " non trouv\u00E9
        com.sun.faces.EMPTY_PARAMETER=Parameter non trouv\u00E9
        Index: jsf-ri/test/com/sun/faces/util/TestUtil_messages.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/util/TestUtil_messages.java,v
        retrieving revision 1.36
        diff -u -r1.36 TestUtil_messages.java
        — jsf-ri/test/com/sun/faces/util/TestUtil_messages.java 23 Nov 2004 19:26:55
        -0000 1.36
        +++ jsf-ri/test/com/sun/faces/util/TestUtil_messages.java 30 Nov 2004 19:08:26 -0000
        @@ -116,6 +116,8 @@

        {Util.MANAGED_BEAN_EXISTING_VALUE_NOT_LIST_ID, "2"}

        ,

        {Util.MANAGED_BEAN_CANNOT_SET_MAP_PROPERTY_ID, "2"}

        ,

        {Util.MANAGED_BEAN_TYPE_CONVERSION_ERROR_ID, "4"}

        ,
        +

        {Util.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID, "0"}

        ,
        +

        {Util.APPLICATION_ASSOCIATE_EXISTS_ID, "0"}

        ,
        };

        private String[][] toolsMessageInfo = {

        Show
        Ryan Lubke added a comment - Phase 2 towards resolution of this issue. This change bundle is fairly minor. Removed/Added assertions where necessary. Minor cleanup and i18n additions corrected while reviewing assertion usage. SECTION: Modified Files ---------------------------- M jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java i18n'd pending i18n comments removed unused var M jsf-ri/src/com/sun/faces/application/ApplicationImpl.java follow sun style guidlines M jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java removed unneeded assert M jsf-ri/src/com/sun/faces/util/Util.java added message constants removed unnedded assert M jsf-ri/src/javax/faces/Messages.properties M jsf-ri/src/javax/faces/Messages_de.properties M jsf-ri/src/javax/faces/Messages_es.properties M jsf-ri/src/javax/faces/Messages_fr.properties new messages M jsf-ri/test/com/sun/faces/util/TestUtil_messages.java updated unit test to reflect new additions SECTION: Diffs ---------------------------- Index: jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java,v retrieving revision 1.6 diff -u -r1.6 ApplicationAssociate.java — jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java 23 Nov 2004 19:26:52 -0000 1.6 +++ jsf-ri/src/com/sun/faces/application/ApplicationAssociate.java 30 Nov 2004 19:08:07 -0000 @@ -80,21 +80,25 @@ private boolean responseRendered = false; private static final String ASSOCIATE_KEY = RIConstants.FACES_PREFIX + "ApplicationAssociate"; + "ApplicationAssociate"; public ApplicationAssociate() { ExternalContext externalContext = null; if (null == (externalContext = ConfigureListener.getExternalContextDuringInitialize())) { - // PENDING I18N - throw new IllegalStateException("ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized()"); - } // PENDING I18N if (null != externalContext.getApplicationMap().get(ASSOCIATE_KEY)) { - throw new IllegalStateException("ApplicationAssociate already exists for this webapp"); - } externalContext.getApplicationMap().put(ASSOCIATE_KEY, this); + public ApplicationAssociate() Unknown macro: {+ + ExternalContext externalContext;+ if (null == (externalContext =+ ConfigureListener.getExternalContextDuringInitialize())) { + throw new IllegalStateException( + Util.getExceptionMessageString( + Util.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID)); + }++ if (null != externalContext.getApplicationMap().get(ASSOCIATE_KEY)) { + throw new IllegalStateException( + Util.getExceptionMessageString( + Util.APPLICATION_ASSOCIATE_EXISTS_ID)); + }+ externalContext.getApplicationMap().put(ASSOCIATE_KEY, this); managedBeanFactoriesMap = new HashMap(); caseListMap = new HashMap(); wildcardMatchList = new TreeSet(new SortIt());@@ -239,14 +243,13 @@ return null; } Object bean = null; + Object bean; try Unknown macro: { bean = managedBean.newInstance(context); if (log.isDebugEnabled()) { log.debug("Created bean " + managedBeanName + " successfully "); } } catch (Exception ex) { Object[] params = {ex.getMessage()} ; if (log.isErrorEnabled()) { log.error("Managedbean " + managedBeanName + " could not be created " + ex.getMessage(), ex); Index: jsf-ri/src/com/sun/faces/application/ApplicationImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationImpl.java,v retrieving revision 1.55 diff -u -r1.55 ApplicationImpl.java --- jsf-ri/src/com/sun/faces/application/ApplicationImpl.java 23 Nov 2004 19:26:53 -0000 1.55 +++ jsf-ri/src/com/sun/faces/application/ApplicationImpl.java 30 Nov 2004 19:08:09 -0000 @@ -251,7 +251,7 @@ } public MethodBinding createMethodBinding(String ref, Class params[]) { + public MethodBinding createMethodBinding(String ref, Class[] params) { return this.methodBindingFactory.createMethodBinding(ref, params); Index: jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java,v retrieving revision 1.12 diff -u -r1.12 CoreValidator.java — jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java 12 Oct 2004 14:39:54 -0000 1.12 +++ jsf-ri/src/com/sun/faces/taglib/jsf_core/CoreValidator.java 30 Nov 2004 19:08:15 -0000 @@ -11,7 +11,6 @@ import com.sun.faces.taglib.FacesValidator; import com.sun.faces.taglib.ValidatorInfo; -import com.sun.faces.util.Util; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; @@ -86,8 +85,7 @@ @param uri Tag library uri */ protected String getFailureMessage(String prefix, String uri) { // we should only get called if this Validator failed assert (failed); + // we should only get called if this Validator failed StringBuffer result = new StringBuffer(); if (idTagParser.hasFailed()) { @@ -112,7 +110,7 @@ @param ns Element name space. @param ln Element local name. @param qn Element QName. * @param a Element's Attribute list. + * @param attrs Element's Attribute list. */ public void startElement(String ns, String ln, @@ -136,9 +134,9 @@ <p>Parse the ending element. If it is a specific JSTL tag make sure that the nested count is decreased.</p> * + * @param ns Element name space. @param ln Element local name. @param qn Element QName. * @param a Element's Attribute list. */ public void endElement(String ns, String ln, String qn) { validatorInfo.setQName(qn); Index: jsf-ri/src/com/sun/faces/util/Util.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v retrieving revision 1.147 diff -u -r1.147 Util.java jsf-ri/src/com/sun/faces/util/Util.java 23 Nov 2004 19:26:54 -0000 1.147 +++ jsf-ri/src/com/sun/faces/util/Util.java 30 Nov 2004 19:08:19 -0000 @@ -40,6 +40,7 @@ import javax.faces.render.RenderKitFactory; import javax.faces.render.ResponseStateManager; import javax.servlet.ServletContext; +import javax.servlet.jsp.jstl.fmt.LocalizationContext; import java.io.IOException; import java.lang.reflect.Constructor; @@ -292,6 +293,12 @@ public static final String MANAGED_BEAN_TYPE_CONVERSION_ERROR_ID = "com.sun.faces.MANAGED_BEAN_TYPE_CONVERSION_ERROR"; + + public static final String APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID = + "com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK"; + + public static final String APPLICATION_ASSOCIATE_EXISTS_ID = + "com.sun.faces.APPLICATION_ASSOCIATE_EXISTS"; // README - make sure to add the message identifier constant @@ -672,7 +679,8 @@ getLocaleFromContextOrComponent(FacesContext context, UIComponent component) { Locale result = null; String bundleName = null, bundleAttr = "bundle"; + String bundleName = null; + String bundleAttr = "bundle"; Util.parameterNonNull(context); Util.parameterNonNull(component); @@ -681,12 +689,10 @@ if (null != (bundleName = (String) component.getAttributes().get(bundleAttr))) { // verify there is a Locale for this localizationContext javax.servlet.jsp.jstl.fmt.LocalizationContext locCtx = null; if (null != (locCtx = (javax.servlet.jsp.jstl.fmt.LocalizationContext) (Util.getValueBinding(bundleName)).getValue(context))) Unknown macro: {+ LocalizationContext locCtx = (LocalizationContext)+ Util.getValueBinding(bundleName).getValue(context);+ if (locCtx != null) { result = locCtx.getLocale(); - assert (null != result); } } if (null == result) { @@ -715,10 +721,9 @@ if (null == attrs) { return false; } int i = 0; Object attrVal; String empty = ""; for (i = 0; i < passthruAttributes.length; i++) { + for (int i = 0; i < passthruAttributes.length; i++) Unknown macro: { if (null != (attrVal = attrs.get(passthruAttributes[i])) && !empty.equals(attrVal)) { @@ -727,7 +732,7 @@ } } if (!result) { for (i = 0; i < booleanPassthruAttributes.length; i++) { + for (int i = 0; i < booleanPassthruAttributes.length; i++) { if (null != (attrVal = attrs.get(booleanPassthruAttributes [i] )) && @@ -761,15 +766,14 @@ assert (null != writer); assert (null != component); int i = 0, len = booleanPassthruAttributes.length, j, jLen = (null != excludes ? excludes.length : 0); Object value = null; + Object value; boolean result; boolean skip = false; for (i = 0; i < len; i++) { + boolean skip; + + for (int i = 0, len = booleanPassthruAttributes.length; i < len; i++) { skip = false; if (null != excludes) { for (j = 0; j < jLen; j++) { + for (int j = 0, jLen = excludes.length; j < jLen; j++) { if (null != excludes [j] && excludes [j] .equals(booleanPassthruAttributes [i] )) { skip = true; @@ -827,14 +831,12 @@ assert (null != writer); assert (null != component); int i = 0, len = passthruAttributes.length, j, jLen = (null != excludes ? excludes.length : 0); Object value = null; boolean skip = false; for (i = 0; i < len; i++) { + Object value; + boolean skip; + for (int i = 0, len = passthruAttributes.length; i < len; i++) { skip = false; if (null != excludes) { for (j = 0; j < jLen; j++) { + for (int j = 0, jLen = excludes.length; j < jLen; j++) { if (null != excludes [j] && excludes [j] .equals(passthruAttributes [i] )) { skip = true; @@ -1069,21 +1071,19 @@ public static ResponseStateManager getResponseStateManager(FacesContext context, String renderKitId) throws FacesException { - RenderKit renderKit = null; - RenderKitFactory renderKitFactory = null; - ResponseStateManager result = null; - renderKitFactory = (RenderKitFactory) + assert (null != renderKitId); + assert (null != context); + + RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); assert (null != renderKitFactory); - assert (null != renderKitId); - - renderKit = renderKitFactory.getRenderKit(context, renderKitId); + RenderKit renderKit = renderKitFactory.getRenderKit(context, renderKitId); assert (null != renderKit); - result = renderKit.getResponseStateManager(); - return result; + return renderKit.getResponseStateManager(); + } @@ -1263,7 +1263,6 @@ public static String stripBracketsIfNecessary(String expression) throws ReferenceSyntaxException { assert (null != expression); int len = 0; // look for invalid expressions if ('#' == expression.charAt(0)) { if ('{' != expression.charAt(1)) Unknown macro: {@@ -1271,6 +1270,8 @@ Util.INVALID_EXPRESSION_ID, new Object[]{expression})); } + + int len; if ('}' != expression.charAt((len = expression.length()) - 1)) { throw new ReferenceSyntaxException(Util.getExceptionMessageString( Util.INVALID_EXPRESSION_ID, @@ -1411,7 +1412,7 @@ } List result = new ArrayList(); int i, j, len = expressionString.length(), cur = 0; while (cur < len && + while (cur < len && -1 != (i = expressionString.indexOf("#{", cur))) { if (-1 == (j = expressionString.indexOf("} ", i + 2))) Unknown macro: { throw newReferenceSyntaxException(Util.getExceptionMessageString(Util.INVALID_EXPRESSION_ID,new Object[]{expressionString}));@@ -1463,7 +1464,7 @@ return ""; } StackTraceElement stacks[] = e.getStackTrace(); + StackTraceElement[] stacks = e.getStackTrace(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < stacks.length; i++) { sb.append(stacks [i] .toString() + "\n"); Index: jsf-ri/src/javax/faces/Messages.properties =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages.properties,v retrieving revision 1.20 diff -u -r1.20 Messages.properties jsf-ri/src/javax/faces/Messages.properties 23 Nov 2004 19:26:54 -0000 1.20 +++ jsf-ri/src/javax/faces/Messages.properties 30 Nov 2004 19:08:20 -0000 @@ -70,6 +70,8 @@ IMPLEMENTATION DEFINED MESSAGES ============================================================================== +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized(). +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists for this webapp. com.sun.faces.ASSERTION_FAILED=Assertion Failed com.sun.faces.ATTRIBUTE_NOT_SUPORTED=Attribute '' {0}'' not supported for component type ''{1}''. com.sun.faces.CANT_CONVERT_VALUE=Can''t convert property: ''{0} '' to value type: '' {1}''. Index: jsf-ri/src/javax/faces/Messages_de.properties =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_de.properties,v retrieving revision 1.19 diff -u -r1.19 Messages_de.properties — jsf-ri/src/javax/faces/Messages_de.properties 23 Nov 2004 19:26:54 -0000 1.19 +++ jsf-ri/src/javax/faces/Messages_de.properties 30 Nov 2004 19:08:20 -0000 @@ -121,6 +121,8 @@ com.sun.faces.TYPECONVERSION_ERROR_detail=Konvertierungs-Fehler: Wert ''{0}'' f\u00fcr Modell ''{1} '' : Ausnahme: {2}. com.sun.faces.MODELUPDATE_ERROR_detail=ertes ''{0}'' f\u00fcr Modell ''{1}''.nahme: {2} . com.sun.faces.INVALID_EXPRESSION=Invalid expression: '' {0}''. +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized(). +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists for this webapp. com.sun.faces.NULL_FORVALUE=Bestandteil "{0} " nicht gefunden\ com.sun.faces.EMPTY_PARAMETER=Parameter ist empty Index: jsf-ri/src/javax/faces/Messages_es.properties =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_es.properties,v retrieving revision 1.19 diff -u -r1.19 Messages_es.properties — jsf-ri/src/javax/faces/Messages_es.properties 23 Nov 2004 19:26:54 -0000 1.19 +++ jsf-ri/src/javax/faces/Messages_es.properties 30 Nov 2004 19:08:21 -0000 @@ -122,6 +122,8 @@ com.sun.faces.TYPECONVERSION_ERROR_detail=Error de conversion en el valor puesto '' {0}'' del modelo ''{1}'': excepci\u00f3n de: {2} com.sun.faces.MODELUPDATE_ERROR_detail=Error de poner al d\u00edda valor ''{0} '' para modelo '' {1}'' : excepci\u00f3n de: {2}. com.sun.faces.INVALID_EXPRESSION=Invalid expression: ''{0}''. +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized(). +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists for this webapp. com.sun.faces.NULL_FORVALUE=Componente "{0}" no encontrado com.sun.faces.EMPTY_PARAMETER=Parameter no encondrado Index: jsf-ri/src/javax/faces/Messages_fr.properties =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/javax/faces/Messages_fr.properties,v retrieving revision 1.18 diff -u -r1.18 Messages_fr.properties — jsf-ri/src/javax/faces/Messages_fr.properties 23 Nov 2004 19:26:55 -0000 1.18 +++ jsf-ri/src/javax/faces/Messages_fr.properties 30 Nov 2004 19:08:22 -0000 @@ -122,6 +122,8 @@ com.sun.faces.TYPECONVERSION_ERROR_detail=Erreur de conversion quand la valeur ''{0}'' est commise pour le mod\u00e9le ''{1} '' : Exception: {2}. com.sun.faces.MODELUPDATE_ERROR_detail=Erreur lors de la mise \u00b4 jour de la valeur ''{0}'' pour le mod\u00e9le ''{1}'' : Exception: {2} . com.sun.faces.INVALID_EXPRESSION=Invalid expression: '' {0}''. +com.sun.faces.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK=ApplicationAssociate ctor not called in same callstack as ConfigureListener.contextInitialized(). +com.sun.faces.APPLICATION_ASSOCIATE_EXISTS=ApplicationAssociate already exists for this webapp. com.sun.faces.NULL_FORVALUE=Composant "{0} " non trouv\u00E9 com.sun.faces.EMPTY_PARAMETER=Parameter non trouv\u00E9 Index: jsf-ri/test/com/sun/faces/util/TestUtil_messages.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/util/TestUtil_messages.java,v retrieving revision 1.36 diff -u -r1.36 TestUtil_messages.java — jsf-ri/test/com/sun/faces/util/TestUtil_messages.java 23 Nov 2004 19:26:55 -0000 1.36 +++ jsf-ri/test/com/sun/faces/util/TestUtil_messages.java 30 Nov 2004 19:08:26 -0000 @@ -116,6 +116,8 @@ {Util.MANAGED_BEAN_EXISTING_VALUE_NOT_LIST_ID, "2"} , {Util.MANAGED_BEAN_CANNOT_SET_MAP_PROPERTY_ID, "2"} , {Util.MANAGED_BEAN_TYPE_CONVERSION_ERROR_ID, "4"} , + {Util.APPLICATION_ASSOCIATE_CTOR_WRONG_CALLSTACK_ID, "0"} , + {Util.APPLICATION_ASSOCIATE_EXISTS_ID, "0"} , }; private String[][] toolsMessageInfo = {
        Hide
        Ed Burns added a comment -

        Thanks for doing this. r=edburns

        Show
        Ed Burns added a comment - Thanks for doing this. r=edburns
        Hide
        Ryan Lubke added a comment -

        This is really an umbrella issue for all exception reporting issues.
        Moving to P4 as this issue will never be totally resolved.

        Show
        Ryan Lubke added a comment - This is really an umbrella issue for all exception reporting issues. Moving to P4 as this issue will never be totally resolved.
        Hide
        Ryan Lubke added a comment -

        Closing this out. The bulk of the issues pointed out here are resolved. Of
        course this is an on going process and will continue to improve our error
        handling as we go.

        Show
        Ryan Lubke added a comment - Closing this out. The bulk of the issues pointed out here are resolved. Of course this is an on going process and will continue to improve our error handling as we go.
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            Ryan Lubke
            Reporter:
            jayashri
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: