gpt4 book ai didi

java - 并行部署异常

转载 作者:行者123 更新时间:2023-11-28 22:48:49 24 4
gpt4 key购买 nike

当我在 Tomcat 8 上部署我的 webapp 的新版本 (3.0.1) [在 tomcat 上部署了旧版本 (3.0.0)] 我得到这个异常:

未能注册 LiveBeansView MBean;嵌套异常是 javax.management.InstanceAlreadyExistsException

org.springframework.context.ApplicationContextException: Failed to register LiveBeansView MBean; nested exception is javax.management.InstanceAlreadyExistsException: security-base,security-api:application=/MyWebApplication at org.springframework.context.support.LiveBeansView.registerApplicationContext(LiveBeansView.java:72) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:776) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1617) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1483) at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:731) at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:424) at javax.servlet.http.HttpServlet.service(HttpServlet.java:651) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:589) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: javax.management.InstanceAlreadyExistsException: security-base,security-api:application=/MyWebApplication at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) at org.springframework.context.support.LiveBeansView.registerApplicationContext(LiveBeansView.java:68) ... 51 more

在我的应用程序的 web.xml 中,我有这样的配置:

<context-param>  
<param-name>spring.profiles.active</param-name>
<param-value>security-base,security-api</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>security-base,security-api</param-value>
</context-param>
<context-param>
<param-name>spring.liveBeansView.mbeanDomain</param-name>
<param-value>security-base,security-api</param-value>
</context-param>

谁能帮帮我?

最佳答案

由于您在 Tomcat 服务器上为相同 应用程序(尽管不同版本)部署了两个,因此您需要以不同方式命名您的 MBean。由于 MBean 是按服务器访问的(通过单个 JMX 端点),每个 MBean 标识符必须是独立的。

您有几个选项可以让这些在您的应用中独一无二:

  1. 最简单的解决方案是将endpoints.jmx.unique-names 设置为true 并让Spring Boot make the MBean paths unique for you ,而不是使用默认名称。.
  2. 或者,您可以通过为应用程序设置 spring.jmx.default-domain=applicationname 来更改 MBean 域
  3. 您可能不需要这个,但为了完整性而在此处添加;如果您在 Spring 配置中手动加载 bean,则可以添加 EnableMBeanExport 指定域:

    @Configuration
    @EnableMBeanExport(defaultDomain="first")
    public class MBeanConfig {...}

关于java - 并行部署异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47332718/

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