Jahia Dev Forum > Getting property...

0 (0 Good)
0 (0 Bad)

Getting property values in .jsp using different Spring profiles (Jahia 7.2)

by  ejub.boric@landtag.nrw.de »  2018/11/13 07:54

When I am trying to set the value of a certain property in a .jsp file...

<spring:eval expression="@environmentProperties.getProperty('rss.targetHost')" var="rssHost" />

... I get following "spring"-Exception:

Caused by: org.springframework.expression.AccessException: Could not resolve bean reference against BeanFactory
	at org.springframework.context.expression.BeanFactoryResolver.resolve(BeanFactoryResolver.java:47)
	at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:48)
	... 157 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'environmentProperties' is defined
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:575)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1111)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:276)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:267)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1119)
	at org.springframework.context.expression.BeanFactoryResolver.resolve(BeanFactoryResolver.java:44)
	... 158 more

 

1. -Dspring.profiles.active is set and working. I've checked it with System.getProperty("spring.profiles.active") in .jsp file.

2. Spring module onfiguration xml:  <context:property-placeholder properties-ref="environmentProperties" order="1"  ignore-unresolvable="true"/>

2. local.xml: <util:properties id="environmentProperties" location="osgibundle:/config/local.properties" >

3. Property 'rss.targetHost=http://localhost:8080' in /config/local.properties set

 

I have already used spring profiles in order to get database connections from pool or generate custom data source. Therefoe I asume that configuration settings are correct.

Well, how to get a value of a property in dependency of currently used spring profile in a .jsp file?

Is the usage of a spring:eval tag right approach or does Jaha eventually has its own Taglib for this case?

Thanks!

 

  (ejub.boric@landtag.nrw.de)

Number of messages  3
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page