Spring Boot 1.3.1.and spring 4.2.4.java.lang.RuntimePermission accessClassInPackage.sun.reflect.annotation

时间:2015-12-23 15:51:59

标签: spring spring-mvc spring-boot tomcat8

我已将spring boot升级到1.3.1.RELEASE和spring framework 4.2.4.RELEASE,我遇到了问题。我没有获得tomcat catalina政策中sun.reflect.annotation的安全许可。

任何人都可以告诉为什么spring框架尝试扫描系统jar文件/类进行Web servlet注释?春季启动有没有办法不扫描系统文件/类?

22-Dec-2015 14:15:41.523 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[/hccore]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    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:699)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1798)
    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.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect.annotation")
    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.SecurityManager.checkPackageAccess(SecurityManager.java:1564)
    at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:188)
    at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:164)
    at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:827)
    at org.springframework.core.annotation.AnnotationUtils.synthesizeAnnotation(AnnotationUtils.java:1364)
    at org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:685)
    at org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:660)
    at org.springframework.core.annotation.OrderUtils.getOrder(OrderUtils.java:67)
    at org.springframework.core.annotation.OrderUtils.getOrder(OrderUtils.java:56)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:84)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:127)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:116)
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:87)
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:73)
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
    at java.util.TimSort.sort(TimSort.java:220)
    at java.util.Arrays.sort(Arrays.java:1438)
    at java.util.List.sort(List.java:478)
    at java.util.Collections.sort(Collections.java:175)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(AnnotationAwareOrderComparator.java:116)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 14 more

1 个答案:

答案 0 :(得分:0)

这可能与您的tomcat策略文件有关。您可以找到类似问题的说明和解决方案here。尝试在tomcat策略文件中检查是否有类似的内容:

permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect.annotation";
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect.annotation.*";    
permission java.lang.RuntimePermission "accessDeclaredMembers";