0

I am trying to move a working spring WAR to OSGI environment (in glassfish 3.1 and blueprint, spring 3.0.5). The application loads properties file from disk, like this:

<bean id="myProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="${my_conf}/my.properties"/>
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>

I see in debugger that ${my_conf}/my.properties is translated to the existing path (c:\conf\my.properties)

I use the property jms.url defined in my.properties in the next bean declaration

<amq:broker useJmx="false" persistent="false" brokerName="embeddedbroker">
    <amq:transportConnectors>
        <amq:transportConnector uri="tcp://${jms.url}"/>
        <amq:transportConnector uri="vm://embeddedbroker" />
    </amq:transportConnectors>
</amq:broker>

And in deployment I get an exception "Could not resolve placeholder ${jms.url}"

Why it fails? Is there another way to load properties from file on disk?

thank you

lili
  • 1,866
  • 8
  • 29
  • 50
  • possible duplicate [question](http://stackoverflow.com/questions/4779572/could-not-resolve-placeholder-problem). The one you see in debugger might be loaded by another bean in another applicationContext.xml – Ravi Kadaboina Feb 06 '12 at 05:17
  • Thanks. I tried to set a location path to non-existing file, and did not get an exception. I tried to set a hard-coded path to the properties file, and nothing changed. Remember that it worked in non-osgi war – lili Feb 06 '12 at 09:05

2 Answers2

0

Since its an OSGI environment, you will need spring-osgi-core jar added to your application. Take a look at this link to configure property-placeholder for OSGI framework.

Ravi Kadaboina
  • 8,494
  • 3
  • 30
  • 42
  • Thank you. I thought I do not have to use osgix:cm-properties, according to this post: [osgi-spring-config](http://tech-tauk.blogspot.com/2009/12/osgi-spring-configuration-admin-dynamic.html). Am I wrong? – lili Feb 06 '12 at 17:27
  • if you do not use spring-osgi-core you won't be able to use osgix tags in your context.xml as the schemas for these is located in spring-osgi-core – Ravi Kadaboina Feb 06 '12 at 17:40
  • I am not using osgix tags meanwhile, I am using only bean and amq. I am using spring-osgi-core jar and many other spring jars, but it does not help me to solve the described problem – lili Feb 07 '12 at 07:52
0

It isn't a solution, but an explanation of my problem. The problem is related to this bug in spring 3 and osgi.

I had to open spring logs to debug level to understand it.

lili
  • 1,866
  • 8
  • 29
  • 50