Package org.apache.openejb

Examples of org.apache.openejb.OpenEJBException


        try {
            InitialContext ic = new InitialContext(contextInfo.properties);
            result = ic;
        } catch (NamingException ne) {

            throw new OpenEJBException("The remote JNDI EJB references for remote-jndi-contexts = " + contextInfo.id + "+ could not be resolved.", ne);
        }
        InitialContext cntx = result;

        try {
            containerSystem.getJNDIContext().bind("java:openejb/remote_jndi_contexts/" + contextInfo.id, cntx);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + contextInfo.service + " with id " + contextInfo.id, e);
        }

        // Update the config tree
        config.facilities.remoteJndiContexts.add(contextInfo);
    }
View Full Code Here


        checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id);

        try {
            this.containerSystem.getJNDIContext().bind("java:openejb/" + serviceInfo.service + "/" + serviceInfo.id, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + serviceInfo.service + " with id " + serviceInfo.id, e);
        }

        setSystemInstanceComponent(interfce, service);

        props.put(interfce.getName(), service);
View Full Code Here

        ProxyManager.setDefaultFactory(serviceInfo.id);

        try {
            this.containerSystem.getJNDIContext().bind("java:openejb/" + serviceInfo.service + "/" + serviceInfo.id, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + serviceInfo.service + " with id " + serviceInfo.id, e);
        }

        setSystemInstanceComponent(interfce, service);

        getContext().put(interfce.getName(), service);
View Full Code Here

            } catch (NamingException e) {
                // handled below
            }

            if (resourceAdapter == null) {
                throw new OpenEJBException("No existing resource adapter defined with id '" + resourceAdapterId + "'.");
            }
            if (!(resourceAdapter instanceof ResourceAdapter)) {
                throw new OpenEJBException("Resource adapter defined with id '" + resourceAdapterId + "' is not an instance of ResourceAdapter, " +
                        "but is an instance of " + resourceAdapter.getClass());
            }
            serviceRecipe.setProperty("ResourceAdapter", resourceAdapter);
        }
    }
View Full Code Here

        if (service instanceof ResourceAdapter) {
            ResourceAdapter resourceAdapter = (ResourceAdapter) service;

            // resource adapters only work with a geronimo transaction manager
            if (!(transactionManager instanceof GeronimoTransactionManager)) {
                throw new OpenEJBException("The use of a resource adapter requires a Geronimo transaction manager");
            }
            GeronimoTransactionManager geronimoTransactionManager = (GeronimoTransactionManager) transactionManager;

            // create a thead pool
            int threadPoolSize = getIntProperty(serviceInfo.properties, "threadPoolSize", 30);
            if (threadPoolSize <= 0) throw new IllegalArgumentException("threadPoolSizes <= 0: " + threadPoolSize);
            Executor threadPool = Executors.newFixedThreadPool(threadPoolSize, new ResourceAdapterThreadFactory(serviceInfo.id));

            // create a work manager which the resource adapter can use to dispatch messages or perform tasks
            WorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, geronimoTransactionManager);

            // wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
            BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, geronimoTransactionManager);

            // start the resource adapter
            try {
                resourceAdapter.start(bootstrapContext);
            } catch (ResourceAdapterInternalException e) {
                throw new OpenEJBException(e);
            }           
        } else if (service instanceof ManagedConnectionFactory) {
            ManagedConnectionFactory managedConnectionFactory = (ManagedConnectionFactory) service;

            // get the connection manager
            ConnectionManager connectionManager;
            if ((ManagedConnectionFactory) service instanceof JdbcManagedConnectionFactory) {
                connectionManager = SystemInstance.get().getComponent(ConnectionManager.class);
            } else {
                GeronimoConnectionManagerFactory connectionManagerFactory = new GeronimoConnectionManagerFactory();
                // default transaction support is "local" and that doesn't seem to work
                connectionManagerFactory.setTransactionSupport("xa");
                connectionManagerFactory.setTransactionManager(transactionManager);
                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                if (classLoader == null) classLoader = getClass().getClassLoader();
                if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
                connectionManagerFactory.setClassLoader(classLoader);
                connectionManager = connectionManagerFactory.create();
            }

            if (connectionManager == null) {
                throw new RuntimeException("Invalid connection manager specified for connector identity = " + serviceInfo.id);
            }

            // service becomes a ConnectorReference which merges connection manager and mcf
            service = new ConnectorReference(connectionManager, managedConnectionFactory);
        }

        try {
            containerSystem.getJNDIContext().bind("java:openejb/Resource/" + serviceInfo.id, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind resource adapter with id " + serviceInfo.id, e);
        }

        // Update the config tree
        config.facilities.resources.add(serviceInfo);
    }
View Full Code Here

        checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id);

        try {
            this.containerSystem.getJNDIContext().bind("java:openejb/" + serviceInfo.service + "/" + serviceInfo.id, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + serviceInfo.service + " with id " + serviceInfo.id, e);
        }

        setSystemInstanceComponent(interfce, service);

        getContext().put(interfce.getName(), service);
View Full Code Here

        checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id);

        try {
            this.containerSystem.getJNDIContext().bind("java:openejb/" + serviceInfo.service, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + serviceInfo.service + " with id " + serviceInfo.id, e);
        }

        setSystemInstanceComponent(interfce, service);

        getContext().put(interfce.getName(), service);
View Full Code Here

        checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id);

        try {
            this.containerSystem.getJNDIContext().bind("java:openejb/" + serviceInfo.service, service);
        } catch (NamingException e) {
            throw new OpenEJBException("Cannot bind " + serviceInfo.service + " with id " + serviceInfo.id, e);
        }

        setSystemInstanceComponent(interfce, service);

        getContext().put(interfce.getName(), service);
View Full Code Here

                try {
                    containerInfo.properties.put("MessageListenerInterface",
                        configuration.getConfigurationClassLoader().loadClass(messageListenerInterface));
                } catch (ClassNotFoundException e) {
                    throw new OpenEJBException("Could not load MessageListenerInterface " + messageListenerInterface + " in classloader: " + configuration.getConfigurationClassLoader(), e);
                }
                try {
                    containerInfo.properties.put("ActivationSpecClass",
                        configuration.getConfigurationClassLoader().loadClass(activationSpecClass));
                } catch (ClassNotFoundException e) {
                    throw new OpenEJBException("Could not load ActivationSpecClass " + activationSpecClass + " in classloader: " + configuration.getConfigurationClassLoader(), e);
                }
                //TODO is this necessary????
//                containerInfo.properties.put("ResourceAdapter", resourceAdapter);

                containerSystem.containers.add(containerInfo);
View Full Code Here

                t.printStackTrace(res.getWriter());
            } catch (IOException e) {
                // no-op
            }
            log.error("BAD REQUEST", t);
            throw new OpenEJBException("Could not read the request.\n" + t.getClass().getName() + ":\n" + t.getMessage(), t);
        }

        final URI uri;
        String location = null;
        try {
            uri = req.getURI();
            location = uri.getPath();
            final int querry = location.indexOf("?");
            if (querry != -1) {
                location = location.substring(0, querry);
            }
        } catch (Throwable t) {
            throw new OpenEJBException("Could not determine the module " + location + "\n" + t.getClass().getName() + ":\n" + t.getMessage());
        }

        try {
            listener.onMessage(req, res);
        } catch (Throwable t) {
            throw new OpenEJBException("Error occurred while executing the module " + location + "\n" + t.getClass().getName() + ":\n" + t.getMessage(), t);
        }

        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.OpenEJBException

Copyright © 2018 www.massapicom. 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.