title: How to configure and looking up OSGi service via JNDI
body: <p>I have created a OSGi bundle using bundle activator and deployed in karaf,
  but in karaf if you give jndi:bind-id service-name  then it will not exist after karaf console shutdown because its not persistent.</p>
  
  <p>I want to register service in OSGi using JNDi which is persistent, which is I can access using JNDI.</p>
  
  <p>I am registering service as under,</p>
  
  <pre><code> bundleContext.registerService(myFramework.class.getName(),FrmFactory.initFramework(ctx), null);
  Context ctx = null;
          try
          {
              ctx = new InitialContext();
              ctx.bind("service/myframework", frmFactory.initFramework(ctx));
          }
  </code></pre>
  
  <p>Please suggest is this the right way,if not Please suggest,
  because I am getting exception as </p>
  
  <blockquote>
    <p>errorMessage = jndiobjectBindError, errorMessage = Failed to bind
    local object in jndi. Object Name:service/portframework, cause =
    javax.naming.NotContextException: The intermediate context Myfr
    amework does not exist</p>
  </blockquote>