Examples of EZBComponentException


Examples of org.ow2.easybeans.component.api.EZBComponentException

            // Enable bindings into the cluster
            try {
                ConfigurationRepository.getServerConfiguration().enableCMI(this.cmiProperties);
            } catch (Exception e) {
                this.logger.error("Cannot configure Carol to use CMI", e);
                throw new EZBComponentException("Cannot configure Carol to use CMI", e);
            }

            ClusterViewManagerFactory clusterViewManagerFactory = ClusterViewManagerFactory.getFactory();

            // Start the manager
            try {
                this.clusterViewManager = (ServerClusterViewManager) clusterViewManagerFactory.create();
            } catch (Exception e) {
                this.logger.error("Cannot retrieve the CMI Server", e);
                throw new EZBComponentException("Cannot retrieve the CMI Server", e);
            }
            if (this.clusterViewManager != null
                    && this.clusterViewManager.getState().equals(ClusterViewManager.State.STOPPED)) {
                if (this.eventComponent != null) {
                    List<Component> components =
                        clusterViewManagerFactory.getConfig().getComponents().getComponents();
                    if (components != null) {
                        for (Component cmiEventComponent : components) {
                            if (org.ow2.cmi.component.event.EventComponent.class.isAssignableFrom(cmiEventComponent.getClass())) {
                                ((org.ow2.cmi.component.event.EventComponent) cmiEventComponent).setEventService(
                                        this.eventComponent.getEventService());
                            }
                        }
                    }
                }
                try {
                    this.clusterViewManager.start();
                } catch (Exception e) {
                    this.logger.error("Cannot start the CMI Server", e);
                    throw new EZBComponentException("Cannot start the CMI Server", e);
                }
            }
        }
        // register the listener.
        EZBEventListener eventListener = new CmiEventListener();
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

            if (this.clusterViewManager != null) {
                try {
                    this.clusterViewManager.stop();
                } catch (Exception e) {
                    this.logger.error("Cannot stop the server-side manager", e);
                    throw new EZBComponentException("Cannot stop the server-side manager", e);
                }
            }
        }
        this.logger.info("CMI extension stopped.");
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

    public void enable() throws EZBComponentException {
        for (EZBMonitor monitor : this.monitors) {
            try {
                monitor.start();
            } catch (EZBMonitorException e) {
                throw new EZBComponentException("Cannot start monitor '" + monitor + "'", e);
            }
        }
    }
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

        // Build Remote Object for this server.
        try {
            jndiResolver = new JNDIResolverRemoteImpl(server);
        } catch (RemoteException e) {
            throw new EZBComponentException("Cannot create the JNDI Resolver.", e);
        }

        // Bind
        try {
            new InitialContext().bind(DEFAULT_JNDI_NAME, jndiResolver);
        } catch (NamingException e) {
            throw new EZBComponentException("Cannot bind the JNDI Resolver", e);
        }

    }
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

        // Build initial context
        try {
            this.ictx = new InitialContext();
        } catch (NamingException e) {
            throw new EZBComponentException("Cannot create an initial context.", e);
        }

        // Check if the transaction component is present
        if (this.transactionComponent == null) {
            // Missing injection
            throw new EZBComponentException("Transaction component was not injected. Reason: Missing tm=\"#tm\""
                    + " in the easybeans.xml configuration file ?");
        }

        // Check if the work manager is present
        if (this.workManager == null) {
            // Missing injection
            throw new EZBComponentException("Work manager was not injected. Reason: Missing workmanager=\"#workmanager\""
                    + " in the easybeans.xml configuration file ?");
        }

        // Create BootstrapContext
        XATerminator xaTerminator = null;
        try {
            xaTerminator = this.transactionComponent.getXATerminator();
        } catch (XAException e) {
            throw new EZBComponentException("Cannot get the XA terminator", e);
        }

        BootstrapContext bootstrapContext = new JoramBootstrapContext(this.workManager, xaTerminator);

        // Create JORAM adapter
        this.joramAdapter = new JoramAdapter();

        // Set host/port
        this.joramAdapter.setHostName(this.host);
        this.joramAdapter.setServerPort(Integer.valueOf(this.port));

        // configure it (in fact the server will be collocated but started by this service and not by the resource adapter).
        this.joramAdapter.setCollocatedServer(Boolean.FALSE);

        // Set properties (transient)
        System.setProperty(TRANSACTION_PROPERTY, NullTransaction.class.getName());

        // Init
        try {
            AgentServer.init(ID, DEFAULT_PERSISTENCE_DIRECTORY, null);
        } catch (Exception e) {
            throw new EZBComponentException("Cannot initialize a new collocated Joram server", e);
        }

        // start Agent
       try {
           AgentServer.start();
        } catch (Exception e) {
            throw new EZBComponentException("Cannot start collocated Joram server", e);
        }

        // Add services
        try {
            new ServerConfigHelper(false).addService(ID, ConnectionManager.class.getName(), "root root");
        } catch (Exception e) {
            throw new EZBComponentException("Cannot add connection manager service", e);
        }
        // To enable TCP listener
        try {
            new ServerConfigHelper(false).addService(ID, TcpProxyService.class.getName(), String.valueOf(this.port));
        } catch (Exception e) {
            throw new EZBComponentException("Cannot add TcpProxy service", e);
        }


        // connect to the collocated server
        try {
            connectToCollocated();
        } catch (JoramException e) {
            throw new EZBComponentException("Cannot connect to the collocated server", e);
        }


        // Create anonymous user
        try {
            this.joramAdapter.createUser("anonymous", "anonymous");
        } catch (AdminException e) {
            throw new EZBComponentException("Cannot create anonymous user", e);
        } catch (ConnectException e) {
            throw new EZBComponentException("Cannot create anonymous user", e);
        }


        // start resource adapter
        try {
            this.joramAdapter.start(bootstrapContext);
        } catch (ResourceAdapterInternalException e) {
            throw new EZBComponentException("Cannot start the resource adapter of JORAM", e);
        }

        // create factories
        try {
            createConnectionFactories();
        } catch (JoramException e) {
            throw new EZBComponentException("Cannot create connection factories", e);
        }


        // initial topics and queues
        try {
            createInitialTopics();
        } catch (JoramException e) {
            throw new EZBComponentException("Cannot create initial topics", e);
        }

        try {
            createInitialQueues();
        } catch (JoramException e) {
            throw new EZBComponentException("Cannot create initial queues", e);
        }

        // Create and bind ActivationSpec
        ActivationSpec activationSpec = new ActivationSpecImpl();
        try {
            activationSpec.setResourceAdapter(this.joramAdapter);
        } catch (ResourceException e) {
            throw new EZBComponentException("Cannot set resource adapter on activation spec object", e);
        }
        try {
            this.ictx.rebind("joramActivationSpec", activationSpec);
        } catch (NamingException e) {
            throw new EZBComponentException("Cannot bind activation spec object", e);
        }

        logger.info("Joram version ''{0}'' started on {1}:{2}",
                ConnectionMetaData.providerVersion, this.host, String.valueOf(this.port));
        this.started = true;
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

        // Creates a new selector
        try {
            this.selector = Selector.open();
        } catch (IOException e) {
            throw new EZBComponentException("Cannot open a new selector.", e);
        }
        // Server socket
        try {
            this.server = ServerSocketChannel.open();
        } catch (IOException e) {
            throw new EZBComponentException("Cannot open a new server socket channel.", e);
        }

        // no blocking
        try {
            this.server.configureBlocking(false);
        } catch (IOException e) {
            throw new EZBComponentException("Cannot configure the server socket with non-blocking mode.", e);
        }
    }
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

        // port number listener
        try {
            this.server.socket().bind(new java.net.InetSocketAddress(this.portNumber));
        } catch (IOException e) {
            throw new EZBComponentException("Cannot listen on the port number '" + this.portNumber
                    + "', maybe the port is already used.", e);
        }

        // registering
        try {
            this.serverkey = this.server.register(this.selector, SelectionKey.OP_ACCEPT);
        } catch (ClosedChannelException e) {
            throw new EZBComponentException("Cannot register the current selector as an accepting selector waiting clients.", e);
        }

        // now wait clients
        this.waitingSelector = true;
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

                    // Build address object from the string
                    Address address = null;
                    try {
                        address = new InternetAddress(mail.getName());
                    } catch (AddressException e) {
                        throw new EZBComponentException("Cannot build an internet address with given value '" + mail.getName()
                                + "'.", e);
                    }

                    // Add address in the correct list
                    if ("CC".equalsIgnoreCase(mail.getType())) {
                        ccAddresses.add(address);
                    } else if ("BCC".equalsIgnoreCase(mail.getType())) {
                        bccAddresses.add(address);
                    } else {
                        // Default is TO
                        toAddresses.add(address);
                    }
                }

                // Set recipients
                mimePartDataSourceRef.setToRecipients(toAddresses.toArray(new Address[toAddresses.size()]));
                mimePartDataSourceRef.setCcRecipients(ccAddresses.toArray(new Address[ccAddresses.size()]));
                mimePartDataSourceRef.setBccRecipients(bccAddresses.toArray(new Address[bccAddresses.size()]));

            } else {
                throw new EZBComponentException("Unknown factory '" + factory + "'.");
            }

            // Set common values
            javaMailRef.setName(factory.getName());
            javaMailRef.setJNDIName(jndiName);
            javaMailRef.setProperties(factory.getMailSessionProperties());

            // Auth set for the factory ?
            Auth auth = factory.getAuth();

            // No, try to see for default auth ?
            if (auth == null) {
                auth = getAuth();
            }

            // There is authentication, set it
            if (auth != null) {
                javaMailRef.setAuthName(auth.getUsername());
                javaMailRef.setAuthName(auth.getPassword());
            }

            // Bind object
            try {
                new InitialContext().bind(jndiName, javaMailRef);
                logger.info("Binding {0} Mail factory with JNDI name {1}", javaMailRef.getType(), jndiName);
            } catch (NamingException e) {
                throw new EZBComponentException(
                        "Unable to bind the factory '" + factory + "' with JNDI name '" + jndiName + "'.", e);
            }

        }
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

     * @throws EZBComponentException if validation fails.
     */
    private void validate() throws EZBComponentException {
        // check that there is a JNDI name
        if (this.jndiName == null) {
            throw new EZBComponentException("No JNDI name set");
        }

        // check that there is an URL
        if (this.url == null) {
            throw new EZBComponentException("No URL set");
        }

        // Check that there is a driver classname
        if (this.driver == null) {
            throw new EZBComponentException("No driver set");
        }
    }
