Example usage for org.hibernate MappingNotFoundException getPath

List of usage examples for org.hibernate MappingNotFoundException getPath

Introduction

In this page you can find the example usage for org.hibernate MappingNotFoundException getPath.

Prototype

public String getPath() 

Source Link

Usage

From source file:org.broadleafcommerce.common.util.sql.HibernateToolTask.java

License:Apache License

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 {/*  w w w .  j a  v  a 2s.co  m*/
            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;
}