可能的修复 :
1)将authConfigFactory设置为Tomcat 8.5使用的默认AuthConfigFactory实现(示例基本实现):
package com.example;import org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import javax.security.auth.message.config.AuthConfigFactory;@SpringBootApplicationpublic class DemoApplication { public static void main(String[] args) { if (AuthConfigFactory.getFactory() == null) { AuthConfigFactory.setFactory(new AuthConfigFactoryImpl()); } SpringApplication.run(DemoApplication.class, args); }}
要么
2)
AuthConfigFactory从您的类路径中删除重复的类。就我而言,同一类有两种不同的实现:
org.apache.tomcat.embed/tomcat-embed-core/8.5.4/tomcat-embed-core-8.5.4.jar!/javax/security/auth/message/config/AuthConfigFactory.classjavax/javaee-api/7.0/javaee-api-7.0.jar!/javax/security/auth/message/config/AuthConfigFactory.class
javaee-api-7.0.jar具有自己的
AuthConfigFactory实现,该实现与Tomcat
8.5不完全兼容,并导致
NullPointerException(从Tomcat的版本开始,该常量定义了默认的jaspic实现类
javaee-api)从gradle / mvn项目中删除依赖项(或任何其他包含不同AuthConfigFactory实现的依赖项)(如果您能够)
要么
3)将Tomcat降级到8.0或7.0:
http://docs.spring.io/spring-boot/docs/current-
SNAPSHOT/reference/htmlsingle/#howto-use-
tomcat-7
说明 :
此问题与从Spring Boot从1.3.x升级到1.4期间进行的Tomcat升级(从8.0.x到8.5.x)有关。问题是Tomcat
8.5引入了jaspic支持(https://tomcat.apache.org/tomcat-8.5-doc/config/jaspic.html),并提供了自己的AuthConfigFactory
实现。此实现定义了默认的jaspic auth工厂实现:
private static final String DEFAULT_JASPI_AUTHConFIGFACTORYIMPL = "org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl";
它在其他实现中未定义(例如,来自javaee-
api-7.0的实现),并且
NullPointerException由于未实例化AuthConfigFactory而导致。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)