代码之家  ›  专栏  ›  技术社区  ›  Menelaos

Spring BooT和Tomcat策略——拒绝访问(“java. Lang.Exim.Reavig允许”)“SuffeldAccess检查”

  •  0
  • Menelaos  · 技术社区  · 6 年前

    我正在尝试将Spring引导应用程序部署到Tomcat。 不幸的是,我们无法控制雄猫。

    我收到以下错误:

    Caused by: java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
    

    我看到Spring引导框架确实尝试使用反射并检查内部的各种类和工厂: https://github.com/spring-projects/spring-boot/blob/4a883d00a5a6842e53086207c259fd053be1ce43/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java#L440

    29-Nov-2018 18:46:34.152 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    29-Nov-2018 18:46:34.596 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mne-api]]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
            at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:131)
            at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:153)
            at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:143)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
            at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer
            at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:448)
            at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:427)
            at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
            at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:266)
            at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:247)
            at org.springframework.boot.builder.SpringApplicationBuilder.createSpringApplication(SpringApplicationBuilder.java:102)
            at org.springframework.boot.builder.SpringApplicationBuilder.<init>(SpringApplicationBuilder.java:90)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createSpringApplicationBuilder(SpringBootServletInitializer.java:146)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:106)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
            at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
            ... 14 more
    Caused by: java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
            at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
            at java.security.AccessController.checkPermission(AccessController.java:884)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
            at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
            at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:488)
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:168)
            at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:444)
    

    问题

    1. 这是我做过的事情,还是服务器的配置明显有问题?

    2. 这个错误可能是其他原因吗?这不是真正的问题吗?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Menelaos    6 年前

    托管和管理我们Tomcat的部门使用额外的参数来运行它,该参数使用安全管理器。

    他们移除了它们,问题就消失了。