javax.naming.NameNotFoundException


springmvc和mybatis整合項目debug啟動,拋出下面的異常。

07:51:36,521 DEBUG JndiLocatorDelegate:101 - Converted JNDI name [java:comp/env/spring.profiles.default] not found - trying original name [spring.profiles.default]. javax.naming.NameNotFoundException: Name [spring.profiles.default] is not bound in this Context. Unable to find [spring.profiles.default].
07:51:36,521 DEBUG JndiTemplate:150 - Looking up JNDI object with name [spring.profiles.default]
07:51:36,521 DEBUG JndiPropertySource:90 - JNDI lookup for name [spring.profiles.default] threw NamingException with message: Name [spring.profiles.default] is not bound in this Context. Unable to find [spring.profiles.default].. Returning null.



07:51:36,521 DEBUG JndiLocatorDelegate:101 - Converted JNDI name [java:comp/env/spring.profiles.active] not found - trying original name [spring.profiles.active]. javax.naming.NameNotFoundException: Name [spring.profiles.active] is not bound in this Context. Unable to find [spring.profiles.active].
07:51:36,521 DEBUG JndiTemplate:150 - Looking up JNDI object with name [spring.profiles.active]
07:51:36,521 DEBUG JndiPropertySource:90 - JNDI lookup for name [spring.profiles.active] threw NamingException with message: Name [spring.profiles.active] is not bound in this Context. Unable to find [spring.profiles.active].. Returning null.



07:51:37,099 DEBUG JndiLocatorDelegate:101 - 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].
07:51:37,099 DEBUG JndiTemplate:150 - Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
07:51:37,099 DEBUG JndiPropertySource:90 - 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.

上面的異常不用處理,倒是不會影響程序功能的使用。

從上面日志信息中我們可以很清晰的看到異常來自於jndi的數據源配置,但是問題是我的項目中並沒有使用jndi。

網上查閱資料,有說是jar包問題的,也有說是spring配置的內部問題,這里我並沒有取深究具體的問題。

 

如果不想看到上面拋出異常的日志信息,我們有兩種解決辦法。

 

方法一:修改log4j日志信息的級別為info級別,就不會看到上面的信息了

修改為:

方法二:修改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>  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM