Package org.hibernate.search.exception

Examples of org.hibernate.search.exception.SearchException


        typeMetadataBuilder.addProperty( propertyMetadataBuilder.build() );
      }
    }
    if ( ( fieldAnnotation == null && idAnn == null ) && numericFieldAnnotation != null ) {
      throw new SearchException( "@NumericField without a @Field on property '" + member.getName() + "'" );
    }
  }
View Full Code Here


                configContext.getServiceManager()
            );
        transientAnnotation = member.getAnnotation( transientAnnotationClass );
      }
      catch (ClassLoadingException e) {
        throw new SearchException( "Unable to load @Transient.class even though it should be present ?!" );
      }
      return transientAnnotation != null;
    }
  }
View Full Code Here

    Object instance;
    try {
      instance = classToLoad.newInstance();
    }
    catch (IllegalAccessException e) {
      throw new SearchException(
          "Unable to instantiate " + componentDescription + " class: " + classToLoad.getName() +
              ". Class or constructor is not accessible.", e
      );
    }
    catch (InstantiationException e) {
      throw new SearchException(
          "Unable to instantiate " + componentDescription + " class: " + classToLoad.getName() +
              ". Verify it has a no-args public constructor and is not abstract.", e
      );
    }
    return verifySuperTypeCompatibility( targetSuperType, instance, classToLoad, componentDescription );
View Full Code Here

  @SuppressWarnings("unchecked")
  private static <T> T verifySuperTypeCompatibility(Class<T> targetSuperType, Object instance, Class<?> classToLoad, String componentDescription) {
    if ( !targetSuperType.isInstance( instance ) ) {
      // have a proper error message according to interface implementation or subclassing
      if ( targetSuperType.isInterface() ) {
        throw new SearchException(
            "Wrong configuration of " + componentDescription + ": class " + classToLoad.getName()
                + " does not implement interface " + targetSuperType.getName()
        );
      }
      else {
        throw new SearchException(
            "Wrong configuration of " + componentDescription + ": class " + classToLoad.getName()
                + " is not a subtype of " + targetSuperType.getName()
        );
      }
    }
View Full Code Here

    final Object instance;
    try {
      instance = singleMapConstructor.newInstance( constructorParameter );
    }
    catch (Exception e) {
      throw new SearchException(
          "Unable to instantiate " + componentDescription + " class: " + classToLoad.getName() +
              ". The implementation class did not recognize the applied parameters.", e
      );
    }
    return verifySuperTypeCompatibility( targetSuperType, instance, classToLoad, componentDescription );
View Full Code Here

      }
      catch (NoSuchMethodException nsme) {
        StringBuilder msg = new StringBuilder( "Unable to instantiate analyzer class: " );
        msg.append( classToInstantiate.getName() );
        msg.append( ". Class neither has a default constructor nor a constructor with a Version parameter" );
        throw new SearchException( msg.toString(), e );
      }
    }

    try {
      if ( useVersionParameter ) {
        analyzerInstance = (Analyzer) constructor.newInstance( luceneMatchVersion );
      }
      else {
        analyzerInstance = (Analyzer) constructor.newInstance();
      }
    }
    catch (IllegalAccessException e) {
      throw new SearchException(
          "Unable to instantiate analyzer class: " + classToInstantiate.getName() +
              ". Class or constructor is not accessible.", e
      );
    }
    catch (InstantiationException e) {
      throw new SearchException(
          "Unable to instantiate analyzer class: " + classToInstantiate.getName() +
              ". Verify it has a no-args public constructor and is not abstract.", e
      );
    }
    catch (InvocationTargetException e) {
      throw new SearchException(
          "Unable to instantiate analyzer class: " + classToInstantiate.getName() +
              ". Verify it has a no-args public constructor and is not abstract."
              + " Also Analyzer implementation classes or their tokenStream() and reusableTokenStream() implementations must be final.",
          e
      );
View Full Code Here

    return analyzerInstance;
  }

  private static void checkClassType(Class<?> classToLoad, String componentDescription) {
    if ( classToLoad.isInterface() ) {
      throw new SearchException(
          classToLoad.getName() + " defined for component " + componentDescription
              + " is an interface: implementation required."
      );
    }
  }
View Full Code Here

  private static void checkHasNoArgConstructor(Class<?> classToLoad, String componentDescription) {
    try {
      classToLoad.getConstructor();
    }
    catch (SecurityException e) {
      throw new SearchException(
          classToLoad.getName() + " defined for component " + componentDescription
              + " could not be instantiated because of a security manager error", e
      );
    }
    catch (NoSuchMethodException e) {
      throw new SearchException(
          classToLoad.getName() + " defined for component " + componentDescription
              + " is missing a no-arguments constructor"
      );
    }
  }
View Full Code Here

  private static Constructor<?> getSingleMapConstructor(Class<?> classToLoad, String componentDescription) {
    try {
      return classToLoad.getConstructor( Map.class );
    }
    catch (SecurityException e) {
      throw new SearchException(
          classToLoad.getName() + " defined for component " + componentDescription
              + " could not be instantiated because of a security manager error", e
      );
    }
    catch (NoSuchMethodException e) {
      throw new SearchException(
          classToLoad.getName() + " defined for component " + componentDescription
              + " is missing an appropriate constructor: expected a public constructor with a single parameter of type Map"
      );
    }
  }
View Full Code Here

    ClassLoaderService classLoaderService = serviceManager.requestService( ClassLoaderService.class );
    try {
      clazz = classLoaderService.classForName( classNameToLoad );
    }
    catch (ClassLoadingException e) {
      throw new SearchException(
          "Unable to find " + componentDescription +
              " implementation class: " + classNameToLoad, e
      );
    }
    finally {
View Full Code Here

TOP

Related Classes of org.hibernate.search.exception.SearchException

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.