use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method createEJBObjectImpl.
/**
* This is called from the generated "HelloEJBHomeImpl" create method
* via EJBHomeImpl.createEJBObject.
* Note: for stateful beans, the HelloEJBHomeImpl.create calls
* ejbCreate on the new bean after createEJBObject() returns.
* Return the EJBObject for the bean.
*/
protected EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException {
try {
SessionContextImpl context = createBeanInstance();
EJBObjectImpl ejbObjImpl = createEJBObjectImpl(context);
afterInstanceCreation(context);
return ejbObjImpl;
} catch (Exception ex) {
_logger.log(Level.WARNING, CREATE_EJBOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
if (ex instanceof EJBException)
throw (EJBException) ex;
else {
CreateException ce = new CreateException("ERROR creating stateful SessionBean");
ce.initCause(ex);
throw ce;
}
}
}
use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method createEJBLocalObjectImpl.
/**
* This is called from the generated "HelloEJBLocalHomeImpl" create method
* via EJBLocalHomeImpl.createEJBObject.
* Note: for stateful beans, the HelloEJBLocalHomeImpl.create calls
* ejbCreate on the new bean after createEJBLocalObjectImpl() returns.
* Return the EJBLocalObject for the bean.
*/
protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException {
try {
SessionContextImpl context = createBeanInstance();
EJBLocalObjectImpl localObjImpl = createEJBLocalObjectImpl(context);
afterInstanceCreation(context);
return localObjImpl;
} catch (Exception ex) {
_logger.log(Level.WARNING, CREATE_EJBLOCALOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
if (ex instanceof EJBException)
throw (EJBException) ex;
else {
CreateException ce = new CreateException("ERROR creating stateful SessionBean");
ce.initCause(ex);
throw ce;
}
}
}
use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method getEJBLocalBusinessObjectImpl.
EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object sessionKey) {
// Create an EJBLocalObject reference which
// is *not* associated with a SessionContext. That way, the
// session bean context lookup will be done lazily whenever
// the reference is actually accessed. This avoids I/O in the
// case that the reference points to a passivated session bean.
// It's also consistent with the deserialization approach used
// throughout the container. e.g. a timer reference is deserialized
// from its handle without checking it against the timer database.
EJBLocalObjectImpl localBusinessObjImpl;
try {
localBusinessObjImpl = instantiateEJBLocalBusinessObjectImpl();
localBusinessObjImpl.setKey(sessionKey);
} catch (Exception ex) {
EJBException ejbEx = new EJBException();
ejbEx.initCause(ex);
throw ejbEx;
}
return localBusinessObjImpl;
}
use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method createEJBLocalBusinessObjectImpl.
/**
* Internal creation event for Local Business view of SFSB
*/
EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(boolean localBeanView) throws CreateException {
try {
SessionContextImpl context = createBeanInstance();
EJBLocalObjectImpl localBusinessObjImpl = localBeanView ? createOptionalEJBLocalBusinessObjectImpl(context) : createEJBLocalBusinessObjectImpl(context);
afterInstanceCreation(context);
return localBusinessObjImpl;
} catch (Exception ex) {
_logger.log(Level.WARNING, CREATE_EJBLOCALOBJECT_EXCEPTION, new Object[] { ejbDescriptor.getName(), ex });
if (ex instanceof EJBException)
throw (EJBException) ex;
else {
CreateException ce = new CreateException("ERROR creating stateful SessionBean");
ce.initCause(ex);
throw ce;
}
}
}
use of javax.ejb.EJBException in project Payara by payara.
the class AsynchronousTask method validateEMForClientTx.
@Override
protected void validateEMForClientTx(EjbInvocation inv, JavaEETransaction clientJ2EETx) throws EJBException {
SessionContextImpl sessionCtx = (SessionContextImpl) inv.context;
Map<EntityManagerFactory, PhysicalEntityManagerWrapper> entityManagerMap = sessionCtx.getExtendedEntityManagerMap();
for (Map.Entry<EntityManagerFactory, PhysicalEntityManagerWrapper> entry : entityManagerMap.entrySet()) {
EntityManagerFactory emf = entry.getKey();
// Extended persistence context for the propagated transaction.
if (clientJ2EETx.getTxEntityManagerResource(emf) != null) {
throw new EJBException("There is an active transactional persistence context for the same EntityManagerFactory as the current stateful session bean's extended persistence context");
}
// Now see if there's already a *different* extended
// persistence context within this transaction for the
// same EntityManagerFactory.
PhysicalEntityManagerWrapper physicalEM = (PhysicalEntityManagerWrapper) clientJ2EETx.getExtendedEntityManagerResource(emf);
if ((physicalEM != null) && entry.getValue().getEM() != physicalEM.getEM()) {
throw new EJBException("Detected two different extended persistence contexts for the same EntityManagerFactory within a transaction");
}
}
}
Aggregations