Wednesday, March 18, 2015

ActivationException

java.rmi.activation.ActivationException

ActivationException is described in the javadoc comments as:

General exception used by the activation interfaces.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The 'detail exception' that may be provided at construction time and accessed via the public {link: #detail} field is now known as the cause, and may be accessed via the {link: Throwable#getCause()} method, as well as the aforementioned 'legacy field.'

Invoking the method {link: Throwable#initCause(Throwable)} on an instance of ActivationException always throws {@link IllegalStateException}.
author: Ann Wollrath version: 1.24, 12/19/03 since: 1.2

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

java.rmi.activation.ActivationGroup.createGroup(ActivationGroupID, ActivationGroupDesc, long)

/**
     * Create and set the activation group for the current VM.  The
     * activation group can only be set if it is not currently set.
     * An activation group is set using the <code>createGroup</code>
     * method when the <code>Activator</code> initiates the
     * re-creation of an activation group in order to carry out
     * incoming <code>activate</code> requests. A group must first be
     * registered with the <code>ActivationSystem</code> before it can
     * be created via this method.
     * The group class specified by the
     * <code>ActivationGroupDesc</code> must be a concrete subclass of
     * <code>ActivationGroup</code> and have a public constructor that
     * takes two arguments: the <code>ActivationGroupID</code> for the
     * group and the <code>MarshalledObject</code> containing the
     * group's initialization data (obtained from the
     * <code>ActivationGroupDesc</code>.
     * If the group class name specified in the
     * <code>ActivationGroupDesc</code> is <code>null</code>, then
     * this method will behave as if the group descriptor contained
     * the name of the default activation group implementation class.
     * Note that if your application creates its own custom
     * activation group, a security manager must be set for that
     * group.  Otherwise objects cannot be activated in the group.
     * <code>java.rmi.RMISecurityManager</code> is set by default.
     * If a security manager is already set in the group VM, this
     * method first calls the security manager's
     * <code>checkSetFactory</code> method.  This could result in a
     * <code>SecurityException</code>. If your application needs to
     * set a different security manager, you must ensure that the
     * policy file specified by the group's
     * <code>ActivationGroupDesc</code> grants the group the necessary
     * permissions to set a new security manager.  (Note: This will be
     * necessary if your group downloads and sets a security manager).
     * After the group is created, the
     * <code>ActivationSystem</code> is informed that the group is
     * active by calling the <code>activeGroup</code> method which
     * returns the <code>ActivationMonitor</code> for the group. The
     * application need not call <code>activeGroup</code>
     * independently since it is taken care of by this method.
     * Once a group is created, subsequent calls to the
     * <code>currentGroupID</code> method will return the identifier
     * for this group until the group becomes inactive.
     * @param id the activation group's identifier
     * @param desc the activation group's descriptor
     * @param incarnation the group's incarnation number (zero on group's
     * initial creation)
     * @return the activation group for the VM
     * @exception ActivationException if group already exists or if error
     * occurs during group creation 
     * @exception SecurityException if permission to create group is denied.
     * (Note: The default implementation of the security manager 
     * <code>checkSetFactory</code>
     * method requires the RuntimePermission 'setFactory')
     * @see SecurityManager#checkSetFactory
     * @since 1.2
     */
public static synchronized ActivationGroup createGroup(ActivationGroupID id, final ActivationGroupDesc desc, long incarnation) throws ActivationException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) security.checkSetFactory();
    if (currGroup != null) throw new ActivationException('group already exists');
    if (canCreate == false) throw new ActivationException('group deactivated and ' + 'cannot be recreated');
    try {
        String groupClassName = desc.getClassName();
        if (groupClassName == null) {
            groupClassName = sun.rmi.server.ActivationGroupImpl.class.getName();
        }
        final String className = groupClassName;
        Class cl;
        try {
            cl = (Class) java.security.AccessController.doPrivileged(new PrivilegedExceptionAction() {

                public Object run() throws ClassNotFoundException, MalformedURLException {
                    return RMIClassLoader.loadClass(desc.getLocation(), className);
                }
            });
        } catch (PrivilegedActionException pae) {
            throw new ActivationException('Could not load default group ' + 'implementation class', pae.getException());
        }
        Constructor constructor = cl.getConstructor(groupConstrParams);
        Object[] params = new Object[] { id, desc.getData() };
        Object obj = constructor.newInstance(params);
        if (obj instanceof ActivationGroup) {
            ActivationGroup newGroup = (ActivationGroup) obj;
            currSystem = id.getSystem();
            newGroup.incarnation = incarnation;
            newGroup.monitor = currSystem.activeGroup(id, newGroup, incarnation);
            currGroup = newGroup;
            currGroupID = id;
            canCreate = false;
        } else {
            throw new ActivationException('group not correct class: ' + obj.getClass().getName());
        }
    } catch (java.lang.reflect.InvocationTargetException e) {
        e.getTargetException().printStackTrace();
        throw new ActivationException('exception in group constructor', e.getTargetException());
    } catch (ActivationException e) {
        throw e;
    } catch (Exception e) {
        throw new ActivationException('exception creating group', e);
    }
    return currGroup;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.rmi.activation.ActivationGroup.setSystem(ActivationSystem)

/**
     * Set the activation system for the VM.  The activation system can
     * only be set it if no group is currently active. If the activation
     * system is not set via this call, then the <code>getSystem</code>
     * method attempts to obtain a reference to the
     * <code>ActivationSystem</code> by looking up the name
     * 'java.rmi.activation.ActivationSystem' in the Activator's
     * registry. By default, the port number used to look up the
     * activation system is defined by
     * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be overridden
     * by setting the property <code>java.rmi.activation.port</code>.
     * If there is a security manager, this method first
     * calls the security manager's <code>checkSetFactory</code> method.
     * This could result in a SecurityException.
     * @param system remote reference to the <code>ActivationSystem</code>
     * @exception ActivationException if activation system is already set
     * @exception SecurityException if permission to set the activation system is denied.
     * (Note: The default implementation of the security manager 
     * <code>checkSetFactory</code>
     * method requires the RuntimePermission 'setFactory')
     * @see #getSystem
     * @see SecurityManager#checkSetFactory
     * @since 1.2
     */
public static synchronized void setSystem(ActivationSystem system) throws ActivationException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) security.checkSetFactory();
    if (currSystem != null) throw new ActivationException('activation system already set');
    currSystem = system;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.rmi.activation.ActivationGroup.currentGroup()