View Full Code Here

Examples of org.ow2.easybeans.component.api.EZBComponentException

    public void start() throws EZBComponentException {
        // set settings
        if (this.useTM) {
            if (this.transactionComponent == null) {
                // Missing injection
                throw new EZBComponentException("Transaction component was not injected. Reason: Missing tm=\"#tm\""
                        + " in the easybeans.xml configuration file ?");
            }
            this.connectionManager.setTm(this.transactionComponent.getTransactionManager());
        }
        this.connectionManager.setPoolMin(this.poolMin);
        this.connectionManager.setPoolMax(this.poolMax);

        // Something is there ?
        try {
            Object o = new InitialContext().lookup(this.jndiName);
            if (o != null) {
                logger.warn("Entry with JNDI name {0} already exist", this.jndiName);
            }
        } catch (NamingException e) {
            logger.debug("Nothing with JNDI name {0}", this.jndiName);
        }

        // Bind the resource.
        try {
            new InitialContext().rebind(this.jndiName, this.connectionManager);
        } catch (NamingException e) {
            throw new EZBComponentException("Cannot bind a JDBC Datasource with the jndi name '" + this.jndiName + "'.");
        }

        logger.info("DS ''{0}'', URL ''{1}'', Driver = ''{2}''.", this.jndiName, this.url, this.driver);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.