Search in sources :

Example 1 with AccessException

use of java.rmi.AccessException in project lar_361 by comitsrl.

the class ALogin method tryConnection.

// defaultsOK
/**
 ************************************************************************
 *	Try to connect.
 *  - Get Connection
 *  - Compare User info
 *  @return true if connected
 */
private boolean tryConnection() {
    m_user = userTextField.getText();
    m_pwd = new String(passwordField.getPassword());
    // Establish connection
    if (!DB.isConnected(false))
        validateConnection();
    if (!DB.isConnected(false)) {
        statusBar.setStatusLine(txt_NoDatabase, true);
        hostField.setBackground(AdempierePLAF.getFieldBackground_Error());
        return false;
    }
    // Reference check
    Ini.setProperty(Ini.P_ADEMPIERESYS, "Reference".equalsIgnoreCase(CConnection.get().getDbUid()));
    // Reference check
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, "Reference".equalsIgnoreCase(CConnection.get().getDbUid()));
    // Get Roles
    m_login = new Login(m_ctx);
    KeyNamePair[] roles = null;
    try {
        roles = m_login.getRoles(m_user, m_pwd);
        if (roles == null || roles.length == 0) {
            statusBar.setStatusLine(txt_UserPwdError, true);
            userTextField.setBackground(AdempierePLAF.getFieldBackground_Error());
            passwordField.setBackground(AdempierePLAF.getFieldBackground_Error());
            return false;
        }
    } catch (Throwable e) {
        if (e.getCause() instanceof AccessException) {
            statusBar.setStatusLine(txt_UserPwdError, true);
            userTextField.setBackground(AdempierePLAF.getFieldBackground_Error());
            passwordField.setBackground(AdempierePLAF.getFieldBackground_Error());
            return false;
        } else {
            log.severe(CLogger.getRootCause(e).getLocalizedMessage());
            statusBar.setStatusLine(CLogger.getRootCause(e).getLocalizedMessage(), true);
            return false;
        }
    }
    // Delete existing role items
    m_comboActive = true;
    if (roleCombo.getItemCount() > 0)
        roleCombo.removeAllItems();
    // Initial role
    KeyNamePair iniValue = null;
    String iniDefault = Ini.getProperty(Ini.P_ROLE);
    // fill roles
    for (int i = 0; i < roles.length; i++) {
        roleCombo.addItem(roles[i]);
        if (roles[i].getName().equals(iniDefault))
            iniValue = roles[i];
    }
    if (iniValue != null)
        roleCombo.setSelectedItem(iniValue);
    // If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
    if (roleCombo.getItemCount() == 1 && !MSysConfig.getBooleanValue("ALogin_ShowOneRole", true)) {
        roleCombo.setSelectedIndex(0);
        roleLabel.setVisible(false);
        roleCombo.setVisible(false);
    } else {
        roleLabel.setVisible(true);
        roleCombo.setVisible(true);
    }
    userTextField.setBackground(AdempierePLAF.getFieldBackground_Normal());
    passwordField.setBackground(AdempierePLAF.getFieldBackground_Normal());
    // 
    this.setTitle(hostField.getDisplay());
    statusBar.setStatusLine(txt_LoggedIn);
    m_comboActive = false;
    roleComboChanged();
    return true;
}
Also used : AccessException(java.rmi.AccessException) Login(org.compiere.util.Login) KeyNamePair(org.compiere.util.KeyNamePair)

Example 2 with AccessException

use of java.rmi.AccessException in project guice by google.

the class ThrowingProviderTest method testProviderMethodWithManyExceptions.

@Test
public void testProviderMethodWithManyExceptions() {
    try {
        Guice.createInjector(new AbstractModule() {

            @Override
            protected void configure() {
                install(ThrowingProviderBinder.forModule(this));
            }

            @SuppressWarnings("unused")
            @CheckedProvides(RemoteProvider.class)
            String foo() throws InterruptedException, RuntimeException, RemoteException, AccessException, TooManyListenersException {
                return null;
            }
        });
        fail();
    } catch (CreationException ce) {
        // The only two that should fail are Interrupted & TooManyListeners.. the rest are OK.
        List<Message> errors = ImmutableList.copyOf(ce.getErrorMessages());
        assertEquals(InterruptedException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(0).getMessage());
        assertEquals(TooManyListenersException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(1).getMessage());
        assertEquals(2, errors.size());
    }
}
Also used : CreationException(com.google.inject.CreationException) AbstractModule(com.google.inject.AbstractModule) TooManyListenersException(java.util.TooManyListenersException) AccessException(java.rmi.AccessException) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RemoteException(java.rmi.RemoteException) Test(org.junit.Test)

