搭建springmvc框架,debug日志一直有个异常,大家帮忙看看

CraneH 发布于 2013/12/02 17:33
阅读 42K+
收藏 1
google、百度了没找到原因,还望大家帮忙看看呢~

主要就是这段:17:19:24 [JndiPropertySource.getProperty] [DEBUG] JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Name spring.liveBeansView.mbeanDomain is not bound in this Context. Returning null.

17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Searching for key 'spring.liveBeansView.mbeanDomain' in [servletConfigInitParams]

17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Searching for key 'spring.liveBeansView.mbeanDomain' in [servletContextInitParams] 17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Searching for key 'spring.liveBeansView.mbeanDomain' in [jndiProperties] 17:19:24 [JndiTemplate.lookup] [DEBUG] Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain] 17:19:24 [JndiLocatorSupport.lookup] [DEBUG] 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 17:19:24 [JndiTemplate.lookup] [DEBUG] Looking up JNDI object with name [spring.liveBeansView.mbeanDomain] 17:19:24 [JndiPropertySource.getProperty] [DEBUG] JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Name spring.liveBeansView.mbeanDomain is not bound in this Context. Returning null. 17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties] 17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment] 17:19:24 [EnumerablePropertySource.containsProperty] [DEBUG] PropertySource [systemEnvironment] does not contain 'spring.liveBeansView.mbeanDomain' 17:19:24 [EnumerablePropertySource.containsProperty] [DEBUG] PropertySource [systemEnvironment] does not contain 'spring_liveBeansView_mbeanDomain' 17:19:24 [EnumerablePropertySource.containsProperty] [DEBUG] PropertySource [systemEnvironment] does not contain 'SPRING.LIVEBEANSVIEW.MBEANDOMAIN' 17:19:24 [EnumerablePropertySource.containsProperty] [DEBUG] PropertySource [systemEnvironment] does not contain 'SPRING_LIVEBEANSVIEW_MBEANDOMAIN' 17:19:24 [PropertySourcesPropertyResolver.getProperty] [DEBUG] Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null] 17:19:24 [ContextLoader.initWebApplicationContext] [DEBUG] Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT] 17:19:24 [ContextLoader.initWebApplicationContext] [INFO] Root WebApplicationContext: initialization completed in 6210 ms

系统配置文件

<beans 
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:cache="http://www.springframework.org/schema/cache"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.2.xsd
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
		http://www.springframework.org/schema/cache
		http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
	    http://www.springframework.org/schema/util 
	    http://www.springframework.org/schema/util/spring-util-3.2.xsd
        ">
	<description>Spring公共配置 </description>

	<context:annotation-config />

	<!-- 自动扫描的包名 -->
	<context:component-scan base-package="cn.test">
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<!-- 数据源、系统配置, 加载ClassPath中的properties文件 -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="ignoreResourceNotFound" value="true" />
		<property name="locations" value="classpath*:/global.properties"/>
	</bean>
	
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<!-- Connection Info -->
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		
		<!-- Connection Pooling Info -->
		<property name="maxActive" value="${dbcp.maxActive}" />
		<property name="maxIdle" value="${dbcp.maxIdle}" />
		<property name="defaultAutoCommit" value="false" />
		<property name="timeBetweenEvictionRunsMillis" value="3600000"/>
		<property name="minEvictableIdleTimeMillis" value="3600000"/>
	</bean>

	<!-- 基于JDBC的事务管理器 -->
	<!-- 使用Spring JDBC或iBatis等基于DataSource数据源的持久化技术时,使用该事务管理器 -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager" />

	<!-- 创建SqlSessionFactory,同时指定数据源 -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="configLocation" value="classpath:mybatis-config.xml" />
		<!--指定实体类映射文件,可以指定同时指定某一包以及子包下面的所有配置文件,mapperLocations和configLocation有一个即可,当需要为实体类指定别名时,可指定configLocation属性,再在mybatis总配置文件中采用mapper引入实体类映射文件 -->
		<!-- <property name="mapperLocations" value="classpath*:com/xxt/ibatis/dbcp*.xml"/> -->
	</bean>

	<!-- 自动扫描Mapper -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="cn.test.system.dao,cn.test.lihua.dao" />
	</bean>

	<!-- 使用缓存annotation 配置 -->
	<cache:annotation-driven cache-manager="ehCacheManager" />
	
	<!-- Spring对EhCache的缓存工厂支持 -->
	<bean id="ehCacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
	    <property name="configLocation" value="classpath:ehcache.xml" />
	    <property name="shared" value="false" />
	</bean>
	
	<!-- Spring对EhCache的缓存管理 -->
	<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
	    <property name="cacheManager" ref="ehCacheManagerFactory"></property>
	</bean>
    
    <!-- EhCache缓存监听 -->
    <bean id="myCacheListener" class="cn.test.lihua.listener.TimingQueueCacheEventListener" lazy-init="false" />


	<!-- FreeMarker视图配置 -->
	<bean id="freeMarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="templateLoaderPaths" value="${template.loader_path}" />
		<property name="freemarkerSettings">
			<props>
				<prop key="defaultEncoding">${template.encoding}</prop>
				<prop key="locale">${locale}</prop>
				<prop key="template_update_delay">${template.update_delay}</prop>
				<prop key="tag_syntax">auto_detect</prop>
				<prop key="whitespace_stripping">true</prop>
				<prop key="classic_compatible">true</prop>
				<prop key="number_format">${template.number_format}</prop>
				<prop key="boolean_format">${template.boolean_format}</prop>
				<prop key="datetime_format">${template.datetime_format}</prop>
				<prop key="date_format">${template.date_format}</prop>
				<prop key="time_format">${template.time_format}</prop>
				<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
			</props>
		</property>
		<property name="freemarkerVariables">
			<map>
				<entry key="systemName" value="XXX系统" />
				<entry key="systemVersion" value="V1.0" />
				<entry key="base" value="#{servletContext.contextPath}" />
				<entry key="locale" value="${locale}" />
			</map>
		</property>
	</bean>

	<!-- Spring AOP -->
	<aop:config>
		<aop:aspect id="LogAspect"  ref="aspectBean">
			<aop:pointcut id="bisService" expression="execution(* cn.test.system.service..*.*(..))"/>
			<aop:before pointcut-ref="bisService" method="doBefore"/>  
			<aop:after pointcut-ref="bisService" method="doAfter"/>
		</aop:aspect>
	</aop:config>
	<bean id="aspectBean" class="cn.test.system.aop.MyAspect"/>
	<bean id="mybservice" class="cn.test.system.service.MyBService"/>
	
		
