spring jndi NamingException: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context

前端 未结 2 1988
太阳男子
太阳男子 2021-02-20 18:34

My webapp with spring 3.2.4 is running fine. But when I start up it, I will get debug infos:

2014-05-20 11:11:47 DEBUG JndiTemplate:150 - Looking up JNDI object          


        
2条回答
  •  情歌与酒
    2021-02-20 19:27

    This is the JIRA issue and a short explanation about why it's been introduced first time in Spring 3.2. Also, a bit more details you can find in the initial commit for this feature.

    Basically, this feature it's a way to expose through JMX a live list of beans that exist in an application context from a certain application. For example, you have a webapp deployed in Tomcat and upon starting it you pass to it as an environment variable one called spring.liveBeansView.mbeanDomain. And let's say you don't give it any value, or just an empty String. Spring searches a long list of possible locations for this kind of property and it's finding it in the system environment. If it's found it will know to expose that list of live beans (in JSON format) through JMX.

    If you connect with JConsole to your Tomcat instance you will see an entry called DefaultDomain and under it your application's name. If you expand that there should be an attribute called SnapshotAsJson and this is the live list of beans from your webapp's application context.

    If you would have given a value to your system environment variable, let's say "test_domain", in JMX the entry would have been called test_domain and not DefaultDomain.

    So, basically you are seeing those DEBUG messages because Spring searches for spring.liveBeansView.mbeanDomain property in a long list of locations, JNDI (in case of JEE servers) being one of them.

    In the latest version of SpringSource Tool Suite (and maybe in some earlier ones), there is a feature that makes use of this live beans JMX exposure called "Live Beans Graph" that takes that JSON representation and creates a somewhat basic graphic representation of those beans.

提交回复
热议问题