Blessed Geek
Blessed Geek

Reputation: 21674

Springframework beans

I have not until now had worked with spring framework. I tried reading and reading the spring documentation but could not locate the answer to the following simple question.

The application is ant built to a build directory. So far when I tried to start the JBOSS (or apache) server, the logs says it is unable to build the bean because it could not find

var/config/madagascar.prop. . WRT the following snippet in WEB-INF/applicationContext.xml

<bean id="application.home" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass" value="java.lang.System"/>
    <property name="targetMethod" value="getProperty"/>
    <property name="arguments">
        <list>
            <value>application.home</value>
        </list>
    </property>
</bean>
<bean id="propertyFile" class="java.io.File">
    <constructor-arg ref="application.home"/>
    <constructor-arg value="var/config/madagascar.prop"/>
</bean>

Could you tell me where {application.home} and var/config are expected to be located?

Is it relative to the Eclipse project home or relative to WEB-INF?

What is the bean id="application.home" attempting to do - is it trying to read the value for "application.home" from the system env?

Upvotes: 0

Views: 368

Answers (1)

Jonathan W
Jonathan W

Reputation: 3799

"application.home" is the runtime value of System.getProperty("application.home") and the "propertyFile" bean is a java.io.File object returned from calling new java.io.File(String, String) with the whatever application.home is set to and that second String.

If the bean you wanted was 'propertyFile', the runtime equivalent would be:

File file = new File(System.getProperty("application.home"),"var/config/madagascar.prop");

That config is a very Spring 1.x (read old) way of doing things. XML is a very kludgy way to perform many of these types of initialization, and that's one of the reasons that Spring's @JavaConfig approach became so popular.

Upvotes: 1

Related Questions