</beans>


另附web.xml配置

<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<display-name>lhzx</display-name>

	<!-- 指定Spring的配置文件 -->
	<!-- 否则Spring会默认从WEB-INF下寻找配置文件,contextConfigLocation属性是Spring内部固定的 -->
	<!-- 通过ContextLoaderListener的父类ContextLoader的第120行发现CONFIG_LOCATION_PARAM固定为contextConfigLocation -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			classpath:applicationContext.xml,
			classpath:applicationContext-shiro.xml
		</param-value>
	</context-param>

	<!-- 防止发生java.beans.Introspector内存泄露,应将它配置在ContextLoaderListener的前面 -->
	<listener>
		<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
	</listener>
	<!-- 实例化Spring容器 -->
	<!-- 应用启动时,该监听器被执行,它会读取Spring相关配置文件,其默认会到WEB-INF中查找applicationContext.xml -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- 配置Shiro过滤器,先让Shiro过滤系统接收到的请求 -->
	<!-- 这里filter-name必须对应applicationContext.xml中定义的<bean id="shiroFilter"/> -->
	<!-- 使用[/*]匹配所有请求,保证所有的可控请求都经过Shiro的过滤 -->
	<!-- 通常会将此filter-mapping放置到最前面(即其他filter-mapping前面),以保证它是过滤器链中第一个起作用的 -->
	<filter>
		<filter-name>shiroFilter</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
		<init-param>
			<!-- 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 -->
			<param-name>targetFilterLifecycle</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>shiroFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<!-- SpringMVC核心分发器 -->
	<servlet>
		<servlet-name>SpringMVC</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:servlet-context.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>SpringMVC</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

	<!-- Spring字符集过滤器 -->
	<filter>
		<filter-name>SpringEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>SpringEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<error-page>
		<exception-type>java.lang.Throwable</exception-type>
		<location>/WEB-INF/templates/error/500.jsp</location>
	</error-page>
	<error-page>
		<error-code>500</error-code>
		<location>/WEB-INF/templates/error/500.jsp</location>
	</error-page>
	<error-page>
		<error-code>404</error-code>
		<location>/WEB-INF/templates/error/400.jsp</location>
	</error-page>
	<error-page>
		<error-code>405</error-code>
		<location>/WEB-INF/templates/error/405.jsp</location>
	</error-page>

</web-app>



加载中
0
丁加砙
CraneH
CraneH
代码里貌似没有用到@configuration @profile 这样的注解
0
duty
duty
web.xml有配吗?
CraneH
CraneH
配置了吧,大神您帮忙看下呢?
0
z
zhuomin

楼主楼主 这个问题有解决没 我也遇见了 

CraneH
CraneH
还没有解决
0
Barudisshu
Barudisshu
去掉log4j的所有配置试试,我也遇到过。之前没有这样的问题,后来maven update后出现的。
0
marinesky
marinesky
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreResourceNotFound" value="true" />
        <property name="locations" value="classpath*:/global.properties"/>

</bean>

中加入这行试试,默认的是ENVIRONMENT

<property name="system-properties-mode" value="NEVER"/>


0
小草莓
小草莓
项目可能没有部署到容器中
0
wl8685
wl8685
楼主这个问题找到原因了吗?最近修改项目也遇到这个问题了 一直找不到问题的原因
0
wl8685
wl8685
我是修改web.xml后启动不再报Name spring.profiles.active is not bound in this Context了
修改前:
<context-param>

        <param-name>spring.profiles.defualt</param-name>

        <param-value>development</param-value>

    </context-param>

修改后:
<context-param>

        <param-name>spring.profiles.active</param-name>

        <param-value>development</param-value>

    </context-param>
CraneH
CraneH
嗯,就是在web.xml里面加了点开发配置
0
CraneH
CraneH

引用来自“wl8685”的评论

我是修改web.xml后启动不再报Name spring.profiles.active is not bound in this Context了
修改前:
<context-param>

        <param-name>spring.profiles.defualt</param-name>

        <param-value>development</param-value>

    </context-param>

修改后:
<context-param>

        <param-name>spring.profiles.active</param-name>

        <param-value>development</param-value>

    </context-param>
<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>



0
shizongger
shizongger

我遇到类似的报错:

javax.naming.NameNotFoundException: Name spring.liveBeansView.mbeanDomain is not bound in this Context



不过这个报错貌似可以忽略了!

返回顶部
顶部