Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find

微wx笑發表於2017-03-22

修改專案的配置檔案,log4j的日誌輸出級別修改為DEBUG,列印詳細的錯誤資訊後,

啟動專案控制檯輸出有以下異常資訊:

[org.springframework.jndi.JndiTemplate]-Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain]
[org.springframework.jndi.JndiLocatorDelegate]-Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying original name [spring.liveBeansView.mbeanDomain]. javax.naming.NameNotFoundException: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].
[org.springframework.jndi.JndiTemplate]-Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
[org.springframework.jndi.JndiPropertySource]-JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].. Returning null.
[org.springframework.core.env.PropertySourcesPropertyResolver]-Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
[org.springframework.core.env.PropertySourcesPropertyResolver]-Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
[org.springframework.core.env.PropertySourcesPropertyResolver]-Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
[org.springframework.web.servlet.DispatcherServlet]-Published WebApplicationContext of servlet 'SpringMVC' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.SpringMVC]
[org.springframework.web.servlet.DispatcherServlet]-FrameworkServlet 'SpringMVC': initialization completed in 1138 ms
[org.springframework.web.servlet.DispatcherServlet]-Servlet 'SpringMVC' configured successfully
三月 22, 2017 11:45:12 上午 org.apache.catalina.core.StandardContext reload
資訊: Reloading Context with name [/yuyi] is completed
這個異常倒是不影響專案執行。

錯誤原因:

就是提供通過JMX來實時檢視Spring放在application context裡的bean列表功能的一個包,他會在你的配置檔案裡找一個叫"spring.liveBeansView.mbeanDomain"的環境變數,沒找到,就報錯了。

解決方法

如果你不使用任何 profiles 或 mbeans,可以在web.xml 中新增以下內容:

<context-param>  
    <param-name>spring.profiles.active</param-name>  
    <param-value>dev</param-value>  
</context-param>  
<context-param>  
    <param-name>spring.profiles.default</param-name>  
    <param-value>dev</param-value>  
</context-param>
<context-param>  
    <param-name>spring.liveBeansView.mbeanDomain</param-name>  
    <param-value>dev</param-value>  
</context-param>  

希望有人能提供比這更好的解決方案。

參考:

https://www.zhihu.com/question/21477643

http://stackoverflow.com/questions/23750619/spring-jndi-namingexception-name-spring-livebeansview-mbeandomain-is-not-boun

======================文件資訊========================

版權宣告:非商用自由轉載-保持署名-註明出處

署名(BY) :testcs_dn(微wx笑)

文章出處:[無知人生,記錄點滴](http://blog.csdn.NET/testcs_dn)

==============歡迎關注我的個人微信訂閱號(微wx笑)============

相關文章