Java 类org.hibernate.MappingNotFoundException 实例源码

项目:lams    文件:Configuration.java   
/**
 * Read mappings as a application resourceName (i.e. classpath lookup)
 * trying different class loaders.
 *
 * @param resourceName The resource name
 * @return this (for method chaining purposes)
 * @throws MappingException Indicates problems locating the resource or
 * processing the contained mapping document.
 */
public Configuration addResource(String resourceName) throws MappingException {
    LOG.readingMappingsFromResource( resourceName );
    ClassLoader contextClassLoader = ClassLoaderHelper.getContextClassLoader();
    InputStream resourceInputStream = null;
    if ( contextClassLoader != null ) {
        resourceInputStream = contextClassLoader.getResourceAsStream( resourceName );
    }
    if ( resourceInputStream == null ) {
        resourceInputStream = Environment.class.getClassLoader().getResourceAsStream( resourceName );
    }
    if ( resourceInputStream == null ) {
        throw new MappingNotFoundException( "resource", resourceName );
    }
    add( resourceInputStream, "resource", resourceName );
    return this;
}
项目:cacheonix-core    文件:Configuration.java   
/**
 * Read mappings as a application resourceName (i.e. classpath lookup)
 * trying different classloaders.
 *
 * @param resourceName The resource name
 * @return this (for method chaining purposes)
 * @throws MappingException Indicates problems locating the resource or
 * processing the contained mapping document.
 */
public Configuration addResource(String resourceName) throws MappingException {
    log.info( "Reading mappings from resource : " + resourceName );
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    InputStream rsrc = null;
    if (contextClassLoader!=null) {
        rsrc = contextClassLoader.getResourceAsStream( resourceName );
    }
    if ( rsrc == null ) {
        rsrc = Environment.class.getClassLoader().getResourceAsStream( resourceName );
    }
    if ( rsrc == null ) {
        throw new MappingNotFoundException( "resource", resourceName );
    }
    try {
        return addInputStream( rsrc );
    }
    catch (MappingException me) {
        throw new InvalidMappingException( "resource", resourceName, me );
    }
}
项目:lams    文件:Configuration.java   
/**
 * Read mappings as a application resource (i.e. classpath lookup).
 *
 * @param resourceName The resource name
 * @param classLoader The class loader to use.
 * @return this (for method chaining purposes)
 * @throws MappingException Indicates problems locating the resource or
 * processing the contained mapping document.
 */
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
    LOG.readingMappingsFromResource( resourceName );
    InputStream resourceInputStream = classLoader.getResourceAsStream( resourceName );
    if ( resourceInputStream == null ) {
        throw new MappingNotFoundException( "resource", resourceName );
    }
    add( resourceInputStream, "resource", resourceName );
    return this;
}
项目:cacheonix-core    文件:Configuration.java   
/**
 * Read mappings as a application resource (i.e. classpath lookup).
 *
 * @param resourceName The resource name
 * @param classLoader The class loader to use.
 * @return this (for method chaining purposes)
 * @throws MappingException Indicates problems locating the resource or
 * processing the contained mapping document.
 */
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
    log.info( "Reading mappings from resource: " + resourceName );
    InputStream rsrc = classLoader.getResourceAsStream( resourceName );
    if ( rsrc == null ) {
        throw new MappingNotFoundException( "resource", resourceName );
    }
    try {
        return addInputStream( rsrc );
    }
    catch (MappingException me) {
        throw new InvalidMappingException( "resource", resourceName, me );
    }
}
项目:metaworks_framework    文件:HibernateToolTask.java   
private String getProbableSolutionOrCause(Throwable re) {
    if(re==null) return null;

    if(re instanceof MappingNotFoundException) {
        MappingNotFoundException mnf = (MappingNotFoundException)re;
        if("resource".equals(mnf.getType())) {
            return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
                    "Check the following:\n" +
                    "\n" +
                    "1) Is the spelling/casing correct ?\n" +
                    "2) Is " + mnf.getPath() + " available via the classpath ?\n" +
                    "3) Does it actually exist ?\n";                        
        } else {
            return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
            "Check the following:\n" +
            "\n" +
            "1) Is the spelling/casing correct ?\n" +
            "2) Do you permission to access " + mnf.getPath() + " ?\n" +
            "3) Does it actually exist ?\n";    
        }
    }

    if(re instanceof ClassNotFoundException || re instanceof NoClassDefFoundError) {

        return "A class were not found in the classpath of the Ant task.\n" +
                "Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.\n";            

    }

    if(re instanceof UnsupportedClassVersionError) {
        return "You are most likely running the ant task with a JRE that is older than the JRE required to use the classes.\n" +
                "e.g. running with JRE 1.3 or 1.4 when using JDK 1.5 annotations is not possible.\n" +
                "Ensure that you are using a correct JRE.";
    }



    if(re.getCause()!=re) {
        return getProbableSolutionOrCause( re.getCause() );                 
    }

    return null;
}
项目:SparkCommerce    文件:HibernateToolTask.java   
private String getProbableSolutionOrCause(Throwable re) {
    if(re==null) return null;

    if(re instanceof MappingNotFoundException) {
        MappingNotFoundException mnf = (MappingNotFoundException)re;
        if("resource".equals(mnf.getType())) {
            return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
                    "Check the following:\n" +
                    "\n" +
                    "1) Is the spelling/casing correct ?\n" +
                    "2) Is " + mnf.getPath() + " available via the classpath ?\n" +
                    "3) Does it actually exist ?\n";                        
        } else {
            return "A " + mnf.getType() + " located at " + mnf.getPath() + " was not found.\n" +
            "Check the following:\n" +
            "\n" +
            "1) Is the spelling/casing correct ?\n" +
            "2) Do you permission to access " + mnf.getPath() + " ?\n" +
            "3) Does it actually exist ?\n";    
        }
    }

    if(re instanceof ClassNotFoundException || re instanceof NoClassDefFoundError) {

        return "A class were not found in the classpath of the Ant task.\n" +
                "Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.\n";            

    }

    if(re instanceof UnsupportedClassVersionError) {
        return "You are most likely running the ant task with a JRE that is older than the JRE required to use the classes.\n" +
                "e.g. running with JRE 1.3 or 1.4 when using JDK 1.5 annotations is not possible.\n" +
                "Ensure that you are using a correct JRE.";
    }



    if(re.getCause()!=re) {
        return getProbableSolutionOrCause( re.getCause() );                 
    }

    return null;
}