Skip to main content
Participant
April 5, 2016
Question

java.math.BigDecimal cannot be cast to java.lang.String

  • April 5, 2016
  • 3 replies
  • 5266 views

this sentence below is working fine on Coldfusion 11 and previous version, but it throws exceptions when the application is deployed on Coldfusion 2016

Could anyone give some advice on this issue?

<cfset SubjectText = Replace(#SubjectText#,"%Request.RequestID%",#Request.RequestID#,"All")>

the value of #Request.RequestID# is a number

    This topic has been closed for replies.

    3 replies

    Inspiring
    April 25, 2016

    Definitely looks like I bug. I ran into the same issue. Like the error says, CF is failing to convert a BigDecimal to a string in order to use it in the replace function. This should work for you.

    <cfset SubjectText = Replace(SubjectText,"%Request.RequestID%",javaCast('String',Request.RequestID),"All")>

    For reference, here is an example that fails. In my case, the real value for the theBigDecimal was being generated by selecting an integer column from a simple query against Oracle. As you can see below, the javacast from bigdecimal to string works, but whatever it is doing in the replace function fails. I'll see if I can find were to file the bug.

    <cfscript>

    theBigDecimal = javaCast("bigdecimal", 123456);

    theBigDecimalasString = javaCast("String", theBigDecimal);

    newString = replace('This is my text with documentID in it','documentID',theBigDecimalasString);

    writeDump('This Works: ' & newString);

    writeDump('This Fails:');

    newString = replace('This is my text with documentID in it','documentID',theBigDecimal);

    </cfscript>

    Inspiring
    April 25, 2016

    added to bug base

    Bug 4144890

    Carl Von Stetten
    Legend
    April 5, 2016

    You shouldn't need the pound signs (#) around the variable Request.RequestID, although it appears to work even with them.

    cjhxheAuthor
    Participant
    April 6, 2016

    i removed the pound , but still get the same error

    Inspiring
    April 5, 2016

    Can you give exact examples of what you are using for each variable.

    I tried this and dont get any issues with it. - See Example http://trycf.com/gist/610a1e84aee0c490f4a2208296f890ee/acf2016?theme=monokai

    cjhxheAuthor
    Participant
    April 6, 2016

    yes it works in CF 11 and previous versions but  not working in CF 12