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

时间:2014-08-31 07:40:11

标签: java spring spring-mvc google-app-engine

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

异常堆栈跟踪如下:

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")

我的观点

@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();
    }
}

我的控制器

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

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

以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>

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

App Engine版本:1.9.7 Spring Framework:4.0.3

1 个答案:

答案 0 :(得分:0)

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

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