0

I have been trying to properly implement a Java method using Canonicalizer. I pulled down the xmlsec-2.3.0.jar file and placed it in my build path. I have no initial errors showing up in esclipse until I compile and the error in my opinion makes no sense. I would greatly appreciate a second pair of eyes to see if I made a dumb mistake. The examples I have seen before only has one parm for canonicalize(byte[]), but this version of xmlsec has 3 parms. Your insight is appreciated.

        
        byte[] b = xmldata.getBytes();
        OutputStream writer = null;

        Init.init(); 
        Canonicalizer canon = null;
        try {
            canon = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
        } catch (InvalidCanonicalizerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        try {
            canon.canonicalize(b, writer, false);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

Error

IntegrationServer\instances\default\packages\FibTest\code\source\work.java:56: error: method canonicalize in class Canonicalizer cannot be applied to given types;

            canon.canonicalize(b, writer, false);

                 ^

  required: byte[]

  found: byte[],OutputStream,boolean

  reason: actual and formal argument lists differ in length
ChrisF
  • 1
  • You don't happen to have your own class named `Canonicalizer` do you? The error mentions the Canonicalizer class, not the `org.apache.xml.security.c14n.Canonicalizer` class. – Hovercraft Full Of Eels Feb 07 '22 at 21:19
  • So, then was my guess correct? – Hovercraft Full Of Eels Feb 07 '22 at 22:17
  • Still have the same issue after renaming class. Just weird as usually this happens when the number of parms is incorrect. – ChrisF Feb 07 '22 at 22:30
  • Did you do a clean build after renaming the class? There could be an old class file still in the build output directory. – Tim Moore Feb 08 '22 at 01:08
  • Yes it had a clean rebuild done, but after reviewing the class name was not an issue. I am writing this within the Software AG Designer for creating Java Services. The only thing I can think of is there is a lib conflict somehow causing the canonicalize() to do type checking on a 3 parm method but the library is 1 parm. Just a guess... My other backup is to write a separate jar file and incorporate it into the mix. – ChrisF Feb 08 '22 at 16:04
  • I have decided instead of messing with the product that embeds my code to just create a simple jar file that does what I need too. – ChrisF Feb 08 '22 at 18:58

0 Answers0