OK, apparently I was sleeping when I wrote this, because now that I try to use an external properties file at home, I am still getting the FileNotFound exception (but only from command line).
To start over, I'm trying to use a .properties file in conjunction with my mule-config xml file. According to the Mule docs, it is done with the following:
<context:property-placeholder location="test.properties" />
When I run this from my Eclipse 3.5 and Mule IDE 2.0.2 (whichever is latest?), it works fine. If I run from command line, it fails with the error I'll post at the bottom.
At work, neither option works (Eclipse 3.5 with Dirk's .zip Mule IDE he attached, nor command line). Is there something simple I'm missing in my work environment?
Here's the basic mule config for testing:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="
http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:file="
http://www.mulesource.org/schema/mule/file/2.2"
xmlns:context="
http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/file/2.2 http://www.mulesource.org/schema/mule/file/2.2/mule-file.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd">
<context:property-placeholder location="test.properties" />
</mule>
Note that I've tried several options for the location value, i.e. "test.properties", "classpath:test.properties", etc. None seem to work when I run mule from the command line (i.e. mule -config mule-config.xml) and no matter which dir I'm in when I run mule.
Here is the error I get outside of the one working Eclipse:
Running in console/foreground mode by default, use Ctrl-C to exit...
--> Wrapper Started as Console
Launching a JVM...
Starting the Mule Server...
Wrapper (Version 3.2.3)
http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
INFO 2010-01-16 12:13:11,500 [WrapperListener_start_runner] org.mule.MuleServer: Mule Server initializing...
INFO 2010-01-16 12:13:11,796 [WrapperListener_start_runner] org.mule.config.spring.MuleApplicationContext: Refreshing org.mule.config.spring.MuleApplicationContext@11978b: display name [org.mule.config.spring.MuleApplicationContext@11978b]; startup date [Sat Jan 16 12:13:11 EST 2010]; root of context hierarchy
INFO 2010-01-16 12:13:12,375 [WrapperListener_start_runner] org.mule.config.spring.MuleApplicationContext: Bean factory for application context [org.mule.config.spring.MuleApplicationContext@11978b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@118278a
ERROR 2010-01-16 12:13:12,468 [WrapperListener_start_runner] org.mule.config.spring.SpringXmlConfigurationBuilder: Configuration with "org.mule.config.spring.SpringXmlConfigurationBuilder" failed.
org.mule.api.lifecycle.InitialisationException: Initialisation Failure: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:76)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:98)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:69)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:112)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:58)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:177)
at org.mule.MuleServer.initialize(MuleServer.java:351)
at org.mule.MuleServer.run(MuleServer.java:257)
at org.mule.MuleServer.start(MuleServer.java:244)
at org.mule.module.boot.MuleServerWrapper.start(MuleServerWrapper.java:48)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:87)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:68)
... 14 more
Caused by: java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:182)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:69)
... 19 more
ERROR 2010-01-16 12:13:12,468 [WrapperListener_start_runner] org.mule.config.builders.AutoConfigurationBuilder: Configuration with "org.mule.config.builders.AutoConfigurationBuilder" failed.
org.mule.api.config.ConfigurationException: Initialisation Failure: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist (org.mule.api.lifecycle.InitialisationException)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:112)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:58)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:177)
at org.mule.MuleServer.initialize(MuleServer.java:351)
at org.mule.MuleServer.run(MuleServer.java:257)
at org.mule.MuleServer.start(MuleServer.java:244)
at org.mule.module.boot.MuleServerWrapper.start(MuleServerWrapper.java:48)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.mule.api.lifecycle.InitialisationException: Initialisation Failure: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:76)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:98)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:69)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
... 11 more
Caused by: org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:87)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:68)
... 14 more
Caused by: java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:182)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:69)
... 19 more
ERROR 2010-01-16 12:13:12,531 [WrapperListener_start_runner] org.mule.MuleServer:
********************************************************************************
Message : Initialisation Failure: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
Type : org.mule.api.lifecycle.InitialisationException
Code : MULE_ERROR-72085
JavaDoc :
http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html
Object : org.mule.config.spring.SpringRegistry@2c17f7
********************************************************************************
Exception stack is:
1. class path resource [test.properties] cannot be opened because it does not exist (java.io.FileNotFoundException)
org.springframework.core.io.ClassPathResource:143 (null)
2. Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist (org.springframework.beans.factory.BeanInitializationException)
org.springframework.beans.factory.config.PropertyResourceConfigurer:78 (null)
3. Initialisation Failure: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist (org.mule.api.lifecycle.InitialisationException)
org.mule.registry.AbstractRegistry:76 (
http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html)
********************************************************************************
Root Exception stack trace:
java.io.FileNotFoundException: class path resource [test.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:182)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:69)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:87)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:68)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:98)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:69)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:112)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:58)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:39)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:177)
at org.mule.MuleServer.initialize(MuleServer.java:351)
at org.mule.MuleServer.run(MuleServer.java:257)
at org.mule.MuleServer.start(MuleServer.java:244)
at org.mule.module.boot.MuleServerWrapper.start(MuleServerWrapper.java:48)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
********************************************************************************
ERROR 2010-01-16 12:13:12,640 [WrapperListener_start_runner] org.mule.MuleServer:
********************************************************************************
* A Fatal error has occurred while the server was running: *
* class path resource [test.properties] cannot be opened because it does not *
* exist (java.io.FileNotFoundException) *
* *
* The error is fatal, the system must shutdown *
* Server started: 12/31/69 7:00 PM *
* Server shutdown: 1/16/10 12:13 PM *
********************************************************************************
INFO 2010-01-16 12:13:12,812 [Thread-1] org.mule.MuleServer: Mule server shutting down due to normal shutdown request
INFO 2010-01-16 12:13:12,828 [Thread-1] org.mule.MuleServer:
**************************************************************************************
* The server is shutting down due to normal shutdown request *
* Server started: 12/31/69 7:00 PM *
* Server shutdown: 1/16/10 12:13 PM *
**************************************************************************************
<-- Wrapper Stopped