Example 3 with AccessException

use of java.rmi.AccessException in project roboguice by roboguice.

the class ThrowingProviderTest method testProviderMethodWithManyExceptions.

public void testProviderMethodWithManyExceptions() {
    try {
        Guice.createInjector(new AbstractModule() {

            protected void configure() {
                install(ThrowingProviderBinder.forModule(this));
            }

            @SuppressWarnings("unused")
            @CheckedProvides(RemoteProvider.class)
            String foo() throws InterruptedException, RuntimeException, RemoteException, AccessException, TooManyListenersException {
                return null;
            }
        });
        fail();
    } catch (CreationException ce) {
        // The only two that should fail are Interrupted & TooManyListeners.. the rest are OK.
        List<Message> errors = ImmutableList.copyOf(ce.getErrorMessages());
        assertEquals(InterruptedException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(0).getMessage());
        assertEquals(TooManyListenersException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(1).getMessage());
        assertEquals(2, errors.size());
    }
}
Also used : TooManyListenersException(java.util.TooManyListenersException) AccessException(java.rmi.AccessException) CreationException(com.google.inject.CreationException) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RemoteException(java.rmi.RemoteException) AbstractModule(com.google.inject.AbstractModule)

Example 4 with AccessException

use of java.rmi.AccessException in project tomee by apache.

the class EjbHomeProxyHandler method _invoke.

