错误ContextLoader,localhost-startStop-1:331 - 上下文初始化失败

时间:2016-07-05 19:40:39

标签: jasperserver

我使用LDAP外部身份验证登录JasperReports Server。我已经配置了applicationContext-externalAuth-LDAP.xml

即。在applicationContext-externalAuth-LDAP.xml中:

<bean id="ldapContextSource"
       class="com.jaspersoft.jasperserver.api.security.externalAuth.ldap.JSLdapContextSource">
     <constructor-arg value="${external.ldap.url}" />
     <property name="userDn" value="${external.ldap.username}" />
     <property name="password" value="${external.ldap.password}"/>
</bean>
 the default_master.properties file contains

external.ldapUrl=ldap://hostname:389/dc=example,dc=com
external.ldapDn=cn=Administrator,dc=example,dc=com

以下是错误消息的堆栈跟踪:

  042 ERROR ContextLoader,localhost-startStop-1:331 - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'ldapContextSource' defined in ServletContext resource [/WEB-INF/applicationContext-externalAuth-LDAP.xml]: Could not resolve placeholder 'external.ldapPassword' in string value "${external.ldapPassword}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'external.ldapPassword' in string value "${external.ldapPassword}"
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:223)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:696)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:671)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'external.ldapPassword' in string value "${external.ldapPassword}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:161)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:258)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82)
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:206)

1 个答案:

答案 0 :(得分:0)

如果尚未安装,则模糊密码非常简单:

  

要确定propertyConfigurer是否扫描了您的属性,您需要搜索它是否在propertyConfigurer位置的其中一个文件中定义。例如,假设您要在 applicationContext-report-scheduling.xml 中加密 reportSchedulerMailSender bean的密码属性。

     

$ {report.scheduler.mail.sender.password} 告诉您 report.scheduler.mail.sender.password 很可能是通过 propertyConfigurer定义的 bean。搜索propertyConfigurer位置以进行验证。您将能够在 /WEB-INF/js.quartz.properties 中找到此属性:

report.scheduler.mail.sender.password=${quartz.mail.sender.password}.

这与您的js.externalAuth.properties文件及其值类似。

  

现在, quartz.mail.sender.password 属性可以在 default-master.properties 中加密,如下所示:   在 default-master.properties 中使用所需密码设置 quartz.mail.sender.password quartz.mail.sender.password = XXYYZZ 。如果安装尚未发生,您可以在default-master.properties中取消注释 encrypt = true propsToEncrypt = dbPassword 。然后,您可以将 quartz.mail.sender.password 添加到 propsToEncrypt

quartz.mail.sender.password=XXYYZZ
encrypt=true
propsToEncrypt=dbPassword,quartz.mail.sender.password
     

运行 js-install 后,验证 default-master.properties 中的 report.scheduler.mail.sender.password 是否已加密并在 /WEB-INF/js.quartz.properties

     

如果安装已经运行,请按上述设置属性并重新运行。

BEWARE :如果你运行js-install,你可能会破坏你的JasperReport安装:

  

这些命令将覆盖在步骤1中创建的war文件,并使服务器数据源无法访问。如果需要重新部署war文件,请将数据库密码重置为纯文本,然后从步骤1重新开始。

Source