/**
     * Returns the current group for the VM.
     * @exception ActivationException if current group is null (not active)
     */
static synchronized ActivationGroup currentGroup() throws ActivationException {
    if (currGroup == null) {
        throw new ActivationException('group is not active');
    }
    return currGroup;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.rmi.activation.ActivationGroup.internalCurrentGroupID()

/**
     * Returns the activation group identifier for the VM.  If an
     * activation group does not exist for this VM, a default
     * activation group is created. A group can be created only once,
     * so if a group has already become active and deactivated.
     * @return the activation group identifier
     * @exception ActivationException if error occurs during group
     * creation, if security manager is not set, or if the group
     * has already been created and deactivated.
     */
static synchronized ActivationGroupID internalCurrentGroupID() throws ActivationException {
    if (currGroupID == null) throw new ActivationException('nonexistent group');
    return currGroupID;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.rmi.activation.ActivationGroup.getSystem()

/**
     * Returns the activation system for the VM. The activation system
     * may be set by the <code>setSystem</code> method. If the
     * activation system is not set via the <code>setSystem</code>
     * method, then the <code>getSystem</code> method attempts to
     * obtain a reference to the <code>ActivationSystem</code> by
     * looking up the name 'java.rmi.activation.ActivationSystem' in
     * the Activator's registry. By default, the port number used to
     * look up the activation system is defined by
     * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
     * overridden by setting the property
     * <code>java.rmi.activation.port</code>.
     * @return the activation system for the VM/group
     * @exception ActivationException if activation system cannot be
     *  obtained or is not bound
     * (means that it is not running)
     * @see #setSystem
     * @since 1.2
     */
public static synchronized ActivationSystem getSystem() throws ActivationException {
    if (currSystem == null) {
        try {
            int port;
            port = ((Integer) java.security.AccessController.doPrivileged(new GetIntegerAction('java.rmi.activation.port', ActivationSystem.SYSTEM_PORT))).intValue();
            currSystem = (ActivationSystem) Naming.lookup('//:' + port + '/java.rmi.activation.ActivationSystem');
        } catch (Exception e) {
            throw new ActivationException('unable to obtain ActivationSystem', e);
        }
    }
    return currSystem;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

No comments:

Post a Comment