-1

We are using commons-codec to encrypt passwords, using the org.apache.commons.codec.digest.Md5Crypt.md5Crypt function.

It works fine on a Windows environment, but on CentOS, an exception is thrown.

We have 3 centOS test servers: one is centOS7, one is centOS6.7, and one is centOS7 minimal. The weirdest thing is, the code works on the centOS7 server, but not on the other two. The only difference between them is the OS. Same tomcats, same jdks, same builds.

Does it need any other things under linux?

The exception message:

java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getMd5Digest()Ljava/security/MessageDigest; from class org.apache.commons.codec.digest.Md5Crypt

Anson .K
  • 57
  • 5

1 Answers1

0

have you checked the jar ? and the presence of the library ? Perhaps it was removed for some obscure security / patent / export reason ?

or, at least, something changed. It is a problem of incompatibility: see that: java.lang.IllegalAccessError: tried to access method

Or you have already (loaded) this class, because you have multiple incompatible instances . Try to find it in your packages (caller function, or called)

but why not directly use the library ?

import java.security.*;
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(_originebyte);
Community
  • 1
  • 1
  • Thanks for the answer. I checked the question you mentioned, then I checked every details of my environment again, found that the version of the three tomcats were different. The version of jdks were 1.7, but the tomcats' were 8 and 7. 8 worked fine for the code, but 7 not. So now I change tomcats from 7 to 8. But I'm still confused, what made this happen, I'll dig it deeper. – Anson .K Dec 25 '15 at 05:36
  • Hi, you were right, I found a different commons-codec was included by a third party jar file in WEB-INF/lib folder what is not managed by maven. I deleted it, and now it works fine. Thank you! – Anson .K Dec 30 '15 at 03:35