You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by yihfeng <yh...@gmu.edu> on 2010/09/27 22:20:49 UTC

cannot load app config file from etc directory

Greetings,

I am using serviceMix 4.2 with cxf, and having an issue of separating an
application configuration file   "xxx.properties" from a bundle jar file
"yyy.jar".

The code/bundle works fine if I have the xxx.properties within the bundle
itself using the following spring bean configuration: (using classpath)


         <bean id="configLoader"
	
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location">
                    <value>classpath:xxx.properties</value>
		</property>
	</bean>



However, I got "file not found" error when I moved the "xxx.properties" file
to $SERVICEMIX_HOME/etc from the bundle "yyy.jar" with the same spring bean
configuration above.  (somehow "$SERVICEMIX_HOME/etc" cannot be recognized
as part of classpath) 



The bundle would work fine if I used the following spring bean
configuration: (instead of using classpath, file with the absolute path is
used)

<bean id="configLoader"
	
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location">
                      <value>
file:/Users/yihfeng/apache-servicemix-4.2.0-fuse-02-00/etc/xxx.properties
                      </value>
		</property>
	</bean>
	

Is this ONLY way to read a configuration file outside of a bundle under
serviceMix 4.2?


Any helps would be greatly appreciated.


Yih-Feng


-- 
View this message in context: http://servicemix.396122.n5.nabble.com/cannot-load-app-config-file-from-etc-directory-tp2855869p2855869.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: cannot load app config file from etc directory

Posted by yihfeng <yh...@gmu.edu>.
Thanks, Freeman, for the advices. IT WORKS with the following:

<osgix:cm-properties id="xxxProps" persistent-id="xxx">
    </osgix:cm-properties>
<ctx:property-placeholder properties-ref="xxxProps" />

Yih-Feng

-- 
View this message in context: http://servicemix.396122.n5.nabble.com/cannot-load-app-config-file-from-etc-directory-tp2855869p2857255.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: cannot load app config file from etc directory

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

My comment inline.
On 2010-9-28, at 上午4:20, yihfeng wrote:

>
> Greetings,
>
> I am using serviceMix 4.2 with cxf, and having an issue of  
> separating an
> application configuration file   "xxx.properties" from a bundle jar  
> file
> "yyy.jar".
>
> The code/bundle works fine if I have the xxx.properties within the  
> bundle
> itself using the following spring bean configuration: (using  
> classpath)
>
>
>         <bean id="configLoader"
> 	
> class 
> = 
> "org 
> .springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> 		<property name="location">
>                    <value>classpath:xxx.properties</value>
> 		</property>
> 	</bean>
>
>
>
> However, I got "file not found" error when I moved the  
> "xxx.properties" file
> to $SERVICEMIX_HOME/etc from the bundle "yyy.jar" with the same  
> spring bean
> configuration above.  (somehow "$SERVICEMIX_HOME/etc" cannot be  
> recognized
> as part of classpath)
>
>
>
> The bundle would work fine if I used the following spring bean
> configuration: (instead of using classpath, file with the absolute  
> path is
> used)
>
> <bean id="configLoader"
> 	
> class 
> = 
> "org 
> .springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> 		<property name="location">
>                      <value>
> file:/Users/yihfeng/apache-servicemix-4.2.0-fuse-02-00/etc/ 
> xxx.properties
>                      </value>
> 		</property>
> 	</bean>
> 	
>
> Is this ONLY way to read a configuration file outside of a bundle  
> under
> serviceMix 4.2?
>
No, this isn't the preferred way to use property place holder in SMX 4.2
As Servicemix 4.2 is based on OSGi, so you should use OSGi style  
property place holder in your beans.xml and ConfigAdmin Service to  
load/set properties from/to property files in $SMX4_HOME/etc folder.

Actually we have a camel-osgi example shipped with kit exactly shows  
how to do it, you need take a look at that example, README.txt  
explains how it works.

Freeman
>
> Any helps would be greatly appreciated.
>
>
> Yih-Feng
>
>
> -- 
> View this message in context: http://servicemix.396122.n5.nabble.com/cannot-load-app-config-file-from-etc-directory-tp2855869p2855869.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


-- 
Freeman Fang

------------------------
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org