Search in sources :

Example 41 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class BasicBmp2DataSourcesBean method ejbRemove.

/**
 * A container invokes this method before it removes the EJB object
 * that is currently associated with the instance. This method
 * is invoked when a client invokes a remove operation on the
 * enterprise Bean's home interface or the EJB object's remote interface.
 * This method transitions the instance from the ready state to the pool
 * of available instances.
 */
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
    try {
        final InitialContext jndiContext = new InitialContext();
        final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
        final Connection con = ds.getConnection();
        try {
            final PreparedStatement stmt = con.prepareStatement("delete from entity where id = ?");
            try {
                final Integer primaryKey = (Integer) ejbContext.getPrimaryKey();
                stmt.setInt(1, primaryKey.intValue());
                stmt.executeUpdate();
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }
    } catch (final Exception e) {
        e.printStackTrace();
        throw new javax.ejb.EJBException(e);
    }
}
Also used : EJBException(javax.ejb.EJBException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) InitialContext(javax.naming.InitialContext) RemoveException(javax.ejb.RemoveException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) FinderException(javax.ejb.FinderException) DataSource(javax.sql.DataSource)

Example 42 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class RmiIiopCmp2Bean method returnEJBMetaData.

public EJBMetaData returnEJBMetaData() {
    EJBMetaData data = null;
    try {
        final InitialContext ctx = new InitialContext();
        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        data = home.getEJBMetaData();
    } catch (final Exception e) {
        throw new EJBException(e);
    }
    return data;
}
Also used : EJBMetaData(javax.ejb.EJBMetaData) EJBException(javax.ejb.EJBException) InitialContext(javax.naming.InitialContext) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Example 43 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class RmiIiopCmp2Bean method returnEJBObject.

public EJBObject returnEJBObject() {
    EncCmpObject data = null;
    try {
        final InitialContext ctx = new InitialContext();
        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        data = home.create("Test01 CmpBean");
    } catch (final Exception e) {
        throw new EJBException(e);
    }
    return data;
}
Also used : EJBException(javax.ejb.EJBException) InitialContext(javax.naming.InitialContext) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Example 44 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class RmiIiopCmp2Bean method returnEJBHome.

public EJBHome returnEJBHome() {
    EJBHome data = null;
    try {
        final InitialContext ctx = new InitialContext();
        data = (EJBHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
    } catch (final Exception e) {
        e.printStackTrace();
        throw new EJBException(e);
    }
    return data;
}
Also used : EJBHome(javax.ejb.EJBHome) EJBException(javax.ejb.EJBException) InitialContext(javax.naming.InitialContext) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Example 45 with EJBException

use of javax.ejb.EJBException in project tomee by apache.

the class RmiIiopCmp2Bean method returnNestedEJBMetaData.

public ObjectGraph returnNestedEJBMetaData() {
    ObjectGraph data = null;
    try {
        final InitialContext ctx = new InitialContext();
        final EncCmpHome home = (EncCmpHome) ctx.lookup("java:comp/env/cmp/rmi-iiop/home");
        final EJBMetaData object = home.getEJBMetaData();
        data = new ObjectGraph(object);
    } catch (final Exception e) {
        throw new EJBException(e);
    }
    return data;
}
Also used : EJBMetaData(javax.ejb.EJBMetaData) ObjectGraph(org.apache.openejb.test.object.ObjectGraph) EJBException(javax.ejb.EJBException) InitialContext(javax.naming.InitialContext) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Aggregations

EJBException (javax.ejb.EJBException)169 CreateException (javax.ejb.CreateException)51 RemoteException (java.rmi.RemoteException)45 RemoveException (javax.ejb.RemoveException)40 InitialContext (javax.naming.InitialContext)40 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)37 SystemException (javax.transaction.SystemException)37 FinderException (javax.ejb.FinderException)30 InvocationTargetException (java.lang.reflect.InvocationTargetException)24 OpenEJBException (org.apache.openejb.OpenEJBException)24 EJBObject (javax.ejb.EJBObject)18 NoSuchEntityException (javax.ejb.NoSuchEntityException)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 EjbInvocation (com.sun.ejb.EjbInvocation)14 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)14 IllegalLoopbackException (javax.ejb.IllegalLoopbackException)14 NamingException (javax.naming.NamingException)14 NotSerializableException (java.io.NotSerializableException)13 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)13