10 Replies Latest reply on Aug 17, 2006 4:26 AM by ony

    JSTL/JBoss/JSP error

    jlauman

      I got the following error when upgrading my app from JSTL 1.0.x to 1.1.x Other that changing the tld and web xml files to the selvlet 2.4/2.0 spec nothing changed. I'm running JBoss 4.0.1RC3 with Tomcat 5.0.28.

      The error is in a custom scheduling tag that uses java.util.Date, java.text.SimpleDateFormat, java.util.Calendar I'm not sure why I'm getting: org.jboss.util.propertyeditor.DateEditor.getValue(DateEditor.java:42)

      I'd appreciate any help on solving this.

      Thanks,

      Jack

      <error msg>
      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      org.apache.jasper.JasperException: Unparseable date: "Tue Dec 21 20:01:25 PST 2004"; - nested throwable: (java.text.ParseException: Unparseable date: "Tue Dec 21 20:01:25 PST 2004")
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      AccessControlFilter.doFilter(AccessControlFilter.java:166)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

      root cause

      org.jboss.util.NestedRuntimeException: Unparseable date: "Tue Dec 21 20:01:25 PST 2004"; - nested throwable: (java.text.ParseException: Unparseable date: "Tue Dec 21 20:01:25 PST 2004")
      org.jboss.util.propertyeditor.DateEditor.getValue(DateEditor.java:42)
      org.apache.taglibs.standard.lang.jstl.Coercions.coerceToObject(Coercions.java:714)
      org.apache.taglibs.standard.lang.jstl.Coercions.coerce(Coercions.java:298)
      org.apache.taglibs.standard.lang.jstl.ELEvaluator.convertStaticValueToExpectedType(ELEvaluator.java:358)
      org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:235)
      org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:201)
      org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:138)
      org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:166)
      org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:112)
      com.nwc.tags.DateSelectTag.doEndTag(Unknown Source)
      org.apache.jsp.secure.editMenu_jsp._jspx_meth_nwc_dateSelect_2(editMenu_jsp.java:1764)
      org.apache.jsp.secure.editMenu_jsp._jspService(editMenu_jsp.java:457)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      AccessControlFilter.doFilter(AccessControlFilter.java:166)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

      note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

        • 1. Re: JSTL/JBoss/JSP error
          starksm64

          Apparently the new version is using java bean property editors for the string conversion, and jboss installs its own date property editor. This is simply doing the following:

           public Object getValue()
           {
           try
           {
           DateFormat df = DateFormat.getDateInstance();
           return df.parse(getAsText());
           }
           catch (ParseException e)
           {
           throw new NestedRuntimeException(e);
           }
           }
          


          This is using the locale default format parser, which is not very flexible. You can use the properties-service.xml PropertyEditorManagerService to

           <mbean code="org.jboss.varia.property.PropertyEditorManagerService"
           name="jboss:type=Service,name=PropertyEditorManager">
          
           <!--
           | Register and editor for each of the type_name=editor_type_name listed
           | in properties file style convetion.
           -->
           <attribute name="Editors">
           java.util.Date=my.project.editors.DateEditor
           </attribute>
          
           </mbean>
          


          Presumably there is a DateEditor in the jstl release that should be used.


          • 2. Re: JSTL/JBoss/JSP error
            jlauman

            Scott:

            Thanks for your reply. The exception is coming from a custom tag library that I use for scheduling. This code works fine in v3.2.7 but not in v4.0.1. I tried several different combinations in the 'properties-service.xml' file, all of which generated mbean errors.

            I don't have a clue as to what should be used here. Is the a way to disable the default date parser?

            Any help would be appreciated.

            Thanks,

            Jack

            org.jboss.util.NestedRuntimeException: Unparseable date: "Mon Dec 27 16:49:16 PST 2004"; - nested throwable: (java.text.ParseException: Unparseable date: "Mon Dec 27 16:49:16 PST 2004")
            org.jboss.util.propertyeditor.DateEditor.getValue(DateEditor.java:42)
            org.apache.taglibs.standard.lang.jstl.Coercions.coerceToObject(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.Coercions.coerce(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.ELEvaluator.convertStaticValueToExpectedType(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Unknown Source)
            org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Unknown Source)
            org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(Unknown Source)
            com.nwc.tags.DateSelectTag.doEndTag(DateSelectTag.java:120)


            <--- CODE SNIP --->
            public int doEndTag() throws JspException {
            /*
            * Evaluate the EL expression, if any
            */
            Integer days = (Integer) ExpressionEvaluatorManager.evaluate("days", daysEL, Integer.class, this, pageContext);

            <<< THIS IS THE LINE THAT THROWS THE EXCEPTION >>>
            java.util.Date attribSelect = (java.util.Date) ExpressionEvaluatorManager.evaluate("select", selectEL, java.util.Date.class, this, pageContext);

            String name = (String) ExpressionEvaluatorManager.evaluate("name", nameEL, String.class, this, pageContext);
            String expires = (String) ExpressionEvaluatorManager.evaluate("expires", expiresEL, String.class, this, pageContext);

            Calendar now = Calendar.getInstance();
            now.set(Calendar.HOUR_OF_DAY, 0);
            now.set(Calendar.MINUTE, 0);
            now.set(Calendar.SECOND, 0);
            now.set(Calendar.MILLISECOND, 0);

            SimpleDateFormat displayFormat = new SimpleDateFormat("MMM dd (EE)");
            SimpleDateFormat valueFormat = new SimpleDateFormat("MMMddyyyy");

            HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
            try {
            JspWriter out = pageContext.getOut();
            out.write("<SELECT NAME=\"" + name + "\">");

            java.util.Date today = valueFormat.parse(valueFormat.format(now.getTime()));
            java.util.Date select = null;

            if (attribSelect == null) {
            Calendar invalid = Calendar.getInstance();
            invalid.set(Calendar.HOUR_OF_DAY, 0);
            invalid.set(Calendar.MINUTE, 0);
            invalid.set(Calendar.SECOND, 0);
            invalid.set(Calendar.MILLISECOND, 0);
            invalid.set(Calendar.DAY_OF_YEAR, invalid.get(Calendar.DAY_OF_YEAR) + days.intValue() + 1);
            select = valueFormat.parse(valueFormat.format(invalid.getTime()));
            } else {
            select = valueFormat.parse(valueFormat.format(attribSelect));
            }

            if (select.before(today)) {
            if (expires.equals("yes")) {
            out.write("<OPTION SELECTED CLASS=\"red\" VALUE=\"" + valueFormat.format(select) + "\">Expired");
            } else {
            out.write("<OPTION SELECTED VALUE=\"" + valueFormat.format(select) + "\">" + displayFormat.format(select) + "");
            }
            }
            <--- END CODE SNIP --->

            • 3. 357670
              jlauman

              This is show stopper. Does anyone know how to fix this problem? It apparently only affects v4.0.x.

              It seems to affect any call to java.util.Date in a jsp page.

              Thanks,

              Jack

              • 4. Re: JSTL/JBoss/JSP error
                starksm64

                Create a bug report on jira with the custom tag lib example.
                http://jira.jboss.com/jira/browse/JBAS

                • 5. Re: JSTL/JBoss/JSP error
                  jlauman

                  For anyone interested here's what I did to solve the JBoss problem with the PropertiesEditor error.

                  I edited org.jboss.util.propertyeditorDateEditor.java and
                  recompiled it wth the following changes and the problem went
                  away. I tried creating a date/time editor and a BeanInfo
                  class but sometimes they loaded and somtime they didn't. It
                  was very sporatic. Changing the JBoss file that was complaining
                  was easier but not a long term fix.

                  Thanks,

                  Jack Lauman

                  // Entries for DateSelectTag:
                  // 2005-01-10
                  new SimpleDateFormat("yyyy-MM-dd"),
                  // Jan 10 (Mon)
                  new SimpleDateFormat("MMM dd (EE)"),
                  //
                  // Entries for TimeSelectTag:
                  // 06:00:00
                  new SimpleDateFormat("hh:mm:ss"),
                  // 06:00am
                  new SimpleDateFormat("hh:mma"),
                  // 6:00am
                  new SimpleDateFormat("h:mma")

                  • 6. Re: JSTL/JBoss/JSP error
                    epleisman

                    Jack - great news that you got this fixed...
                    So - the only way around this right now is to recompile JBoss?
                    Did I read correctly thatmodifying the properties file is NON effective?
                    Also - any way you can saved me time and send me the new .class or .jar file I need? Would be really helpful.

                    Thanks so much.


                    `Ed Leisman

                    • 7. Re: JSTL/JBoss/JSP error
                      epleisman

                      Actually - DateEditor.java is not long.
                      can you just paste the new code in and I will compile.

                      Thanks.

                      ~Ed Leisman

                      • 8. Re: JSTL/JBoss/JSP error
                        epleisman

                        Jack - my email is:
                        epleisman@earthlink.net or
                        edward.p.leisman@sun.com

                        Thanks.

                        ~Ed

                        • 9. Re: JSTL/JBoss/JSP error
                          starksm64

                          The DateEditor has been updated to accept more date formats for the 3.2.7 and 4.0.2 releases.

                          I still need a bug report that has an illustration of the problem as none of the date based jstl examples gave me any problems.

                          http://jira.jboss.com/jira/browse/JBAS

                          • 10. Re: JSTL/JBoss/JSP error
                            ony

                            Setting this java property (partialy) solved the problem for me:
                            -Dorg.jboss.util.propertyeditor.DateEditor.format=dd.MM.yyyy