Package javax.naming

Examples of javax.naming.NoInitialContextException


        throws NoInitialContextException, NotContextException {
        if (ctx instanceof DirContext) {
            return (DirContext) ctx;
        } else if (null == ctx) {
            // jndi.1A=Cannot create initial context.
            throw new NoInitialContextException(Messages.getString("jndi.1A"))//$NON-NLS-1$
        } else {
            // jndi.1B=DirContext object is required.
            throw new NotContextException(Messages.getString("jndi.1B"))//$NON-NLS-1$
        }
    }
View Full Code Here


            throw e;
        } catch (Exception e) {
            // failed, throw NoInitialContextException
            // jndi.20=Failed to create InitialContext using factory specified
            // in hashtable {0}
            NamingException nex = new NoInitialContextException(Messages
                    .getString("jndi.20", h)); //$NON-NLS-1$
            nex.setRootCause(e);
            throw nex;
        }
    }
View Full Code Here

            throws NoInitialContextException, NotContextException {
        if (ctx instanceof DirContext) {
            return (DirContext) ctx;
        } else if (null == ctx) {
            // jndi.1A=Cannot create initial context.
            throw new NoInitialContextException(Messages.getString("jndi.1A")); //$NON-NLS-1$
        } else {
            // jndi.1B=DirContext object is required.
            throw new NotContextException(Messages.getString("jndi.1B")); //$NON-NLS-1$
        }
    }
View Full Code Here

            throw e;
        } catch (Exception e) {
            // failed, throw NoInitialContextException
            // jndi.20=Failed to create InitialContext using factory specified
            // in hashtable {0}
            NamingException nex = new NoInitialContextException(Messages
                    .getString("jndi.20", h)); //$NON-NLS-1$
            nex.setRootCause(e);
            throw nex;
        }
    }
View Full Code Here

   * two objects should be equal.
   */
  public void testSerializable_Simple() throws ClassNotFoundException,
      IOException, InvalidNameException {

    NoInitialContextException exception = new NoInitialContextException(
        "Test exception Serializable: NoInitialContextException");
    exception.setRemainingName(new CompositeName(
        "www.apache.org/foundation"));
    exception.setResolvedName(new CompositeName(
        "http://www.apache.org/index.html"));
    exception.setResolvedObj("This is a string object.");
    exception.setRootCause(new NullPointerException("null pointer"));

    // write to byte array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(exception);
    byte[] buffer = baos.toByteArray();
    oos.close();
    baos.close();

    // read from byte array
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    ObjectInputStream ois = new ObjectInputStream(bais);
    NoInitialContextException exception2 = (NoInitialContextException) ois
        .readObject();
    ois.close();
    bais.close();

    assertEquals(exception.getExplanation(), exception2.getExplanation());
    assertEquals(exception.getResolvedObj(), exception2.getResolvedObj());
    assertEquals(exception.getRemainingName(), exception2
        .getRemainingName());
    assertEquals(exception.getResolvedName(), exception2.getResolvedName());
    assertEquals(exception.getRootCause().getMessage(), exception2
        .getRootCause().getMessage());
    assertEquals(exception.getRootCause().getClass(), exception2
        .getRootCause().getClass());
  }
View Full Code Here

    ObjectInputStream ois = new ObjectInputStream(
                getClass()
                        .getClassLoader()
                        .getResourceAsStream(
                                "/serialization/javax/naming/NoInitialContextException.ser"));
    NoInitialContextException exception2 = (NoInitialContextException) ois
        .readObject();
    ois.close();

    NoInitialContextException exception = new NoInitialContextException(
        "Test exception Serializable: NoInitialContextException");
    exception.setRemainingName(new CompositeName("www.apache.org/foundation"));
    exception.setResolvedName(new CompositeName(
        "http://www.apache.org/index.html"));
    exception.setResolvedObj("This is a string object.");
    exception.setRootCause(new NullPointerException("null pointer"));

    assertEquals(exception.getExplanation(), exception2.getExplanation());
    assertEquals(exception.getResolvedObj(), exception2.getResolvedObj());
    assertEquals(exception.getRemainingName(), exception2
        .getRemainingName());
    assertEquals(exception.getResolvedName(), exception2.getResolvedName());
    assertEquals(exception.getRootCause().getMessage(), exception2
        .getRootCause().getMessage());
    assertEquals(exception.getRootCause().getClass(), exception2
        .getRootCause().getClass());
  }
View Full Code Here

                {
                    return (InitialContextFactory) (loadClass(className).newInstance());
                }
                catch (Exception e)
                {
                    NoInitialContextException ne =
                            new NoInitialContextException(
                                    "Cannot instantiate class: " + className);
                    ne.setRootCause(e);
                    throw ne;
                }
            }
        }
        // default case
View Full Code Here

    }

    private static class DefaultGlobalContext extends ContextFlyweight {
        protected Context getContext() throws NoInitialContextException {
            synchronized (GlobalContextManager.class) {
                if (globalContext == null) throw new NoInitialContextException("Global context has not been set");
                return globalContext;
            }
        }
View Full Code Here

                {
                    return (InitialContextFactory) (loadClass(className).newInstance());
                }
                catch (Exception e)
                {
                    NoInitialContextException ne =
                            new NoInitialContextException(
                                    "Cannot instantiate class: " + className);
                    ne.setRootCause(e);
                    throw ne;
                }
            }
        }
        // default case
View Full Code Here

                catch (Exception e) {
                    if (className.startsWith("weblogic.jndi")) {
                        logger.log(Level.INFO, FALL_BACK_INITIAL_CONTEXT_FACTORY,
                                "com.sun.enterprise.naming.impl.SerialInitContextFactory");
                    } else {
                        NoInitialContextException ne =
                                new NoInitialContextException("Cannot instantiate class: " + className);
                        ne.setRootCause(e);
                        throw ne;
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.naming.NoInitialContextException

Copyright © 2018 www.massapicom. 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.