导致的 SecurityException

时间:2025-03-23 11:01:23

: class ""'s signer information does not match signer information of other classes in the same package

 

1.1. 场景

代码中使用了 ,项目启动时报 SecurityException。

1.2. 问题分析

项目依赖的两个 jar 包中都有 ,一个是 :annotations 另一个是 :。

两个分别引入的是 JSR 305 和 JSR 250,但是 jetty 中的 jar 是带签名的,而 findbugs 中没有签名,jvm 加载检查数字签名有问题,会抛异常。

1.3. 原理分析

TODO

参考文档

  • /questions/2877262/java-securityexception-signer-information-does-not-match
  • /2013/11/
  • /questions/33447686/why-javax-annotation-of-different-organization-are-different

jetty 8 (8.1.10.v20130312) 依赖 :;mtthrift、mtconfig 则依赖 :annotations。这两个依赖中都有 包,但是前者 jar 是带签名的,后者没有签名。jvm 加载时,检查到数字签名有问题,就会抛出异常。

jetty 依赖的 实现了 JSR 250: Common Annotations for the JavaTM Platform

  • (Generated, ManagedBean , PostConstruct, PreDestroy, Resource, Resources)

  • (DeclareRoles, DenyAll, PermitAll, RolesAllowed, RunAs) 

  • (DataSourceDefinition, DataSourceDefinitions) - since version 1.1

除了 Jetty Orbit,还有以下常见的 JSR 250 实现:

  • - /artifact//jsr250-api

  • - /artifact//-api

  • Geronimo - /artifact//geronimo-annotation_1.0_spec

  • Glassfish - /artifact//

  • And loads of others - /c/javax/annotation/postconstruct

而 findbugs:annotations 则实现了 JSR 305: Annotations for Software Defect Detection

  • (CheckForNull, ... , Nonnull, Nullable, ... , WillNotClose)

  • (GuardedBy, ... , ThreadSafe)

  • (Exclusive, ... , When)

除了这个 findbugs:annotations,还有一个实现 /c/javax/annotation/nullable/jar