Java 类javax.ejb.TransactionRolledbackLocalException 实例源码
项目:swan
文件:Service.java
public void removeDocument(Document entity) throws CreateException {
try {
entity.removeDefaultAnnotations();
documentDAO.merge(entity);
linkDAO.removeAllLinksByDocId(entity.getId());
annotationDAO.removeAllAnnotationsByDocId(entity);
stateDAO.removeAllStatesByDocId(entity.getId());
Project project = entity.getProject();
documentDAO.remove(entity);
project.removeDocuments(entity);
projectDAO.merge(project);
} catch (NoResultException | TransactionRolledbackLocalException e) {
throw new CreateException(e.getMessage());
}
}
项目:tomee
文件:ManyToManyComplexPkTests.java
public void testSetCmrNull() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
} catch (final TransactionRolledbackLocalException e) {
final Throwable cause = e.getCause();
assertNotNull("cause is null", cause);
assertTrue("cause is not a instance of IllegalArgumentException", cause instanceof IllegalArgumentException);
}
} finally {
completeTransaction();
}
}
项目:tomee
文件:ManyToManyTests.java
public void testSetCmrNull() throws Exception {
resetDB();
beginTransaction();
try {
final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
} catch (final TransactionRolledbackLocalException e) {
final Throwable cause = e.getCause();
assertNotNull("cause is null", cause);
assertTrue("cause is not a instance of IllegalArgumentException", cause instanceof IllegalArgumentException);
}
} finally {
completeTransaction();
}
}
项目:tomee
文件:EJBInvocationHandler.java
/**
* Renamed method so it shows up with a much more understandable purpose as it
* will be the top element in the stacktrace
*
* @param e Throwable
* @param method Method
*/
protected Throwable convertException(final Throwable e, final Method method) {
if (!remote && e instanceof RemoteException) {
if (e instanceof TransactionRequiredException) {
return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e));
}
if (e instanceof TransactionRolledbackException) {
return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e));
}
/**
* If a client attempts to invoke a method on a removed bean's business interface,
* we must throw a javax.ejb.NoSuchEJBException. If the business interface is a
* remote business interface that extends java.rmi.Remote, the
* java.rmi.NoSuchObjectException is thrown to the client instead.
* See EJB 3.0, section 4.4
*/
if (e instanceof NoSuchObjectException) {
if (java.rmi.Remote.class.isAssignableFrom(method.getDeclaringClass())) {
return e;
} else {
return new NoSuchEJBException(e.getMessage()).initCause(getCause(e));
}
}
if (e instanceof AccessException) {
return new AccessLocalException(e.getMessage()).initCause(getCause(e));
}
return new EJBException(e.getMessage()).initCause(getCause(e));
}
if (remote && e instanceof EJBAccessException) {
if (e.getCause() instanceof Exception) {
return new AccessException(e.getMessage(), (Exception) e.getCause());
} else {
return new AccessException(e.getMessage());
}
}
if (!remote && e instanceof EJBTransactionRolledbackException) {
return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e));
}
return e;
}
项目:tomee
文件:BaseEjbProxyHandler.java
/**
* Renamed method so it shows up with a much more understandable purpose as it
* will be the top element in the stacktrace
*
* @param e Throwable
* @param method Method
* @param interfce Class
*/
protected Throwable convertException(Throwable e, final Method method, final Class interfce) {
final boolean rmiRemote = Remote.class.isAssignableFrom(interfce);
if (e instanceof TransactionRequiredException) {
if (!rmiRemote && interfaceType.isBusiness()) {
return new EJBTransactionRequiredException(e.getMessage()).initCause(getCause(e));
} else if (interfaceType.isLocal()) {
return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e));
} else {
return e;
}
}
if (e instanceof TransactionRolledbackException) {
if (!rmiRemote && interfaceType.isBusiness()) {
return new EJBTransactionRolledbackException(e.getMessage()).initCause(getCause(e));
} else if (interfaceType.isLocal()) {
return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e));
} else {
return e;
}
}
if (e instanceof NoSuchObjectException) {
if (!rmiRemote && interfaceType.isBusiness()) {
return new NoSuchEJBException(e.getMessage()).initCause(getCause(e));
} else if (interfaceType.isLocal()) {
return new NoSuchObjectLocalException(e.getMessage()).initCause(getCause(e));
} else {
return e;
}
}
if (e instanceof AccessException) {
if (!rmiRemote && interfaceType.isBusiness()) {
return new AccessLocalException(e.getMessage()).initCause(getCause(e));
} else if (interfaceType.isLocal()) {
return new AccessLocalException(e.getMessage()).initCause(getCause(e));
} else {
return e;
}
}
if (e instanceof RemoteException) {
if (!rmiRemote && interfaceType.isBusiness()) {
return new EJBException(e.getMessage()).initCause(getCause(e));
} else if (interfaceType.isLocal()) {
return new EJBException(e.getMessage()).initCause(getCause(e));
} else {
return e;
}
}
for (final Class<?> type : method.getExceptionTypes()) {
if (type.isAssignableFrom(e.getClass())) {
return e;
}
}
// Exception is undeclared
// Try and find a runtime exception in there
while (e.getCause() != null && !(e instanceof RuntimeException)) {
e = e.getCause();
}
return e;
}