gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 03:51:42 25 4
gpt4 key购买 nike

我正在创建具有 spring 方面的应用程序,但是在应用引擎中,当我遇到第一个请求时,初始化 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

@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?

应用引擎版本:1.9.7 Spring 框架:4.0.3

最佳答案

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

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

关于java - appengine spring aop java.security.AccessControlException : access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25589916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com