Skip to main content
September 30, 2014
Answered

Problem using HSBCHashGenerator CFX

  • September 30, 2014
  • 1 reply
  • 374 views

Upgrading from MX7 to 10.

Got a .jar file "cpitools.jar" which I've put into /opt/coldfusion10/jre/lib

If I do a jar -tf on it, I get:

com/clearcommerce/CpiTools/security/Encrypter.class

com/clearcommerce/CpiTools/security/HashGenerator.class

com/clearcommerce/CpiTools/security/SecCrypto.class

META-INF/MANIFEST.MF

I've registered it in the CFIDE:

TagName: CFX_HSBCHashGenerator

ClassName: com.clearcommerce.CpiTools.security.HashGenerator

BUT when I try to call it...

<CFX_HSBCHashGenerator SharedSecret="#ss#" HashElement="#datainput#">

I get the error message: The CFX custom tag CFX_com.clearcommerce.CpiTools.security.HashGenerator was not found in the custom tag database. You must add custom tags to the database before using them. If you have added your tag to the database, check the spelling of the tag within your template to ensure that it matches the database entry.

-----

So when it says "you must add custom tags to the database" - it's referring to the registration of the Java CFX, right?

So I've done that. so I check the spelling of the tag - looks OK to me (and it is unchanged since the functional MX7 code).

Obviously the mapping is working to some extent - CF was clever enough to realise that when I say <CFX_HSBCHashGenerator...., I am referring to something with "com.clearcommerce.CpiTools.security.HashGenerator".

So what's my blindingly obvious in retrospect error?!

This topic has been closed for replies.
Correct answer

Just a little update:

If I put cpitools.jar into /opt/coldfusion10/cfusion/wwwroot/WEB-INF/classes

And then add /opt/coldfusion10/cfusion/wwwroot/WEB-INF/classes into the ColdFusion Class Path, the error changes to this:

A ClassCastingException occured. The CFX custom tag CFX_com.clearcommerce.CpiTools.security.HashGenerator needs to implement com.allaire.cfx.CustomTag interface. Ensure that you add this to your custom class.


If I understand this correctly, I can no longer use a generic Java class in CF10 - it HAS to be one that has some ColdFusion specific stubs added.

That sounds like a right royal PITA! I don't want to be messing around changing other people's .jar files and getting my hands dirty with Java. There MUST be a way around this, surely?!

OK - the answer is not to use CFX at all!

Just instantiate a JavaObject and call its method:

    <cfset HashGenerator = createObject("java","com.clearcommerce.CpiTools.security.HashGenerator")>

    <cfset OrderHash = HashGenerator.generateHash(v,ss)>

1 reply

Correct answer
September 30, 2014

Just a little update:

If I put cpitools.jar into /opt/coldfusion10/cfusion/wwwroot/WEB-INF/classes

And then add /opt/coldfusion10/cfusion/wwwroot/WEB-INF/classes into the ColdFusion Class Path, the error changes to this:

A ClassCastingException occured. The CFX custom tag CFX_com.clearcommerce.CpiTools.security.HashGenerator needs to implement com.allaire.cfx.CustomTag interface. Ensure that you add this to your custom class.


If I understand this correctly, I can no longer use a generic Java class in CF10 - it HAS to be one that has some ColdFusion specific stubs added.

That sounds like a right royal PITA! I don't want to be messing around changing other people's .jar files and getting my hands dirty with Java. There MUST be a way around this, surely?!

OK - the answer is not to use CFX at all!

Just instantiate a JavaObject and call its method:

    <cfset HashGenerator = createObject("java","com.clearcommerce.CpiTools.security.HashGenerator")>

    <cfset OrderHash = HashGenerator.generateHash(v,ss)>