@Override
protected Object _invoke(final Object proxy, final Class interfce, final Method method, final Object[] args) throws Throwable {
    final String methodName = method.getName();
    if (logger.isDebugEnabled()) {
        logger.debug("EjbHomeProxyHandler: invoking method " + methodName + " on " + deploymentID);
    }
    try {
        final Object retValue;
        final MethodType operation = dispatchTable.get(methodName);
        if (operation == null) {
            retValue = homeMethod(interfce, method, args, proxy);
        } else {
            switch(operation) {
                /*-- CREATE ------------- <HomeInterface>.create(<x>) ---*/
                case CREATE:
                    retValue = create(interfce, method, args, proxy);
                    break;
                case FIND:
                    retValue = findX(interfce, method, args, proxy);
                    break;
                /*-- GET EJB METADATA ------ EJBHome.getEJBMetaData() ---*/
                case META_DATA:
                    retValue = getEJBMetaData(method, args, proxy);
                    break;
                /*-- GET HOME HANDLE -------- EJBHome.getHomeHandle() ---*/
                case HOME_HANDLE:
                    retValue = getHomeHandle(method, args, proxy);
                    break;
                /*-- REMOVE ------------------------ EJBHome.remove() ---*/
                case REMOVE:
                    {
                        final Class type = method.getParameterTypes()[0];
                        /*-- HANDLE ------- EJBHome.remove(Handle handle) ---*/
                        if (Handle.class.isAssignableFrom(type)) {
                            retValue = removeWithHandle(interfce, method, args, proxy);
                        } else {
                            /*-- PRIMARY KEY ----- EJBHome.remove(Object key) ---*/
                            retValue = removeByPrimaryKey(interfce, method, args, proxy);
                        }
                        break;
                    }
                default:
                    throw new OpenEJBRuntimeException("Inconsistent internal state: value " + operation + " for operation " + methodName);
            }
        }
        if (logger.isDebugEnabled()) {
            logger.debug("EjbHomeProxyHandler: finished invoking method " + method.getName() + ". Return value:" + retValue);
        }
        return retValue;
    /*
            * The ire is thrown by the container system and propagated by
            * the server to the stub.
            */
    } catch (final RemoteException re) {
        if (interfaceType.isLocal()) {
            throw new EJBException(re.getMessage()).initCause(re.detail);
        } else {
            throw re;
        }
    } catch (final InvalidateReferenceException ire) {
        Throwable cause = ire.getRootCause();
        if (cause instanceof RemoteException && interfaceType.isLocal()) {
            final RemoteException re = (RemoteException) cause;
            final Throwable detail = re.detail != null ? re.detail : re;
            cause = new EJBException(re.getMessage()).initCause(detail);
        }
        throw cause;
    /*
            * Application exceptions must be reported dirctly to the client. They
            * do not impact the viability of the proxy.
            */
    } catch (final ApplicationException ae) {
        final Throwable exc = ae.getRootCause() != null ? ae.getRootCause() : ae;
        if (exc instanceof EJBAccessException) {
            if (interfaceType.isBusiness()) {
                throw exc;
            } else {
                if (interfaceType.isLocal()) {
                    throw (AccessLocalException) new AccessLocalException(exc.getMessage()).initCause(exc);
                } else {
                    try {
                        throw new AccessException(exc.getMessage()).initCause(exc);
                    } catch (final IllegalStateException vmbug) {
                        // bug affects using initCause on any RemoteException subclasses in Sun 1.5_07 or lower
                        throw new AccessException(exc.getMessage(), (Exception) exc);
                    }
                }
            }
        }
        throw exc;
    /*
            * A system exception would be highly unusual and would indicate a sever
            * problem with the container system.
            */
    } catch (final SystemException se) {
        if (interfaceType.isLocal()) {
            throw new EJBException("Container has suffered a SystemException").initCause(se.getRootCause());
        } else {
            throw new RemoteException("Container has suffered a SystemException", se.getRootCause());
        }
    } catch (final OpenEJBException oe) {
        if (interfaceType.isLocal()) {
            throw new EJBException("Unknown Container Exception").initCause(oe.getRootCause());
        } else {
            throw new RemoteException("Unknown Container Exception", oe.getRootCause());
        }
    } catch (final Throwable t) {
        logger.debug("EjbHomeProxyHandler: finished invoking method " + method.getName() + " with exception:" + t, t);
        throw t;
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) AccessLocalException(javax.ejb.AccessLocalException) EJBAccessException(javax.ejb.EJBAccessException) Handle(javax.ejb.Handle) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) InvalidateReferenceException(org.apache.openejb.InvalidateReferenceException) ApplicationException(org.apache.openejb.ApplicationException) AccessException(java.rmi.AccessException) EJBAccessException(javax.ejb.EJBAccessException) SystemException(org.apache.openejb.SystemException) RemoteException(java.rmi.RemoteException) OpenEJBException(org.apache.openejb.OpenEJBException) EJBException(javax.ejb.EJBException)

Example 5 with AccessException

use of java.rmi.AccessException in project tomee by apache.

the class EjbObjectProxyHandler method _invoke.

