尝试在JBoss中部署Spring Web应用程序时,在日志中收到以下错误和stacktrace:
Looking for @ControllerAdvice: WebApplicationContext for namespace 'MyApp-ws-war-servlet': startup date [Tue Aug 14 19:35:21 BST 2018]; root of context hierarchy
14 Aug 2018 19:35:22,601 ERROR (ServerService Thread Pool -- 128) Context initialization failed: java.security.AccessControlException: access denied ("org.jboss.as.naming.JndiPermission" "java:module/env/spring.liveBeansView.mbeanDomain" "lookup")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) [rt.jar:1.8.0_131]
at java.security.AccessController.checkPermission(AccessController.java:884) [rt.jar:1.8.0_131]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) [rt.jar:1.8.0_131]
at org.jboss.as.naming.NamingContext.check(NamingContext.java:559)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:187)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:245)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_131]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_131]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiLocatorDelegate.lookup(JndiLocatorDelegate.java:63) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:77) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiLocatorDelegate.lookup(JndiLocatorDelegate.java:58) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.jndi.JndiPropertySource.getProperty(JndiPropertySource.java:91) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:80) [spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:61) [spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:530) [spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.LiveBeansView.registerApplicationContext(LiveBeansView.java:65) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) [spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:540) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_131]
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:264) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:262) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_131]
at javax.security.auth.Subject.doAsPrivileged(Subject.java:549) [rt.jar:1.8.0_131]
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:296) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:156) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:109) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1200) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1112) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3593) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802) [jbossweb-7.5.21.Final-redhat-2.jar:7.5.21.Final-redhat-2]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.14.Final-redhat-2.jar:7.5.14.Final-redhat-2]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.14.Final-redhat-2.jar:7.5.14.Final-redhat-2]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.14.Final-redhat-2.jar:7.5.14.Final-redhat-2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
此应用程序已在我的本地开发机上正确部署,但在测试服务器环境中失败并显示以上消息。这可能与下面的以下ExceptionHandler类有关:
@ControllerAdvice
public class ExceptionHandlerAdvice {
@ExceptionHandler(MyAppEJBValidationException.class)
public ResponseEntity<?> handleMyAppEJBValidationException(MyAppEJBValidationException nev) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(nev.getMessage());
}
}