); error.append( ": " ).append( propertyKey ).append( " " ).append( value ); throw new PersistenceException( getExceptionHeader() + error.toString() );
private Class getSessionInterceptorClass(Properties properties) { String sessionInterceptorClassname = (String) properties.get( AvailableSettings.SESSION_INTERCEPTOR ); if ( StringHelper.isNotEmpty( sessionInterceptorClassname ) ) { try { Class interceptorClass = ReflectHelper.classForName( sessionInterceptorClassname, Ejb3Configuration.class ); interceptorClass.newInstance(); return interceptorClass; } catch (ClassNotFoundException e) { throw new PersistenceException( getExceptionHeader() + "Unable to load " + AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } catch (IllegalAccessException e) { throw new PersistenceException( getExceptionHeader() + "Unable to instanciate " + AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } catch (InstantiationException e) { throw new PersistenceException( getExceptionHeader() + "Unable to instanciate " + AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } } return null; }
private void addSecurity(List<String> keys, Map properties, Map workingVars) { log.debug( "Adding security" ); if ( !properties.containsKey( HibernatePersistence.JACC_CONTEXT_ID ) ) { throw new PersistenceException( getExceptionHeader() + "Entities have been configured for JACC, but " + HibernatePersistence.JACC_CONTEXT_ID + " has not been set" ); } String contextId = (String) properties.get( HibernatePersistence.JACC_CONTEXT_ID ); setProperty( Environment.JACC_CONTEXTID, contextId ); int roleStart = HibernatePersistence.JACC_PREFIX.length() + 1; for ( String key : keys ) { JACCConfiguration jaccCfg = new JACCConfiguration( contextId ); try { String role = key.substring( roleStart, key.indexOf( '.', roleStart ) ); int classStart = roleStart + role.length() + 1; String clazz = key.substring( classStart, key.length() ); String actions = (String) properties.get( key ); jaccCfg.addPermission( role, clazz, actions ); } catch (IndexOutOfBoundsException e) { throw new PersistenceException( getExceptionHeader() + "Illegal usage of " + HibernatePersistence.JACC_PREFIX + ": " + key ); } } }
getExceptionHeader() + "Unable to find " + classDescription + " class: " + className, e ); getExceptionHeader() + "Unable to access " + classDescription + " class: " + className, e ); getExceptionHeader() + "Unable to instantiate " + classDescription + " class: " + className, e ); getExceptionHeader() + classDescription + " class does not implement " + objectClass + " interface: " + className, e );
private Class getSessionInterceptorClass(Properties properties) { String sessionInterceptorClassname = (String) properties.get( HibernatePersistence.SESSION_INTERCEPTOR ); if ( StringHelper.isNotEmpty( sessionInterceptorClassname ) ) { try { Class interceptorClass = ReflectHelper.classForName( sessionInterceptorClassname, Ejb3Configuration.class ); interceptorClass.newInstance(); return interceptorClass; } catch (ClassNotFoundException e) { throw new PersistenceException( getExceptionHeader() + "Unable to load " + HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } catch (IllegalAccessException e) { throw new PersistenceException( getExceptionHeader() + "Unable to instanciate " + HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } catch (InstantiationException e) { throw new PersistenceException( getExceptionHeader() + "Unable to instanciate " + HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e); } } else { return null; } }
); error.append( ": " ).append( propertyKey ).append( " " ).append( value ); throw new PersistenceException( getExceptionHeader() + error.toString() );
private void defineTransactionType(Object overridenTxType, Map workingVars) { if ( overridenTxType == null ) { // if ( transactionType == null ) { // transactionType = PersistenceUnitTransactionType.JTA; //this is the default value // } //nothing to override } else if ( overridenTxType instanceof String ) { transactionType = PersistenceXmlLoader.getTransactionType( (String) overridenTxType ); } else if ( overridenTxType instanceof PersistenceUnitTransactionType ) { transactionType = (PersistenceUnitTransactionType) overridenTxType; } else { throw new PersistenceException( getExceptionHeader() + AvailableSettings.TRANSACTION_TYPE + " of the wrong class type" + ": " + overridenTxType.getClass() ); } }
private void defineTransactionType(Object overridenTxType, Map workingVars) { if ( overridenTxType == null ) { // if ( transactionType == null ) { // transactionType = PersistenceUnitTransactionType.JTA; //this is the default value // } //nothing to override } else if ( overridenTxType instanceof String ) { transactionType = PersistenceXmlLoader.getTransactionType( (String) overridenTxType ); } else if ( overridenTxType instanceof PersistenceUnitTransactionType ) { transactionType = (PersistenceUnitTransactionType) overridenTxType; } else { throw new PersistenceException( getExceptionHeader() + HibernatePersistence.TRANSACTION_TYPE + " of the wrong class type" + ": " + overridenTxType.getClass() ); } }
throw new PersistenceException( getExceptionHeader(workingVars) + "Unable to find XML mapping file in classpath: " + xmlFile); throw new PersistenceException( getExceptionHeader(workingVars) + "Error while reading JPA XML file: " + xmlFile, me); log.info( getExceptionHeader( workingVars ) + META_INF_ORM_XML + " found");
private void addSecurity(List<String> keys, Map properties, Map workingVars) { LOG.debugf("Adding security"); if ( !properties.containsKey( AvailableSettings.JACC_CONTEXT_ID ) ) { throw new PersistenceException( getExceptionHeader() + "Entities have been configured for JACC, but " + AvailableSettings.JACC_CONTEXT_ID + " has not been set" ); } String contextId = (String) properties.get( AvailableSettings.JACC_CONTEXT_ID ); setProperty( Environment.JACC_CONTEXTID, contextId ); int roleStart = AvailableSettings.JACC_PREFIX.length() + 1; for ( String key : keys ) { JACCConfiguration jaccCfg = new JACCConfiguration( contextId ); try { String role = key.substring( roleStart, key.indexOf( '.', roleStart ) ); int classStart = roleStart + role.length() + 1; String clazz = key.substring( classStart, key.length() ); String actions = (String) properties.get( key ); jaccCfg.addPermission( role, clazz, actions ); } catch (IndexOutOfBoundsException e) { throw new PersistenceException( getExceptionHeader() + "Illegal usage of " + AvailableSettings.JACC_PREFIX + ": " + key ); } } }
public EntityManagerFactory buildEntityManagerFactory(BootstrapServiceRegistryBuilder builder) { Thread thread = null; ClassLoader contextClassLoader = null; if ( overridenClassLoader != null ) { thread = Thread.currentThread(); contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( overridenClassLoader ); } try { final ServiceRegistry serviceRegistry = buildLifecycleControledServiceRegistry( builder ); return new EntityManagerFactoryImpl( transactionType, discardOnClose, getSessionInterceptorClass( cfg.getProperties() ), cfg, serviceRegistry, persistenceUnitName ); } catch (HibernateException e) { throw new PersistenceException( getExceptionHeader() + "Unable to build EntityManagerFactory", e ); } finally { if (thread != null) { thread.setContextClassLoader( contextClassLoader ); } } }
throw new PersistenceException( getExceptionHeader() + "Unable to find XML mapping file in classpath: " + xmlFile); throw new PersistenceException( getExceptionHeader() + "Error while reading JPA XML file: " + xmlFile, me); log.info( "{} {} found", getExceptionHeader(), META_INF_ORM_XML); log.info( "{} No {} found", getExceptionHeader(), META_INF_ORM_XML);
public EntityManagerFactory buildEntityManagerFactory() { Thread thread = null; ClassLoader contextClassLoader = null; if (overridenClassLoader != null) { thread = Thread.currentThread(); contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( overridenClassLoader ); } try { configure( (Properties)null, null ); NamingHelper.bind(this); return new EntityManagerFactoryImpl( cfg.buildSessionFactory(), transactionType, discardOnClose, getSessionInterceptorClass( cfg.getProperties() ) ); } catch (HibernateException e) { throw new PersistenceException( getExceptionHeader() + "Unable to build EntityManagerFactory", e ); } finally { if (thread != null) { thread.setContextClassLoader( contextClassLoader ); } } }
public Ejb3Configuration configure(String resource) throws HibernateException { Thread thread = null; ClassLoader contextClassLoader = null; if (overridenClassLoader != null) { thread = Thread.currentThread(); contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( overridenClassLoader ); } try { Properties properties = new Properties(); properties.setProperty( HibernatePersistence.CFG_FILE, resource); configure( properties, new HashMap() ); return this; } finally { if (thread != null) thread.setContextClassLoader( contextClassLoader ); } }
throw new PersistenceException( getExceptionHeader() + "Unable to find XML mapping file in classpath: " + xmlFile); throw new PersistenceException( getExceptionHeader() + "Error while reading JPA XML file: " + xmlFile, me); LOG.exceptionHeaderFound(getExceptionHeader(), META_INF_ORM_XML); LOG.exceptionHeaderNotFound(getExceptionHeader(), META_INF_ORM_XML);
getExceptionHeader() + "Unable to find interceptor class: " + interceptorName, e ); getExceptionHeader() + "Unable to access interceptor class: " + interceptorName, e ); getExceptionHeader() + "Unable to instanciate interceptor class: " + interceptorName, e ); getExceptionHeader() + "Interceptor class does not implement Interceptor interface: " + interceptorName, e ); getExceptionHeader() + "Unable to find naming strategy class: " + namingStrategyName, e ); getExceptionHeader() + "Unable to access naming strategy class: " + namingStrategyName, e ); getExceptionHeader() + "Unable to instanciate naming strategy class: " + namingStrategyName, e ); getExceptionHeader() + "Naming strategyy class does not implement NmaingStrategy interface: " + namingStrategyName,
private void addNamedAnnotatedClasses( Ejb3Configuration cfg, Collection<String> classNames, Map workingVars ) { for ( String name : classNames ) { try { Class clazz = classForName( name ); cfg.addAnnotatedClass( clazz ); } catch (ClassNotFoundException cnfe) { Package pkg; try { pkg = classForName( name + ".package-info" ).getPackage(); } catch (ClassNotFoundException e) { pkg = null; } if ( pkg == null ) { throw new PersistenceException( getExceptionHeader() + "class or package not found", cnfe ); } else { cfg.addPackage( name ); } } } }
private void addNamedAnnotatedClasses( Ejb3Configuration cfg, Collection<String> classNames, Map workingVars ) { for ( String name : classNames ) { try { Class clazz = classForName( name ); cfg.addAnnotatedClass( clazz ); } catch (ClassNotFoundException cnfe) { Package pkg; try { pkg = classForName( name + ".package-info" ).getPackage(); } catch (ClassNotFoundException e) { pkg = null; } if (pkg == null) throw new PersistenceException(getExceptionHeader() + "class or package not found", cnfe); else cfg.addPackage(name); } } }
throw new PersistenceException( getExceptionHeader() + "Unable to configure EntityManagerFactory", e );
throw new PersistenceException( getExceptionHeader() + "Unable to configure EntityManagerFactory", e );