簡體   English   中英

無法解析占位符:Spring XML錯誤

[英]could not resolve placeholder: Spring XML error

我堅持下面提到的異常。 我嘗試了所有可能的方式。 但是他們沒有幫助。

這個問題是因為有不適當的罐子嗎? 是由於多個占位符引起的?

請幫幫我。 希望得到積極的回應。

謝謝,請告訴我是否還有什么我可以與您分享的人,以便您更好地理解。

[12/5/13 4:08:55:744 EST] 0000033e webapp        E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
                                 org.springframework.beans.factory.BeanInitializationException: Error initializing PuttPropertyFileReader; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'customLog4jConfigurer' defined in ServletContext resource [/WEB-INF/application-context.xml]: Could not resolve placeholder 'logging.springlogfile'
                at com.lmig.putt.database.utils.PUTTPropertyFilePlaceholderConfigurer.postProcessBeanFactory(PUTTPropertyFilePlaceholderConfigurer.java:136)
                at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:541)
                at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:532)
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
                at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
                at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
                at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
                at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1651)
                at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:410)
                at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
                at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
                at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:746)
                at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
                at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:422)
                at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:714)
                at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1154)
                at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1369)
                at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:638)
                at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967)
                at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:760)
                at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1348)
                at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2144)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
                at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
                at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5323)
                at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5539)
                at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
                at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
                at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1240)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                at java.lang.reflect.Method.invoke(Method.java:611)
                at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
                at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                at java.lang.reflect.Method.invoke(Method.java:611)
                at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
                at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1085)
                at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:966)
                at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
                at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
                at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
                at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
                at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
                at com.ibm.ws.management.commands.AdminServiceCommands$InvokeCmd.execute(AdminServiceCommands.java:251)
                at com.ibm.ws.console.core.mbean.MBeanHelper.invoke(MBeanHelper.java:241)
                at com.ibm.ws.console.appdeployment.ApplicationDeploymentCollectionAction.execute(ApplicationDeploymentCollectionAction.java:564)
                at org.apache.struts.action.RequestProcessor.processActionPerform(Unknown Source)
                at org.apache.struts.action.RequestProcessor.process(Unknown Source)
                at org.apache.struts.action.ActionServlet.process(Unknown Source)
                at org.apache.struts.action.ActionServlet.doPost(Unknown Source)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
                at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
                at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
                at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
                at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
                at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
                at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1384)
                at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:193)
                at org.apache.struts.action.RequestProcessor.doForward(Unknown Source)
                at org.apache.struts.tiles.TilesRequestProcessor.doForward(Unknown Source)
                at org.apache.struts.action.RequestProcessor.processForwardConfig(Unknown Source)
                at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Unknown Source)
                at org.apache.struts.action.RequestProcessor.process(Unknown Source)
                at org.apache.struts.action.ActionServlet.process(Unknown Source)
                at org.apache.struts.action.ActionServlet.doPost(Unknown Source)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
                at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
                at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
                at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
                at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
                at com.ibm.ws.console.core.servlet.WSCUrlFilter.setUpCommandAssistance(WSCUrlFilter.java:950)
                at com.ibm.ws.console.core.servlet.WSCUrlFilter.continueStoringTaskState(WSCUrlFilter.java:499)
                at com.ibm.ws.console.core.servlet.WSCUrlFilter.doFilter(WSCUrlFilter.java:320)
                at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
                at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
                at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
                at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
                at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
                at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:895)
                at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
                at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
                at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
                at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
                at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
                at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
                at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
                at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
                at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
                at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
                at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
                at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
                at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
                at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'customLog4jConfigurer' defined in ServletContext resource [/WEB-INF/application-context.xml]: Could not resolve placeholder 'logging.springlogfile'
                at com.lmig.putt.database.utils.PUTTPropertyFilePlaceholderConfigurer.processProperties(PUTTPropertyFilePlaceholderConfigurer.java:176)
                at com.lmig.putt.database.utils.PUTTPropertyFilePlaceholderConfigurer.postProcessBeanFactory(PUTTPropertyFilePlaceholderConfigurer.java:132)
                ... 105 more

應用程序的context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <bean id="properyFilePlaceholderConfigurer" class="com.lmig.putt.database.utils.PUTTPropertyFilePlaceholderConfigurer">
            <property name="location">
                <value>/WEB-INF/config/PuttWebConfiguration.xml</value>
            </property>

        </bean>

 <bean id="customLog4jConfigurer" class="com.lmig.putt.database.utils.Log4JConfigurer">
        <property name="location">
            <value>/WEB-INF/config/app-log4j.properties</value>
        </property>
        <property name="log4JProperties">
            <props>
                <prop key="ROOTLEVEL">${logging.rootlogger}</prop>
                <prop key="APPLEVEL">${logging.applogger.level}</prop>
                <prop key="CONSOLETHRESHOLD">${logging.consolethreshold}</prop>
                <prop key="SPRINGLOGLEVEL">${logging.spring.level}</prop>
                <prop key="EMAIL">${logging.email}</prop>
                <prop key="SPRING_LOGFILE">${logging.springlogfile}</prop>
                <prop key="ENV">${logging.environment}</prop>
                <prop key="MAXFILESIZE">${logging.maxfilesize}</prop>
                <prop key="MAXBACKUPINDEX">${logging.maxbackupindex}</prop>     
                <prop key="APP_LOGFILE">${logging.puttdblogfile}</prop>
                <prop key="SYS_LOGFILE">${logging.systemlogfile}</prop>
            </props>
        </property>
    </bean> 

ProjectWebConfiguration.xml

<!--Log4J Configuration  -->
            <item key="logging.environment" value="local"/>

            <item key="logging.rootlogger" value="INFO"/>
            <item key="logging.applogger.level" value="DEBUG"/>
            <item key="logging.spring.level" value="INFO"/>
            <item key="logging.consolethreshold" value="OFF"/>
            <item key="logging.email" value="vetree@salemns.com"/>

            <item key="logging.springlogfile" value="/home/vetree/spring.log"/>
            <item key="logging.systemlogfile" value="/home/vetree/sys.log"/>
            <item key="logging.puttdblogfile" value="/home/vetree/smart.log"/>

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>PUTT</display-name>

 <context-param>
  <param-name>log4ConfigLocation</param-name>
  <param-value>/WEB-INF/classes/log4j.properties</param-value>
 </context-param>
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/application-context.xml</param-value>
 </context-param>
  <!-- Log4jConfigListener also tries to
        set the webAppRootKey. solve this by adding the following statements in web.xml -->
 <context-param>
  <param-name>log4jExposeWebAppRoot</param-name>
  <param-value>false</param-value>
 </context-param>

嘗試將上下文名稱空間添加到您的Spring Configuration中,然后定義屬性占位符的位置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

        <context:property-placeholder location="classpath:/WEB-INF/config/app-log4j.properties" />

請注意,上下文名稱空間的版本可能與您有所不同。 最容易使用STS添加,它將為您添加導入到配置文件中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM