You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Vandewalle, Francois (GE Power)" <fr...@ge.com> on 2021/11/05 08:22:45 UTC

[codec] DigestUtils / NoClassDefFoundError

Hi !

I am developing with Java 11 (OpenJDK) and have the following runtime problem when calling DBUtils.md5Hex()
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils

The purpose of my code is very classical: a history-aware save function, which only overwrites a file when the content to save differs from the content in the existing file (see below).

Surprisingly, compilation works fine.

Does apache commons codec support Java 11 ?
Am I doing something wrong ?
Might this be due to a missing dependency ?


Best regards,

François Vandewalle


    public boolean save(String target_file_name){
        try {
            // Check whether the file changed by comparing MD5 hashes
            String md5_existing_file = "";
            try (InputStream in = new FileInputStream(target_file_name)) {
                md5_existing_file = DigestUtils.md5Hex(in);
            }
            String md5_new_content;
            md5_new_content = DigestUtils.md5Hex(file_content);

            if (!md5_new_content.equals(md5_existing_file)){
                try (BufferedWriter out = new BufferedWriter(new FileWriter(target_file_name, false))) {
                    try {
                        out.write(file_content);
                    }
                    catch (IOException ioEx) {
                    }
                }
            }
        }
        catch (IOException ioEx){

        }

        return true;
    }

François Vandewalle
Systems Engineer / Development & Automation
GE Power
Power Conversion
T +49 30 7622 3818
F +49 30 7622 3737
francois.vandewalle@ge.com<ma...@ge.com>
www.gepowerconversion.com<http://www.gepowerconversion.com/>

Culemeyerstraße 1 | 12277 Berlin, Germany

GE Energy Power Conversion GmbH
Geschäftsführung: Jörg Nuttelmann, Martin Fleischer; Aufsichtsratsvorsitz: Wolfgang Dierker
Registergericht: Berlin-Charlottenburg; HRB 121288; USt-IdNr.: DE 269448104

Diese E-Mail und alle Daten, die darin übertragen werden, sind vertraulich und allein für den Adressaten
bestimmt. Falls Sie diese E-Mail irrtümlich erhalten, bitten wir um Mitteilung und darum, sie vollständig
von Ihrem Computer zu löschen.

This e-mail and any files transmitted with it are confidential and solely for the use of the individual or
entity to whom they are intended. If you have received this e-mail in error please notify the sender either
by telephone or by e-mail and delete the material from any computer.



Re: [codec] DigestUtils / NoClassDefFoundError

Posted by Gary Gregory <ga...@gmail.com>.
It looks like you do not have Commons Codec on the classpath at runtime.

Gary

On Fri, Nov 5, 2021, 07:23 Vandewalle, Francois (GE Power) <
francois.vandewalle@ge.com> wrote:

