/** * Creates a CacheException, but doesn't pass JBC CacheException as the cause * as it is a type that likely doesn't exist on a client. * Instead creates a Hibernate CacheException with the original exception's * stack trace. */ public static CacheException convertToHibernateException(Exception e) { CacheException he = null; if (e.getClass().getName().equals(CACHE_EXCEPTION) || e.getClass().getSuperclass().getName().equals(CACHE_EXCEPTION)) { he = new CacheException(e.getClass().getName() + " " + e.getMessage()); he.setStackTrace(e.getStackTrace()); } else if (e instanceof CacheException) { he = (CacheException) e; } else { he = new CacheException(e); } return he; }
@Override public final CacheException pendingPutsMustNotBeClustered() { final CacheException result = new CacheException(String.format(getLoggingLocale(), pendingPutsMustNotBeClustered$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String pendingPutsMustNotBeTransactional = "HHH025002: Pending-puts cache must not be transactional!";
@Override public final CacheException cannotSuspendTx(final SystemException se) { final CacheException result = new CacheException(String.format(getLoggingLocale(), cannotSuspendTx$str()), se); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotResumeTx = "HHH025022: Could not resume transaction";
@Override public final CacheException unableToStart(final Throwable t) { final CacheException result = new CacheException(String.format(getLoggingLocale(), unableToStart$str()), t); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String unableToCreateCacheManager = "HHH025010: Unable to create default cache manager";
@Override public final CacheException cannotInstallCommandFactory() { final CacheException result = new CacheException(String.format(getLoggingLocale(), cannotInstallCommandFactory$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final CacheException failedInvalidatePendingPut(final Object key, final String regionName) { final CacheException result = new CacheException(String.format(getLoggingLocale(), failedInvalidatePendingPut$str(), key, regionName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final CacheException pendingPutsMustHaveMaxIdle() { final CacheException result = new CacheException(String.format(getLoggingLocale(), pendingPutsMustHaveMaxIdle$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final CacheException timestampsMustNotUseEviction() { final CacheException result = new CacheException(String.format(getLoggingLocale(), timestampsMustNotUseEviction$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String unableToStart = "HHH025009: Unable to start region factory";
@Override public final CacheException unableToRetrieveCmFromJndi(final String jndiNamespace) { final CacheException result = new CacheException(String.format(getLoggingLocale(), unableToRetrieveCmFromJndi$str(), jndiNamespace)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final CacheException cannotGetCurrentTx(final SystemException e) { final CacheException result = new CacheException(String.format(getLoggingLocale(), cannotGetCurrentTx$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedInvalidatePendingPut = "HHH025024: Failed to invalidate pending putFromLoad calls for key %s from region %s";
@Override public final CacheException pendingPutsMustNotBeTransactional() { final CacheException result = new CacheException(String.format(getLoggingLocale(), pendingPutsMustNotBeTransactional$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final CacheException unableToCreateCacheManager(final Throwable t) { final CacheException result = new CacheException(String.format(getLoggingLocale(), unableToCreateCacheManager$str()), t); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotInstallCommandFactory = "HHH025011: Infinispan custom cache command factory not installed (possibly because the classloader where Infinispan lives couldn't find the Hibernate Infinispan cache provider)";
@Override public final CacheException cannotResumeTx(final Exception e) { final CacheException result = new CacheException(String.format(getLoggingLocale(), cannotResumeTx$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotGetCurrentTx = "HHH025023: Unable to get current transaction";
@Override public final CacheException propertyCacheManagerResourceNotSet() { final CacheException result = new CacheException(String.format(getLoggingLocale(), propertyCacheManagerResourceNotSet$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String timestampsMustNotUseInvalidation = "HHH025027: Timestamp cache cannot be configured with invalidation";
@Override public final CacheException timestampsMustNotUseInvalidation() { final CacheException result = new CacheException(String.format(getLoggingLocale(), timestampsMustNotUseInvalidation$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override