@Override
public Object _invoke(final Object p, final Class interfce, final Method m, final Object[] a) throws Throwable {
    Object retValue = null;
    Throwable exc = null;
    final String methodName = m.getName();
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("EjbObjectProxyHandler: invoking method " + methodName + " on " + deploymentID + " with identity " + primaryKey);
        }
        Integer operation = dispatchTable.get(methodName);
        if (operation != null) {
            if (operation == 3) {
                if (m.getParameterTypes()[0] != EJBObject.class && m.getParameterTypes()[0] != EJBLocalObject.class) {
                    operation = null;
                }
            } else {
                operation = m.getParameterTypes().length == 0 ? operation : null;
            }
        }
        if (operation == null || !interfaceType.isComponent()) {
            retValue = businessMethod(interfce, m, a, p);
        } else {
            switch(operation) {
                case 1:
                    retValue = getHandle(m, a, p);
                    break;
                case 2:
                    retValue = getPrimaryKey(m, a, p);
                    break;
                case 3:
                    retValue = isIdentical(m, a, p);
                    break;
                case 4:
                    retValue = remove(interfce, m, a, p);
                    break;
                case 5:
                    retValue = getEJBHome(m, a, p);
                    break;
                case 6:
                    retValue = getEJBLocalHome(m, a, p);
                    break;
                default:
                    throw new OpenEJBRuntimeException("Inconsistent internal state");
            }
        }
        return retValue;
    /*
            * The ire is thrown by the container system and propagated by
            * the server to the stub.
            */
    } catch (final InvalidateReferenceException ire) {
        invalidateAllHandlers(getRegistryId());
        exc = ire.getRootCause() != null ? ire.getRootCause() : new RemoteException("InvalidateReferenceException: " + ire);
        throw exc;
    /*
            * Application exceptions must be reported dirctly to the client. They
            * do not impact the viability of the proxy.
            */
    } catch (final ApplicationException ae) {
        exc = ae.getRootCause() != null ? ae.getRootCause() : ae;
        if (exc instanceof EJBAccessException) {
            if (interfaceType.isBusiness()) {
                throw exc;
            } else {
                if (interfaceType.isLocal()) {
                    throw new AccessLocalException(exc.getMessage()).initCause(exc.getCause());
                } else {
                    throw new AccessException(exc.getMessage());
                }
            }
        }
        throw exc;
    /*
            * A system exception would be highly unusual and would indicate a sever
            * problem with the container system.
            */
    } catch (final SystemException se) {
        invalidateReference();
        exc = se.getRootCause() != null ? se.getRootCause() : se;
        logger.debug("The container received an unexpected exception: ", exc);
        throw new RemoteException("Container has suffered a SystemException", exc);
    } catch (final OpenEJBException oe) {
        exc = oe.getRootCause() != null ? oe.getRootCause() : oe;
        logger.debug("The container received an unexpected exception: ", exc);
        throw new RemoteException("Unknown Container Exception", oe.getRootCause());
    } finally {
        if (logger.isDebugEnabled()) {
            if (exc == null) {
                String ret = "void";
                if (null != retValue) {
                    try {
                        ret = retValue.toString();
                    } catch (final Exception e) {
                        ret = "toString() failed on (" + e.getMessage() + ")";
                    }
                }
                logger.debug("EjbObjectProxyHandler: finished invoking method " + methodName + ". Return value:" + ret);
            } else {
                logger.debug("EjbObjectProxyHandler: finished invoking method " + methodName + " with exception " + exc);
            }
        }
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) AccessLocalException(javax.ejb.AccessLocalException) EJBLocalObject(javax.ejb.EJBLocalObject) EJBAccessException(javax.ejb.EJBAccessException) AccessException(java.rmi.AccessException) InvalidateReferenceException(org.apache.openejb.InvalidateReferenceException) ApplicationException(org.apache.openejb.ApplicationException) EJBAccessException(javax.ejb.EJBAccessException) OpenEJBException(org.apache.openejb.OpenEJBException) AccessLocalException(javax.ejb.AccessLocalException) RemoteException(java.rmi.RemoteException) ObjectStreamException(java.io.ObjectStreamException) SystemException(org.apache.openejb.SystemException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) InvalidateReferenceException(org.apache.openejb.InvalidateReferenceException) ApplicationException(org.apache.openejb.ApplicationException) AccessException(java.rmi.AccessException) EJBAccessException(javax.ejb.EJBAccessException) SystemException(org.apache.openejb.SystemException) EJBObject(javax.ejb.EJBObject) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject) RemoteException(java.rmi.RemoteException)

Aggregations

AccessException (java.rmi.AccessException)9 RemoteException (java.rmi.RemoteException)7 ImmutableList (com.google.common.collect.ImmutableList)4 AbstractModule (com.google.inject.AbstractModule)4 CreationException (com.google.inject.CreationException)4 List (java.util.List)4 TooManyListenersException (java.util.TooManyListenersException)4 BindException (java.net.BindException)2 ArrayList (java.util.ArrayList)2 AccessLocalException (javax.ejb.AccessLocalException)2 EJBAccessException (javax.ejb.EJBAccessException)2 ApplicationException (org.apache.openejb.ApplicationException)2 InvalidateReferenceException (org.apache.openejb.InvalidateReferenceException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)2 SystemException (org.apache.openejb.SystemException)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Login (org.compiere.util.Login)2 EjbInvocation (com.sun.ejb.EjbInvocation)1 ObjectStreamException (java.io.ObjectStreamException)1