code: private static Endpoint initServiceEndpoint(EndpointRegistry epRegistry, String contextPath, String servletName)
     {
        if (contextPath.startsWith("/"))
           contextPath = contextPath.substring(1);
  
        final ObjectName oname = ObjectNameFactory.create(Endpoint.SEPID_DOMAIN + ":" + Endpoint.SEPID_PROPERTY_CONTEXT
              + "=" + contextPath + "," + Endpoint.SEPID_PROPERTY_ENDPOINT + "=" + servletName);
        Endpoint endpoint = epRegistry.getEndpoint(oname);
        if (endpoint == null)
        {
           throw Messages.MESSAGES.cannotObtainEndpoint(oname);
        }
  
        //Inject the EJB and JNDI resources if possible
        injectServiceAndHandlerResources(endpoint);
  
        return endpoint;
     }
docs: Initialize the service endpoint