Package org.hibernate.service.jndi

Examples of org.hibernate.service.jndi.JndiException


    Name name = parseName( jndiName, initialContext );
    try {
      return initialContext.lookup( name );
    }
    catch ( NamingException e ) {
      throw new JndiException( "Unable to lookup JNDI name [" + jndiName + "]", e );
    }
    finally {
      cleanUp( initialContext );
    }
  }
View Full Code Here


  private InitialContext buildInitialContext() {
    try {
      return initialContextSettings.size() == 0 ? new InitialContext() : new InitialContext( initialContextSettings );
    }
    catch ( NamingException e ) {
      throw new JndiException( "Unable to open InitialContext", e );
    }
  }
View Full Code Here

    }
    catch ( InvalidNameException e ) {
      throw new JndiNameException( "JNDI name [" + jndiName + "] was not valid", e );
    }
    catch ( NamingException e ) {
      throw new JndiException( "Error parsing JNDI name [" + jndiName + "]", e );
    }
  }
View Full Code Here

    }
    catch ( Exception initialException ) {
      // We had problems doing a simple bind operation.
      if ( name.size() == 1 ) {
        // if the jndi name had only 1 component there is nothing more we can do...
        throw new JndiException( "Error performing bind [" + name + "]", initialException );
      }

      // Otherwise, there is a good chance this may have been caused by missing intermediate contexts.  So we
      // attempt to create those missing intermediate contexts and bind again
      Context intermediateContextBase = context;
      while ( name.size() > 1 ) {
        final String intermediateContextName = name.get( 0 );

        Context intermediateContext = null;
        try {
                    LOG.trace("Intermediate lookup: " + intermediateContextName);
          intermediateContext = (Context) intermediateContextBase.lookup( intermediateContextName );
        }
        catch ( NameNotFoundException handledBelow ) {
          // ok as we will create it below if not found
        }
        catch ( NamingException e ) {
          throw new JndiException( "Unanticipated error doing intermediate lookup", e );
        }

                if (intermediateContext != null) LOG.trace("Found intermediate context: " + intermediateContextName);
        else {
                    LOG.trace("Creating sub-context: " + intermediateContextName);
          try {
            intermediateContext = intermediateContextBase.createSubcontext( intermediateContextName );
          }
          catch ( NamingException e ) {
            throw new JndiException( "Error creating intermediate context [" + intermediateContextName + "]", e );
          }
        }
        intermediateContextBase = intermediateContext;
        name = name.getSuffix( 1 );
      }
            LOG.trace("Binding : " + name);
      try {
        intermediateContextBase.rebind( name, value );
      }
      catch ( NamingException e ) {
        throw new JndiException( "Error performing intermediate bind [" + name + "]", e );
      }
    }
        LOG.debugf( "Bound name: %s", name );
  }
View Full Code Here

    Name name = parseName( jndiName, initialContext );
    try {
      initialContext.unbind( name );
    }
    catch (Exception e) {
      throw new JndiException( "Error performing unbind [" + name + "]", e );
    }
    finally {
      cleanUp( initialContext );
    }
  }
View Full Code Here

    Name name = parseName( jndiName, initialContext );
    try {
      ( (EventContext) initialContext ).addNamingListener( name, EventContext.OBJECT_SCOPE, listener );
    }
    catch (Exception e) {
      throw new JndiException( "Unable to bind listener to namespace [" + name + "]", e );
    }
    finally {
      cleanUp( initialContext );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.service.jndi.JndiException

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.