> Hi !
>
> I am developing with Java 11 (OpenJDK) and have the following runtime
> problem when calling DBUtils.md5Hex()
> Exception in thread "Thread-0" java.lang.NoClassDefFoundError:
> org/apache/commons/codec/digest/DigestUtils
>
> The purpose of my code is very classical: a history-aware save function,
> which only overwrites a file when the content to save differs from the
> content in the existing file (see below).
>
> Surprisingly, compilation works fine.
>
> Does apache commons codec support Java 11 ?
> Am I doing something wrong ?
> Might this be due to a missing dependency ?
>
>
> Best regards,
>
> François Vandewalle
>
>
>     public boolean save(String target_file_name){
>         try {
>             // Check whether the file changed by comparing MD5 hashes
>             String md5_existing_file = "";
>             try (InputStream in = new FileInputStream(target_file_name)) {
>                 md5_existing_file = DigestUtils.md5Hex(in);
>             }
>             String md5_new_content;
>             md5_new_content = DigestUtils.md5Hex(file_content);
>
>             if (!md5_new_content.equals(md5_existing_file)){
>                 try (BufferedWriter out = new BufferedWriter(new
> FileWriter(target_file_name, false))) {
>                     try {
>                         out.write(file_content);
>                     }
>                     catch (IOException ioEx) {
>                     }
>                 }
>             }
>         }
>         catch (IOException ioEx){
>
>         }
>
>         return true;
>     }
>
> François Vandewalle
> Systems Engineer / Development & Automation
> GE Power
> Power Conversion
> T +49 30 7622 3818
> F +49 30 7622 3737
> francois.vandewalle@ge.com<ma...@ge.com>
> www.gepowerconversion.com<http://www.gepowerconversion.com/>
>
> Culemeyerstraße 1 | 12277 Berlin, Germany
>
> GE Energy Power Conversion GmbH
> Geschäftsführung: Jörg Nuttelmann, Martin Fleischer; Aufsichtsratsvorsitz:
> Wolfgang Dierker
> Registergericht: Berlin-Charlottenburg; HRB 121288; USt-IdNr.: DE 269448104
>
> Diese E-Mail und alle Daten, die darin übertragen werden, sind vertraulich
> und allein für den Adressaten
> bestimmt. Falls Sie diese E-Mail irrtümlich erhalten, bitten wir um
> Mitteilung und darum, sie vollständig
> von Ihrem Computer zu löschen.
>
> This e-mail and any files transmitted with it are confidential and solely
> for the use of the individual or
> entity to whom they are intended. If you have received this e-mail in
> error please notify the sender either
> by telephone or by e-mail and delete the material from any computer.
>
>
>

Re: [codec] DigestUtils / NoClassDefFoundError

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br.INVALID>.
 Hi,
Since you mentioned it compiles fine, I guess this:

>Might this be due to a missing dependency ?
+1 you might have to confirm you have commons-codec available at runtime.
CheersBruno


    On Saturday, 6 November 2021, 12:23:28 am NZDT, Vandewalle, Francois (GE Power) <fr...@ge.com> wrote:  
 
 Hi !

I am developing with Java 11 (OpenJDK) and have the following runtime problem when calling DBUtils.md5Hex()
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils

The purpose of my code is very classical: a history-aware save function, which only overwrites a file when the content to save differs from the content in the existing file (see below).

Surprisingly, compilation works fine.

Does apache commons codec support Java 11 ?
Am I doing something wrong ?
Might this be due to a missing dependency ?


Best regards,

François Vandewalle


    public boolean save(String target_file_name){
        try {
            // Check whether the file changed by comparing MD5 hashes
            String md5_existing_file = "";
            try (InputStream in = new FileInputStream(target_file_name)) {
                md5_existing_file = DigestUtils.md5Hex(in);
            }
            String md5_new_content;
            md5_new_content = DigestUtils.md5Hex(file_content);

            if (!md5_new_content.equals(md5_existing_file)){
                try (BufferedWriter out = new BufferedWriter(new FileWriter(target_file_name, false))) {
                    try {
                        out.write(file_content);
                    }
                    catch (IOException ioEx) {
                    }
                }
            }
        }
        catch (IOException ioEx){

        }

        return true;
    }

François Vandewalle
Systems Engineer / Development & Automation
GE Power
Power Conversion
T +49 30 7622 3818
F +49 30 7622 3737
francois.vandewalle@ge.com<ma...@ge.com>
www.gepowerconversion.com<http://www.gepowerconversion.com/>

Culemeyerstraße 1 | 12277 Berlin, Germany

GE Energy Power Conversion GmbH
Geschäftsführung: Jörg Nuttelmann, Martin Fleischer; Aufsichtsratsvorsitz: Wolfgang Dierker
Registergericht: Berlin-Charlottenburg; HRB 121288; USt-IdNr.: DE 269448104

Diese E-Mail und alle Daten, die darin übertragen werden, sind vertraulich und allein für den Adressaten
bestimmt. Falls Sie diese E-Mail irrtümlich erhalten, bitten wir um Mitteilung und darum, sie vollständig
von Ihrem Computer zu löschen.

This e-mail and any files transmitted with it are confidential and solely for the use of the individual or
entity to whom they are intended. If you have received this e-mail in error please notify the sender either
by telephone or by e-mail and delete the material from any computer.