use of javax.ejb.EJBException in project tomee by apache.
the class RmiIiopCmp2Bean method returnHandle.
public Handle returnHandle() {
Handle data = null;
try {
final InitialContext ctx = new InitialContext();
final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
final EncCmpObject object = home.create("Test03 CmpBean");
data = object.getHandle();
} catch (final Exception e) {
throw new EJBException(e);
}
return data;
}
use of javax.ejb.EJBException in project Payara by payara.
the class AbstractSingletonContainer method _getContext.
@Override
protected ComponentContext _getContext(EjbInvocation invocation) throws EJBException {
checkInit();
if (clusteredLookup.isClusteredEnabled()) {
AbstractSessionContextImpl sessionContext = (AbstractSessionContextImpl) singletonCtx;
try {
invocationManager.preInvoke(invocation);
invocation.context = sessionContext;
sessionContext.setEJB(clusteredLookup.getClusteredSingletonMap().get(clusteredLookup.getClusteredSessionKey()));
if (isJCDIEnabled()) {
if (sessionContext.getJCDIInjectionContext() != null) {
sessionContext.getJCDIInjectionContext().cleanup(false);
}
sessionContext.setJCDIInjectionContext(_createJCDIInjectionContext(sessionContext, sessionContext.getEJB()));
}
if (sessionContext.getEJB() != null) {
injectEjbInstance(sessionContext);
}
} catch (Exception ex) {
throw new EJBException(ex);
} finally {
invocation.context = null;
invocationManager.postInvoke(invocation);
}
}
return singletonCtx;
}
use of javax.ejb.EJBException in project Payara by payara.
the class SafeProperties method getJaccEjb.
/**
* Called-back from security implementation through EjbInvocation
* when a jacc policy provider wants an enterprise bean instance.
*/
public Object getJaccEjb(EjbInvocation inv) {
Object bean = null;
// Remote , Local, and ServiceEndpoint interfaces.
if (((inv.invocationInfo != null) && inv.invocationInfo.isBusinessMethod) || inv.isWebService) {
// twice within the same authorization decision.
if (inv.context == null) {
try {
inv.context = getContext(inv);
bean = inv.context.getEJB();
// NOTE : inv.ejb is not set here. Post-invoke logic for
// BaseContainer and webservices uses the fact that
// inv.ejb is non-null as an indication that that
// BaseContainer.preInvoke() proceeded past a certain
// point, which affects which cleanup needs to be
// performed. It would be better to have explicit
// state in the invocation that says which cleanup
// steps are necessary(e.g. for invocationMgr.postInvoke
// , postInvokeTx, etc) but I'm keeping the logic the
// same for now. BaseContainer.authorize() will
// explicitly handle the case where a context was
// created as a result of this call and the
// authorization failed, which means the context needs
// be released.
} catch (EJBException e) {
_logger.log(Level.WARNING, CONTEXT_FAILURE_JACC, logParams[0]);
_logger.log(Level.WARNING, "", e);
}
} else {
bean = inv.context.getEJB();
}
}
return bean;
}
use of javax.ejb.EJBException in project Payara by payara.
the class SafeProperties method doAfterBegin.
// Implementation of Container method.
// Called from UserTransactionImpl after the EJB started a Tx,
// for TX_BEAN_MANAGED EJBs only.
public final void doAfterBegin(ComponentInvocation ci) {
EjbInvocation inv = (EjbInvocation) ci;
try {
// Associate the context with tx so that on subsequent
// invocations with the same tx, we can do the appropriate
// tx.resume etc.
EJBContextImpl sc = (EJBContextImpl) inv.context;
Transaction tx = transactionManager.getTransaction();
if (!isSingleton) {
sc.setTransaction(tx);
}
// Register Synchronization with TM so that we can
// dissociate the context from tx in afterCompletion
ejbContainerUtilImpl.getContainerSync(tx).addBean(sc);
enlistExtendedEntityManagers(sc);
// Dont call container.afterBegin() because
// TX_BEAN_MANAGED EntityBeans are not allowed,
// and SessionSync calls on TX_BEAN_MANAGED SessionBeans
// are not allowed.
} catch (SystemException ex) {
throw new EJBException(ex);
} catch (RollbackException ex) {
throw new EJBException(ex);
} catch (IllegalStateException ex) {
throw new EJBException(ex);
}
}
use of javax.ejb.EJBException in project Payara by payara.
the class SafeProperties method mapRemoteException.
private Throwable mapRemoteException(EjbInvocation inv) {
Throwable originalException = inv.exception;
Throwable mappedException = originalException;
// 2.x client view.
if (inv.invocationInfo.isAsynchronous()) {
if (java.rmi.Remote.class.isAssignableFrom(inv.clientInterface)) {
mappedException = protocolMgr.mapException(originalException);
if (mappedException == originalException) {
if (originalException instanceof EJBException) {
mappedException = new RemoteException(originalException.getMessage(), originalException);
}
}
} else {
mappedException = mapLocal3xException(originalException);
}
} else {
// Synchronous invocation. First let the protocol manager perform
// its mapping.
mappedException = protocolMgr.mapException(originalException);
// If no mapping happened
if (mappedException == originalException) {
if (inv.isBusinessInterface) {
// client can unwrap it and ensure that the client receives EJBException.
if (originalException instanceof EJBException) {
mappedException = new InternalEJBContainerException(originalException.getMessage(), originalException);
}
} else {
if (originalException instanceof EJBException) {
mappedException = new RemoteException(originalException.getMessage(), originalException);
}
}
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Mapped original remote exception " + originalException + " to exception " + mappedException + " for " + inv);
}
return mappedException;
}
Aggregations