Java SecurityException: signer information does not match

后端 未结 18 2701
迷失自我
迷失自我 2020-11-22 12:56

I recompiled my classes as usual, and suddenly got the following error message. Why? How can I fix it?

java.lang.SecurityException: class \"Chinese_English_D         


        
相关标签:
18条回答
  • 2020-11-22 13:35

    This can occur with the cglib-instrumented proxies because CGLIB uses his own signer information instead of the signer information of the application target class.

    0 讨论(0)
  • 2020-11-22 13:36

    I could fix it.

    Root Cause: This is a common issue when using the Sun JAXB implementation with signed jars. Essentially the JAXB implementation is trying to avoid reflection by generating a class to directly access the properties without using reflection. Unfortunately, it generates this new class in the same package as the class being accessed which is where this error comes from.

    Resolution: Add the following system property to disable the JAXB optimizations that are not compatible with signed jars: -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true

    Ref: https://access.redhat.com/site/solutions/42149

    0 讨论(0)
  • 2020-11-22 13:37

    I was running JUNIT 5 and was also referencing Hamcrest external jar. But Hamcrest is also part of JUNIT 5 library. So, I have to change the order of external Hamecrest jar file up the JUNIT 5 library in build path.

    0 讨论(0)
  • 2020-11-22 13:38

    I had a similar exception:

    java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package
    

    The root problem was that I included the Hamcrest library twice. Once using Maven pom file. And I also added the JUnit 4 library (which also contains a Hamcrest library) to the project's build path. I simply had to remove JUnit from the build path and everything was fine.

    0 讨论(0)
  • 2020-11-22 13:42

    Based on @Mohit Phougat response, if you are running a Groovy with @Grab annotations, you could try to re-order such annotations.

    0 讨论(0)
  • 2020-11-22 13:44

    In my case, I had duplicated JAR version of BouncyCastle in my library path :S

    0 讨论(0)
提交回复
热议问题