appengine spring aop java.security.AccessControlException:access denied(“java.lang.RuntimePermission”“accessClassInPackage.sun.reflect”)

时间:2022-11-14 23:17:29

I am creating application with spring aspect but in app engine when I hit first request then exception occurs while initialize spring framework.

我正在使用spring方面创建应用程序,但是当我点击第一个请求时在app引擎中,然后在初始化spring框架时发生异常。

Exception stack trace is as below:

异常堆栈跟踪如下:

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminController' defined in file [PATH\PACKAGE\AdminController.class]: 
Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: 
Unexpected AOP exception; nested exception is java.security.AccessControlException: 
access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect")

My Aspect

@Aspect
@Component
public class AuthorizationAspect {

    @Around(value="@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    public Object interceptApplicationRequest(
            ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("test");
        return proceedingJoinPoint.proceed();
    }
}

My Controller

@Controller
@RequestMapping(value="/admin")
public class AdminController {

    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public ModelAndView add(){
        ModelAndView mv = new ModelAndView("add");
        return mv;
    }
}

Configuration in XML

在XML中配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">

    <context:component-scan base-package="com.package.name" />

    <aop:aspectj-autoproxy/>

    <mvc:annotation-driven />
</beans>

Is AOP not allowed in app engine framework?

应用引擎框架中是否不允许使用AOP?

App Engine version: 1.9.7 Spring Framework: 4.0.3

App Engine版本:1.9.7 Spring Framework:4.0.3

1 个解决方案

#1


0  

Based on the exception message, it is likely that the library you are using relies on some classes that are not in the App Engine's White list: https://cloud.google.com/appengine/docs/java/jrewhitelist

根据异常消息,您使用的库很可能依赖于App Engine的白名单中没有的某些类:https://cloud.google.com/appengine/docs/java/jrewhitelist

In particular, I don't see any of sun.reflect* classes in this white list. Hence, you are getting AccessControllException.

特别是,我在这个白名单中没有看到任何sun.reflect *类。因此,您将获得AccessControllException。

#1


0  

Based on the exception message, it is likely that the library you are using relies on some classes that are not in the App Engine's White list: https://cloud.google.com/appengine/docs/java/jrewhitelist

根据异常消息,您使用的库很可能依赖于App Engine的白名单中没有的某些类:https://cloud.google.com/appengine/docs/java/jrewhitelist

In particular, I don't see any of sun.reflect* classes in this white list. Hence, you are getting AccessControllException.

特别是,我在这个白名单中没有看到任何sun.reflect *类。因此,您将获得AccessControllException。