Package javax.naming

Examples of javax.naming.InitialContext.rebind()


      if (!OptionHelper.isEmpty(passwordStr)) {
        setter.setProperty("password", passwordStr);
      }

      Context ctx = new InitialContext();
      ctx.rebind("dataSource", ds);
    } catch (Exception oops) {
      addError(
        "Could not bind  datasource. Reported error follows.", oops);
      ec.addError("Could not not bind  datasource of type [" + dsClassName + "].");
    }
View Full Code Here


    }
    ConnectionFactory factory = (ConnectionFactory) ConnectionFactoryImpl
        .newInstance();

    try {
      ctx.rebind(bindJaxr, factory);
      jndiAlreadyBound = true;
    } catch (NamingException e) {
      log.error("JNDI Bind Failed:" + bindJaxr);
      e.printStackTrace();
    }
View Full Code Here

        // bind UserTransaction and TransactionManager to JNDI
        try {
            InitialContext ic = new InitialContext();
            // TODO: for some reason this is not working, throwing an error: java.lang.IllegalArgumentException: RegistryContext: object to bind must be Remote, Reference, or Referenceable
            ic.rebind("java:comp/UserTransaction", new GeronimoTransactionManager());
        } catch (Exception e) {
            throw new ContainerException("Unable to bind UserTransaction/TransactionManager to JNDI", e);
        }

        // check JNDI
View Full Code Here

            }
        } else {
            // bind RMIDispatcher to InitialContext (must be RMI protocol not IIOP)
            try {
                InitialContext ic = new InitialContext();
                ic.rebind(name, remote);
            } catch (NamingException e) {
                throw new ContainerException("Unable to bind RMIDispatcher to JNDI", e);
            }

            // check JNDI
View Full Code Here

      }

      if (!present) {
        try {
          // we rebind just in case it really is there and we just couldn't read it
          ctx.rebind(QUALIFIED_BEAN_MANAGER_JNDI_NAME,
                     new Reference(BeanManager.class.getName(), BEAN_MANAGER_OBJECT_FACTORY, null));
          bound = true;
          log.info("BeanManager reference bound to " + QUALIFIED_BEAN_MANAGER_JNDI_NAME);
        }
        catch (NamingException e) {
View Full Code Here

            }

            if (!present) {
                try {
                    // we rebind just in case it really is there and we just couldn't read it
                    ctx.rebind(QUALIFIED_BEAN_MANAGER_JNDI_NAME,
                            new Reference(BeanManager.class.getName(), BEAN_MANAGER_OBJECT_FACTORY, null));
                    bound = true;
                    WeldServletLogger.LOG.beanManagerReferenceBoundTo(QUALIFIED_BEAN_MANAGER_JNDI_NAME);
                } catch (NamingException e) {
                    throw WeldServletLogger.LOG.couldNotBindBeanManagerReferenceToJNDI(e.getExplanation());
View Full Code Here

            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
            env.put(Context.PROVIDER_URL, "file:/tmp/JNDI");
            InitialContext ctx = new InitialContext(env);
            // This is the object to use so rebind rather than bind, some JNDI implementations would protect this
            // with the requirement to add <CODE>Context.SECURITY_CREDENTIALS</CODE> or the like
            ctx.rebind("jdbc/DB", ds);
        }
        catch (Exception ex)
        {
            System.err.println("Cannot create the Oracle datasource or bind it into JNDI");
            ex.printStackTrace();
View Full Code Here

            //put the thread's classloader back
            currentThread.setContextClassLoader(childLoader1);

            //test rebind with existing binding
            initCtx.rebind("java:comp/env/rubbish", "xyz");
            assertEquals ("xyz", initCtx.lookup("java:comp/env/rubbish"));

            //test rebind with no existing binding
            initCtx.rebind ("java:comp/env/mullheim", "hij");
            assertEquals ("hij", initCtx.lookup("java:comp/env/mullheim"));
View Full Code Here

            //test rebind with existing binding
            initCtx.rebind("java:comp/env/rubbish", "xyz");
            assertEquals ("xyz", initCtx.lookup("java:comp/env/rubbish"));

            //test rebind with no existing binding
            initCtx.rebind ("java:comp/env/mullheim", "hij");
            assertEquals ("hij", initCtx.lookup("java:comp/env/mullheim"));

            //test that the other bindings are already there
            assertEquals ("xyz", initCtx.lookup("java:comp/env/poubelle"));
View Full Code Here

    }
    ConnectionFactory factory = (ConnectionFactory) ConnectionFactoryImpl
        .newInstance();

    try {
      ctx.rebind(bindJaxr, factory);
      jndiAlreadyBound = true;
    } catch (NamingException e) {
      log.error("JNDI Bind Failed:" + bindJaxr);
      e.printStackTrace();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.