2015-09-14 69 views
1

如果我從春天4.1.7.RELEASE移動到4.2.1.RELEASE谷歌應用程序引擎提出了java.lang.NoClassDefFoundError春天4.2.1是一個限制類

當春季安全拋出AccessDeniedException(AffirmativeBased.java:83)

我知道我無權訪問請求的資源。我期待春天之後,但由於春季4.2它不工作:(

[INFO] java.lang.NoClassDefFoundError: java.util.ResourceBundle$Control is a restricted class. Please see the Google App Engine developer's guide for more details. 
[INFO] at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52) 
[INFO] at org.springframework.context.support.ResourceBundleMessageSource$MessageSourceControl.<init>(ResourceBundleMessageSource.java:417) 
[INFO] at org.springframework.context.support.ResourceBundleMessageSource$MessageSourceControl.<init>(ResourceBundleMessageSource.java:417) 
[INFO] at org.springframework.context.support.ResourceBundleMessageSource.doGetBundle(ResourceBundleMessageSource.java:314) 
[INFO] at org.springframework.context.support.ResourceBundleMessageSource.getResourceBundle(ResourceBundleMessageSource.java:284) 
[INFO] at org.springframework.context.support.ResourceBundleMessageSource.resolveCodeWithoutArguments(ResourceBundleMessageSource.java:234) 
[INFO] at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:218) 
[INFO] at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:136) 
[INFO] at org.springframework.context.support.MessageSourceAccessor.getMessage(MessageSourceAccessor.java:83) 
[INFO] at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:83) 
[INFO] at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:232) 
[INFO] at org.springframework.security.access.intercept.aspectj.AspectJMethodSecurityInterceptor.invoke(AspectJMethodSecurityInterceptor.java:43) 
[INFO] at org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect.ajc$around$org_springframework_security_access_intercept_aspectj_aspect_AnnotationSecurityAspect$1$c4d57a2b(AnnotationSecurityAspect.aj:63) 
[INFO] at xx.xxx.controllers.PortalController.home(PortalController.java:51) 
+0

您是否閱讀過變更註釋?任何破壞你的應用的東西? – m02ph3u5

回答

3

要在GAE運行春季4.2.1和使用全局方法安全,我不得不消息源設置的StaticMessageSource而不是ResourceBundleMessageSource會顯示登錄頁面這造成的問題。不幸的是,宣佈爲messageSource豆不僅是一兩件事,有許多工作要做。這是這裏使用的是由法GlobalMethodSecurityConfiguration.accessDecisionManager(創建)和

@Bean(name = "messageSource") 
    public MessageSource messageSource() { 
    StaticMessageSource messageSource = new StaticMessageSource(); 
    return messageSource; 
    } 

AffirmativeBased訪問決策管理不是春bean所以setMessageSource()方法沒有執行,所以它不是MessageSourceAware。該解決方案是手動設置此爲messageSource:

@Configuration 
@EnableGlobalMethodSecurity 
public class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration { 

    @Inject 
    private MessageSource messageSource; 

    @Override 
    protected AccessDecisionManager accessDecisionManager() { 
    AffirmativeBased manager = (AffirmativeBased)super.accessDecisionManager(); 
    manager.setMessageSource(messageSource); 
    return manager; 
    } 
} 
0

有點反覆試驗後,下面似乎爲我工作確定:

  1. 將郵件文件到WEB-INF。
  2. 更新Spring配置使用ReloadableResourceBundleMessageSource而不是ResourceBundleMessageSource,例如,在XML

    <豆ID = "爲messageSource " 類= " org.springframework.context.support.ReloadableResourceBundleMessageSource " > <屬性名= "基名" 值= "/WEB-INF/I18N /消息"/> < /豆>