【问题标题】:Receiving a Spring RequestMappingHandlerMapping error in Google App Engine在 Google App Engine 中收到 Spring RequestMappingHandlerMapping 错误
【发布时间】:2016-01-19 00:05:40
【问题描述】:

我已经构建了一个简单的 Spring MVC 应用程序,它可以在我的本地机器上完美运行。但是,将其上传到 Google App Engine 后,我收到了 HTTP 500 错误。

查看我收到此INFO 消息的日志:

org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions: Loading XML bean definitions from ServletContext resource [/WEB-INF/enterprise-servlet.xml]

这是正常的,因为我在本地运行应用程序时收到此 INFO 消息。然后,Spring 会将 URL 映射到方法上,例如来自我本地机器的日志消息:

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.register Mapped "{[/listStaff],methods=[GET],produces=[application/json || application/xml]}" onto public java.util.List<org.andrewvincent.model.Staff> org.andrewvincent.controller.Controller.listStaffXML()

但是,在查看来自应用引擎的日志时,我收到以下错误:

org.springframework.web.context.support.XmlWebApplicationContext refresh: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect.annotation")

我认为这就是我收到 500 错误代码的原因,因为 url 没有被映射到方法上,但是当我不在本地时,我无法弄清楚为什么我会收到这个错误。

以下是我的企业-servlet.xml:

<beans xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns="http://www.springframework.org/schema/beans"
   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.xsd">

    <mvc:annotation-driven/>

    <bean id="controllerBean" class="org.andrewvincent.controller.Controller"></bean>
    <bean id="plainControllerBean"
      class="org.andrewvincent.controller.PlainTextController"></bean>

    <mvc:resources mapping="/resources/**" location="/resources/"/>

    <mvc:default-servlet-handler/>
</beans>

如果有人可以帮助我,将不胜感激。

【问题讨论】:

  • 你用的是什么版本的 Spring?
  • @NielsMasdorp 我使用的是版本 4

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


【解决方案1】:

这是一个已知的bug

您使用的是 4.2.4 吗?如果是这样,您应该降级到 4.2.3。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-29
    • 2021-11-02
    • 2012-01-25
    • 1970-01-01
    • 1970-01-01
    • 2011-08-11
    • 2013-03-09
    • 1970-01-01
    相关资源
    最近更新 更多