开发者

Tomcat 6 Virtual Hosting Same Spring Application

I want to deploy the same .war file to two different virtual hosts on t开发者_StackOverflow社区he same Tomcat 6 instance. However, I am running into a problem with the Spring framework and registering a bean. Here is the error I am seeing...

org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [com.dti.servlets.Configuration@3a1834] with key 'EAM:name=webConfig'; nested exception is javax.management.InstanceAlreadyExistsException: EAM:name=webConfig

I am pretty sure that I need to define my contexts for each virtual host but I am not having any luck. The only fix I have found that works is to change the name of the bean key. Any other suggestions would be great.


The problem is that the name of the bean must be unique per JVM. Since you're deploying the same war twice, you have two solutions:

  1. change the registration behaviour of the Spring JMX exporter (see the documentation)
  2. define your own ObjectNamingStrategy to dynamically change the name of the beans at startup (you would end up with names like app1.mybean and app2.mybean)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