You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Jack Lauman <jl...@nwcascades.com> on 2004/12/30 01:10:42 UTC

Custom Taglib /JSTL 1.1.2/JBoss4.0.1 Problem - Unparseable date

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

It seems to affect any call to java.util.Date in a jsp page.  The exception is coming from a custom tag library that I use for scheduling when date/time sensitive persistant content should be displayed.  This code works fine in v3.0.7, 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

<--- ERROR --->
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)
<--- END ERROR --->


<--- 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 --->




---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Custom Taglib /JSTL 1.1.2/JBoss4.0.1 Problem - Unparseable date

Posted by Jack Lauman <jl...@nwcascades.com>.
  This code worked just fine under JSTL 1.0.x and JBoss3.0.x/3.2.x. 
When I moved it to and about a dozen other tags to JSTL 1.1x I just 
chaned the DD to allow RT.  The error seem to be from:

org.jboss.util.propertyeditor.DateEditor.getValue(DateEditor.java:42)

For some reason the JBoss DateEditor is overriding java.util.Date and 
java.text.SimpleDateFormat.

The properties-service.xml is supposed to be able to set a default 
DateParser but none of the combinations I've tried ahas worked.  Is 
there a specific DateParser in the JSTL package that you know of?  I 
haven't been able to find one.

Apparently something like this is supposed to be used.  Anyone have any 
ideas on what to do here?

Thanks,

Jack

|   <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>


::SammyRulez:: wrote:
> the problem is not with JSTL but with your
> ExpressionEvaluatorManager.evaluate method.
> 
> It seems to me that you have a rawly refatored method that cause the
> exception... verify the values of the parameters in the metod evaluate
> before use them
> 
> 
> On Wed, 29 Dec 2004 16:10:42 -0800, Jack Lauman <jl...@nwcascades.com> wrote:
> 
>>This is show stopper for us.  Does anyone know how to fix this problem?  It apparently only affects JBoss v4.0.x.
>>
>>It seems to affect any call to java.util.Date in a jsp page.  The exception is coming from a custom tag library that I use for scheduling when date/time sensitive persistant content should be displayed.  This code works fine in v3.0.7, 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
>>
>><--- ERROR --->
>>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)
>><--- END ERROR --->
>>
>><--- 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 --->
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Custom Taglib /JSTL 1.1.2/JBoss4.0.1 Problem - Unparseable date

Posted by "::SammyRulez::" <sa...@gmail.com>.
the problem is not with JSTL but with your
ExpressionEvaluatorManager.evaluate method.

It seems to me that you have a rawly refatored method that cause the
exception... verify the values of the parameters in the metod evaluate
before use them


On Wed, 29 Dec 2004 16:10:42 -0800, Jack Lauman <jl...@nwcascades.com> wrote:
> This is show stopper for us.  Does anyone know how to fix this problem?  It apparently only affects JBoss v4.0.x.
> 
> It seems to affect any call to java.util.Date in a jsp page.  The exception is coming from a custom tag library that I use for scheduling when date/time sensitive persistant content should be displayed.  This code works fine in v3.0.7, 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
> 
> <--- ERROR --->
> 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)
> <--- END ERROR --->
> 
> <--- 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 --->
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 


-- 
::SammyRulez::
http://sammyrulez.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org