Strange freemarker exception

Have no ideas, please help

SEVERE:

Methodparse on gran.tools.formatter.DateFormatter
The problematic instruction:
----------
==> ${addval.df.parse(msg.getTime())} [on line 441, column 5 in 1]
 in user-directive message [on line 807, column 1 in 1]
 in user-directive page [on line 510, column 1 in 1]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Methodparse on gran.tools.formatter.DateFormatter
      at freemarker.ext.beans.OverloadedMethodModel.exec(OverloadedMethodModel.java:112)
      at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
      at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
      at freemarker.core.Expression.getStringValue(Expression.java:93)
      at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.MixedContent.accept(MixedContent.java:92)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.Environment.visit(Environment.java:208)
maximkrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
Seems as msg.getTime() returns an invalid format. A format addval.df.parse() can't parse
0
TimYatesCommented:
what does getTime() return?

is it a java.util.Date object?
0
maximkrAuthor Commented:
   import java.sql.Timestamp;
...
    public Timestamp getTime() {
        return allowedByAcl ? message.getTime() : null;
    }

and

    public String parse(java.sql.Timestamp param) {
        if (param == null)
            return null;

        DateFormat df = this.getDateFormat();
        return new String(df.format(param));
    }

What can be wrong here ?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

zzynxSoftware engineerCommented:
This
   >> return new String(df.format(param));
0
TimYatesCommented:
what is "df" and how is it created?
0
zzynxSoftware engineerCommented:
In other words, post the code of getDateFormat() ;°)
0
maximkrAuthor Commented:
   public Calendar getCalendar() {
        return new GregorianCalendar(this.timezone, this.locale);
    }

    public DateFormat getDateFormat() {
        DateFormat f = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, this.getLocale());
        f.setCalendar(this.getCalendar());
        return f;
    }
0
maximkrAuthor Commented:
I forgot important stacktrace:
Underlying cause:

No signature of method parse matches (java.lang.Object)
The problematic instruction:
----------
==> ${addval.df.parse(msg.getTime())} [on line 441, column 5 in 1]
 in user-directive message [on line 807, column 1 in 1]
 in user-directive page [on line 510, column 1 in 1]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: No signature of method parse matches (java.lang.Object)
      at freemarker.ext.beans.MethodMap.getMostSpecific(MethodMap.java:127)
      at freemarker.ext.beans.OverloadedMethodModel.exec(OverloadedMethodModel.java:104)
      at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
      at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
      at freemarker.core.Expression.getStringValue(Expression.java:93)
      at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.MixedContent.accept(MixedContent.java:92)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.Environment.visit(Environment.java:208)
      at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.MixedContent.accept(MixedContent.java:92)
      at freemarker.core.Environment.visit(Environment.java:171)
      at freemarker.core.Macro$Context.runMacro(Macro.java:164)
      at freemarker.core.Environment.visit(Environment.java:470)
      at freemarker.core.UnifiedCall.accept(UnifiedCall.java:128)
0
TimYatesCommented:
You shouldn't need:

        f.setCalendar( this.getCalendar() );

But I can't see how that's a problem :-/
0
TimYatesCommented:
Ahhhh....  right...for some reason, it's looking for a method:

    public String parse( Object timestamp )

Which is a bit odd....as msg.getTime returns a Timestamp...
0
maximkrAuthor Commented:
I can only add that all this works on our test database, but fail on production.
0
TimYatesCommented:
I'm guessing:

        return allowedByAcl ? message.getTime() : null;

is returning null, and then it can't find a parse method that takes null (as null has no type, it's trying to send it to a method of type Object)

does:

        ${addval.df.parse((java.sql.Timestamp)msg.getTime())}

work?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimYatesCommented:
Can you print out the value of "allowedByAcl"?
0
girionisCommented:
>  ${addval.df.parse(msg.getTime())} [on line 441, column 5 in 1]

Show us that bit of code.

0
maximkrAuthor Commented:
Only idea:
Possible, it try to determine parameter type by value ? getTime return null sometimes...
0
TimYatesCommented:
> Possible, it try to determine parameter type by value ? getTime return null sometimes...

that's what I said isn't it?

;-)
0
zzynxSoftware engineerCommented:
That's what Tim told you, yes. Try casting like he said.
0
maximkrAuthor Commented:
Casting don't  work (even more strange exception occurs), but the following code works fine:
<#if msg.getTime()?exists>
<td>${addval.df.parse(msg.getTime())}</td>
<#else>
<td>&nbsp;</td>
</#if>

Thank you!
0
zzynxSoftware engineerCommented:
That's also a solution of course. OK!
0
zzynxSoftware engineerCommented:
Somewhat surprised I didn't get some points for my comments :/
0
maximkrAuthor Commented:
Possible I missed something in rules (give me a link, I am novice here), but I've think that points for solution, not for attention, correct ?

Anyway, thank you very much too.
0
TimYatesCommented:
Good luck with it maximkr :-)

Tim
0
zzynxSoftware engineerCommented:
>> I've think that points for solution, not for attention,
That's right. But I'm not talking about mere attention.
My first comment:
>> Seems as msg.getTime() returns an invalid format. A format addval.df.parse() can't parse
was a good pointer in the right direction I thought.
And points are also given for "assisted answers" (See the EE help pages)

>> Anyway, thank you very much too.
All right, that's OK.
0
zzynxSoftware engineerCommented:
Thanks maximkr :°)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.