Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-6416

Karaf 4.1.7 - Could not start JMX connector server due to javax.naming.NoInitialContextException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 4.1.7, 4.2.6
    • None
    • karaf
    • None

    Description

      I'm facing this issue intermittently in both Karaf 4.1.7 and latest Karaf 4.2.6.

      karaf@root()> Exception in thread "JMX Connector Thread [service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root]" java.lang.RuntimeException: Could not start JMX connector server
      at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:282)
      Caused by: java.io.IOException: Cannot bind to URL [rmi://127.0.0.1:1099/karaf-root]: javax.naming.NoInitialContextException
      at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:827)
      at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:432)
      at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:269)
      Caused by: javax.naming.NoInitialContextException
      at org.apache.aries.jndi.DelegateContext.getDefaultContext(DelegateContext.java:233)
      at org.apache.aries.jndi.DelegateContext.getURLContext(DelegateContext.java:256)
      at org.apache.aries.jndi.DelegateContext.findContext(DelegateContext.java:214)
      at org.apache.aries.jndi.DelegateContext.bind(DelegateContext.java:82)
      at javax.naming.InitialContext.bind(InitialContext.java:425)
      at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:644)
      at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:427)
      ... 1 more

       

      I've traced the code and found something in 

      org.apache.aries.jndi.ContextHelper.getInitialContext(BundleContext, Hashtable<?, ?>) (org.apache.aries.jndi.core-1.0.2)

       

      ContextProvider provider = getContextProvider(context, environment);
      
       if (provider != null) {
       return new DelegateContext(context, provider);
       } else {
       String contextFactoryClass = (String) environment.get(Context.INITIAL_CONTEXT_FACTORY);
       if (contextFactoryClass == null) {
       return new DelegateContext(context, environment);
       } else {
       throw new NoInitialContextException(Utils.MESSAGES.getMessage("no.initial.context.factory", contextFactoryClass));
       }
       }
      
      

      there the provider = null and it's creating DelegateContext without initial context.
      The provider should be retrieved from

      ServiceReference[] references = AccessController.doPrivileged(new PrivilegedAction<ServiceReference[]>() {
       public ServiceReference[] run() {
       return Activator.getInitialContextFactoryServices();
       }
       });

      But getInitialContextFactoryServices is returning nothing, maybe the service is not up yet.

       

      Attachments

        Issue Links

          Activity

            People

              jbonofre Jean-Baptiste Onofré
              ntanh1 Anh Tuan Nguyen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: