use of org.hibernate.boot.registry.classloading.spi.ClassLoadingException in project hibernate-orm by hibernate.
the class TypeSafeActivator method applyRelationalConstraints.
@SuppressWarnings({ "UnusedDeclaration" })
public static void applyRelationalConstraints(ValidatorFactory factory, Collection<PersistentClass> persistentClasses, Map settings, Dialect dialect, ClassLoaderAccess classLoaderAccess) {
Class<?>[] groupsArray = GroupsPerOperation.buildGroupsForOperation(GroupsPerOperation.Operation.DDL, settings, classLoaderAccess);
Set<Class<?>> groups = new HashSet<Class<?>>(Arrays.asList(groupsArray));
for (PersistentClass persistentClass : persistentClasses) {
final String className = persistentClass.getClassName();
if (className == null || className.length() == 0) {
continue;
}
Class<?> clazz;
try {
clazz = classLoaderAccess.classForName(className);
} catch (ClassLoadingException e) {
throw new AssertionFailure("Entity class not found", e);
}
try {
applyDDL("", persistentClass, clazz, factory, groups, true, dialect);
} catch (Exception e) {
LOG.unableToApplyConstraints(className, e);
}
}
}
use of org.hibernate.boot.registry.classloading.spi.ClassLoadingException in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method checkForOrphanProperties.
private void checkForOrphanProperties(Element tree) {
Class clazz;
try {
clazz = classLoaderAccess.classForName(className);
} catch (ClassLoadingException e) {
//a primitive type most likely
return;
}
Element element = tree != null ? tree.element("attributes") : null;
//put entity.attributes elements
if (element != null) {
//precompute the list of properties
//TODO is it really useful...
Set<String> properties = new HashSet<String>();
for (Field field : clazz.getFields()) {
properties.add(field.getName());
}
for (Method method : clazz.getMethods()) {
String name = method.getName();
if (name.startsWith("get")) {
properties.add(Introspector.decapitalize(name.substring("get".length())));
} else if (name.startsWith("is")) {
properties.add(Introspector.decapitalize(name.substring("is".length())));
}
}
for (Element subelement : (List<Element>) element.elements()) {
String propertyName = subelement.attributeValue("name");
if (!properties.contains(propertyName)) {
LOG.propertyNotFound(StringHelper.qualify(className, propertyName));
}
}
}
}
use of org.hibernate.boot.registry.classloading.spi.ClassLoadingException in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method addTargetClass.
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
String className = element.attributeValue(nodeName);
if (className != null) {
Class clazz;
try {
clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(className, defaults));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find " + element.getPath() + " " + nodeName + ": " + className, e);
}
ad.setValue(getJavaAttributeNameFromXMLOne(nodeName), clazz);
}
}
use of org.hibernate.boot.registry.classloading.spi.ClassLoadingException in project hibernate-orm by hibernate.
the class StandardJtaPlatformResolver method resolveJtaPlatform.
@Override
public JtaPlatform resolveJtaPlatform(Map configurationValues, ServiceRegistryImplementor registry) {
final ClassLoaderService classLoaderService = registry.getService(ClassLoaderService.class);
// Initially look for a JtaPlatformProvider
for (JtaPlatformProvider provider : classLoaderService.loadJavaServices(JtaPlatformProvider.class)) {
final JtaPlatform providedPlatform = provider.getProvidedJtaPlatform();
log.tracef("Located JtaPlatformProvider [%s] provided JtaPlaform : %s", provider, providedPlatform);
if (providedPlatform != null) {
return providedPlatform;
}
}
// JBoss ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
classLoaderService.classForName(JBossStandAloneJtaPlatform.JBOSS_TM_CLASS_NAME);
classLoaderService.classForName(JBossStandAloneJtaPlatform.JBOSS_UT_CLASS_NAME);
// should be relying on that
return new JBossStandAloneJtaPlatform();
} catch (ClassLoadingException ignore) {
}
// Bitronix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
classLoaderService.classForName(BitronixJtaPlatform.TM_CLASS_NAME);
return new BitronixJtaPlatform();
} catch (ClassLoadingException ignore) {
}
// JOnAS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
classLoaderService.classForName(JOnASJtaPlatform.TM_CLASS_NAME);
return new JOnASJtaPlatform();
} catch (ClassLoadingException ignore) {
}
// JOTM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
classLoaderService.classForName(JOTMJtaPlatform.TM_CLASS_NAME);
return new JOTMJtaPlatform();
} catch (ClassLoadingException ignore) {
}
// WebSphere ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (WebSphereJtaPlatform.WebSphereEnvironment webSphereEnvironment : WebSphereJtaPlatform.WebSphereEnvironment.values()) {
try {
Class accessClass = classLoaderService.classForName(webSphereEnvironment.getTmAccessClassName());
return new WebSphereJtaPlatform(accessClass, webSphereEnvironment);
} catch (ClassLoadingException ignore) {
}
}
// Finally, return the default...
log.debugf("Could not resolve JtaPlatform, using default [%s]", NoJtaPlatform.class.getName());
return NoJtaPlatform.INSTANCE;
}
use of org.hibernate.boot.registry.classloading.spi.ClassLoadingException in project hibernate-orm by hibernate.
the class ConstructorNode method resolveConstructor.
private Constructor resolveConstructor(String path) throws SemanticException {
String importedClassName = getSessionFactoryHelper().getImportedClassName(path);
String className = StringHelper.isEmpty(importedClassName) ? path : importedClassName;
if (className == null) {
throw new SemanticException("Unable to locate class [" + path + "]");
}
try {
final Class holderClass = getSessionFactoryHelper().getFactory().getServiceRegistry().getService(ClassLoaderService.class).classForName(className);
return ReflectHelper.getConstructor(holderClass, constructorArgumentTypes);
} catch (ClassLoadingException e) {
throw new DetailedSemanticException("Unable to locate class [" + className + "]", e);
} catch (PropertyNotFoundException e) {
// locate an appropriate constructor
throw new DetailedSemanticException(formatMissingContructorExceptionMessage(className), e);
}
}
Aggregations