Issue
I have built a simple Spring MVC application that works flawlessly on my local machine. Having uploaded it to the Google App Engine, however, I receive a HTTP 500 error.
Looking into the logs I recieve this INFO
message:
org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions: Loading XML bean definitions from ServletContext resource [/WEB-INF/enterprise-servlet.xml]
Which is normal, as I receive this INFO
message when running the app locally. Spring would then go onto map urls onto methods, for example a log message from my local machine:
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()
However when looking at the logs from the app engine, I receive the following error:
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")
I assume this is why I am receiving the 500 error code, as the urls are not being mapped onto the methods, but I cannot work out why I receive this error when I don't locally.
The following is my enterprise-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>
If anyone could help me out it would be much appreciated.
Solution
This is a known bug.
Are you using 4.2.4? If so you should downgrade to 4.2.3.
Answered By - Niels Masdorp
Answer Checked By - Gilberto Lyons (JavaFixing Admin)