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>  

 

posted @ 2018-05-14 08:38  Jepson6669  阅读(6201)  评论(0编辑  收藏  举报