0 Replies Latest reply on Feb 11, 2010 3:16 AM by slipknot_domagoj.tomljenovic

    JNDI, OSGi, Fuse

    slipknot_domagoj.tomljenovic Newbie



      Thank You for sharing your time with me.


      I used FUSE Integration Designer to create simple maven project.


      This project was Camel routing application which scans mails and save attachments in another server directory. Then stored procedure is called. Stored procedure updates database with informations stored in the attachment.


      At first, I put jndi.properties and jndi xml into root „src“ directory of application.

      From FUSE Integration Designer everything was worked ok.


      Then my admin said that he wants to configure some properties from external file.


      I try to add variable classpath entry (pointing to some directory on disk). I put jndi.properties into that dir. In another dir I put jndi.xml with entry pointing to file which contains properties. That solution also worked ok.



          1. jndi.properties ###





          1. jndi.xml ###


      <bean id="jndi"



      <property name="entries">


      <entry key="fuseConfig" value-ref="jndiEntries" />






      <bean id="jndiEntries" class="org.springframework.beans.factory.config.MapFactoryBean">

      <property name="sourceMap">


      <entry key="properties.file" value="d:/temp/MyMail.properties" />





      Then I build application and create OSGi bundle. It was deployed by putting it in my „C:\progress\fuse-esb-\deploy“ directory. Just to mention, I also installed fuse-mediation-router- and fuse-message-broker-


      After resolving some dependencies (by deploying needed bundles) I have finally succeeded and component was „Active“ and „Started“.


      According to this documentation: (http://fusesource.com/docs/esb/3.3/deploy_guide/DeployESBJNDIConfig.html) I put jndi.properties and jndi.xml into „C:\progress\fuse-esb-\conf“ directory. After starting ServiceMix console „javax.naming.NameNotFoundException: properties.file…“ was shown.




      This is how I try to lookup in the context.




      InitialContext context = new InitialContext();

      LinkedHashMap hm = (LinkedHashMap) context.lookup("fuseConfig");

      FileInputStream myFile = new FileInputStream((String) hm.get("properties.file"));

      Properties props = new Properties();



      Documentation (http://camel.apache.org/registry.html) says that there is 2 types of registry.

      1. JndiRegistry

      2. ApplicationContextRegistry




      Also it says (http://camel.apache.org/exception-javaxnamingnoinitialcontextexception.html) which problem can arise and how to specify another JNDI provider.


      When this code is run:



      public class RgfiPocRouteBuilder extends RouteBuilder {

      public void configure() {











      1. in the FUSE Integration Designer it shows:


      class org.apache.camel.impl.JndiRegistry


      2. bundled in osgi it shows


      class org.apache.camel.spring.spi.ApplicationContextRegistry




      My opinion is that jndi.properties was not loaded on ServiceMix console startup.


      What I did wrong ?


      Please help.


      Cheers !


      Edited by: slipknot on Feb 11, 2010 8:15 AM