8

Since yesterday my textencrypter(jasypt) stopped working for no reason. Here is a code example and the error msg. Does anybody know what is going on?

Code example:

        StrongTextEncryptor crypter = new StrongTextEncryptor();
        crypter.setPassword("Password");
        crypter.encrypt("Test");

Error msg:

Exception in thread "main" org.jasypt.exceptions.EncryptionInitializationException: java.lang.ExceptionInInitializerError
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:773)
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:566)
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.encrypt(StandardPBEStringEncryptor.java:644)
    at org.jasypt.util.text.StrongTextEncryptor.encrypt(StrongTextEncryptor.java:107)
    at A.main(A.java:8)
Caused by: java.lang.ExceptionInInitializerError
    at com.ibm.icu.impl.NormalizerDataReader.<clinit>(NormalizerDataReader.java:300)
    at com.ibm.icu.impl.NormalizerImpl.<init>(NormalizerImpl.java:288)
    at com.ibm.icu.impl.NormalizerImpl.<clinit>(NormalizerImpl.java:35)
    at com.ibm.icu.text.Normalizer$Mode.normalize(Normalizer.java:188)
    at com.ibm.icu.text.Normalizer.normalize(Normalizer.java:1177)
    at com.ibm.icu.text.Normalizer.normalize(Normalizer.java:1146)
    at org.jasypt.normalization.Normalizer.normalizeWithIcu4j(Normalizer.java:205)
    at org.jasypt.normalization.Normalizer.normalizeToNfc(Normalizer.java:129)
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:718)
    ... 4 more
Caused by: java.lang.IllegalArgumentException: Invalid version number: Version number may be negative or greater than 255
    at com.ibm.icu.util.VersionInfo.getInstance(VersionInfo.java:188)
    at com.ibm.icu.impl.ICUDebug.getInstanceLenient(ICUDebug.java:65)
    at com.ibm.icu.impl.ICUDebug.<clinit>(ICUDebug.java:69)
    ... 13 more
Jixo
  • 105
  • 1
  • 5

3 Answers3

18

This is not a direct answer, but I'm putting it here in case someone runs upon the issue.

Using Java 1.8.0_275, I was getting a

java.lang.ExceptionInInitializerError

when running the encrypt.sh.

Jasypt version 1.9.3 is using an old version of icu4j-3.4.4.jar. I replaced the icu4j-3.4.4.jar with icu4j-68_2.jar then I was able to run:

./encrypt.sh input=password password=aSecret algorithm=PBEWithMD5AndDES

without error.

For more information, see https://github.com/jasypt/jasypt/issues/58. Even though this is a little different from how you're running jasypt, I'd recommend updating the icu4j.jar and try again.

Brad Rippe
  • 3,405
  • 1
  • 18
  • 20
1

Problem seems to be related (at least in my case) to icu4j. Found this commit on jasypt Github https://github.com/jasypt/jasypt/commit/d384f9a755af2938bc142f7575365bee42ba5f22 Updated dependency and application started running.

Leif H
  • 11
  • 1
  • I didn't see a release with that commit in it. Just build it locally? – unigeek Aug 25 '20 at 02:52
  • 3
    In practise I just replaced the old icu4j jar file in my apps lib directory with this one https://repo1.maven.org/maven2/com/ibm/icu/icu4j/67.1/icu4j-67.1.jar – Leif H Aug 26 '20 at 06:55
  • Did the following with maven pom: org.jasypt jasypt 1.9.2 com.ibm.icu icu4j com.ibm.icu icu4j 67.1 – unigeek Sep 02 '20 at 12:53
0

A jasypt issue 44 comment on github says just to remove the old icu4j-3.4.4.jar. IOW, don't bother tracking down a replacement. Worked OK for me. :-) Thanks Brad Rippe for providing the clue!

DSOANS commented on Aug 24, 2020

It appears the fix is to REMOVE the com.ibm.icu4j jar (icu4j-3.4.4.jar) file from the distribution - at least that seems to have worked for us.

https://github.com/jasypt/jasypt/issues/44

Cris B
  • 23
  • 4