Examples of EZBContainerException


Examples of org.ow2.easybeans.api.EZBContainerException

            // load class
            Class<?> clz = null;
            try {
                clz = classLoader.loadClass(itfClassName);
            } catch (ClassNotFoundException e) {
                throw new EZBContainerException("Cannot find the class '" + itfClassName + "' in Classloader '"
                        + classLoader + "'.", e);
            }

            // set the interface class
            handler.setInterfaceClass(clz);
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

            // load class
            Class<?> clz = null;
            try {
                clz = classLoader.loadClass(itfClassName);
            } catch (ClassNotFoundException e) {
                throw new EZBContainerException("Cannot find the class '" + itfClassName + "' in Classloader '"
                        + classLoader + "'.", e);
            }

            // set the interface class
            handler.setInterfaceClass(clz);
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

        // Analyze files
        long tStart = System.currentTimeMillis();
        try {
            this.deployment.analyze(this.classLoader);
        } catch (ScanException e) {
            throw new EZBContainerException("Cannot analyze archive '" + getArchive().getName() + "'.", e);
        } catch (ResolverException e) {
            throw new EZBContainerException("Cannot resolve some annotations in the archive '" + getName()
                    + "'.", e);
        } catch (DeployableHelperException e) {
            throw new EZBContainerException("Cannot transform in deployable archive '" + getName()
                    + "'.", e);
        } catch (DeployableMetadataException e) {
            throw new EZBContainerException("Cannot create deployable metadata '" + getName()
                    + "'.", e);
        }

        // Build JNDI resolver
        JNDIResolverHelper jndiResolver = new JNDIResolverHelper(this);
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

        // Gets URL of the archive
        final URL url;
        try {
            url = getArchive().getURL();
        } catch (ArchiveException e) {
            throw new EZBContainerException("Cannot get URL on the archive '" + getName() + "'.", e);
        }
        final ClassLoader old = Thread.currentThread().getContextClassLoader();
        // Define classloader if it was not yet defined (ear case -->
        // classloader already set)
        if (this.classLoader == null) {
            PrivilegedAction<EasyBeansClassLoader> privilegedAction = new PrivilegedAction<EasyBeansClassLoader>() {
                public EasyBeansClassLoader run() {
                    return new EasyBeansClassLoader(new URL[] {url}, old);
                }
            };
            this.classLoader = AccessController.doPrivileged(privilegedAction);
        }
        // FIXME keep resolve ? keep classloader ?
        // Resolve deployment stuff if not already done
        if (!this.resolved) {
            resolve();
        }

        try {
            Thread.currentThread().setContextClassLoader(this.classLoader);
            Enhancer enhancer = new Enhancer(this.classLoader, this.deployment.getEjbJarArchiveMetadata(), this.enhancerMap);

            long tStartEnhancing = System.currentTimeMillis();
            try {
                enhancer.enhance();
            } catch (EnhancerException ee) {
                throw new EZBContainerException("Cannot run enhancer on archive '" + getName() + "'.", ee);
            } catch (RuntimeException e) {
                // Catch Exception as some exceptions can be runtime exception
                throw new EZBContainerException("Cannot run enhancer on archive '" + getName() + "'.", e);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Enhancement elapsed during : " + (System.currentTimeMillis() - tStartEnhancing) + " ms");
            }

            // Check if there is META-INF/persistence.xml file
            PersistenceUnitManager analyzedPersistenceUnitManager = null;
            try {
                JPersistenceUnitInfo[] persistenceUnitInfos =
                        PersistenceXmlFileAnalyzer.analyzePersistenceXmlFile(getArchive());

                // Dispatch life cycle event.
                this.dispatcher.dispatch(new EventContainerStarting(this.j2eeManagedObjectId, getArchive(),
                                                                    persistenceUnitInfos, this.configuration));

                if (persistenceUnitInfos != null) {
                    analyzedPersistenceUnitManager =
                            PersistenceXmlFileAnalyzer.loadPersistenceProvider(persistenceUnitInfos, getClassLoader());
                }
            } catch (PersistenceXmlFileAnalyzerException e) {
                throw new EZBContainerException("Cannot analyze the persistence.xml file in the archive", e);
            }

            // No previous manager
            if (this.persistenceUnitManager == null) {
                this.persistenceUnitManager = analyzedPersistenceUnitManager;
            } else {
                // merge old and new.
                if (analyzedPersistenceUnitManager != null) {
                    analyzedPersistenceUnitManager.merge(this.persistenceUnitManager);
                    // update persistence manager with the merged one.
                    this.persistenceUnitManager = analyzedPersistenceUnitManager;
                }
            }

            // Create Beans Factories
            createBeanFactories();

            // cleanup
            this.deployment.reset();
            enhancer = null;
        } finally {
            Thread.currentThread().setContextClassLoader(old);
        }

        // Send notification to callbacks
        if (getCallbacksLifeCycle().size() > 0) {
            EZBContainerCallbackInfo info = getContainer3CallbackInfo();
            for (EZBContainerLifeCycleCallback callback : getCallbacksLifeCycle()) {
                try {
                    callback.start(info);
                } catch (Throwable t) {
                    // Protection from malicious code
                    logger.error("{0}.start() failed", callback.getClass().getName(), t);
                }
            }
        }

        try {
            MBeansHelper.getInstance().registerMBean(this);
        } catch (MBeansException e) {
            // TODO what to do here ? log or exception ?
            logger.error("Cannot register Container MBeans for " + getArchive().getName(), e);
        }

        // Register resolver
        getEmbedded().getJNDIResolver().addContainerResolver(this.configuration.getContainerJNDIResolver());

        // Start factories
        // TODO: apply an order for singletons
        for (Factory<?, ?> factory : this.factories.values()) {
            try {
                factory.start();
            } catch (FactoryException e) {
                throw new EZBContainerException("Cannot start the given factory '" + factory + "'", e);
            }
        }

        // Display infos
        if (logger.isInfoEnabled()) {
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

    protected void createBeanFactories() throws EZBContainerException {

        // Check that the event component is here
        EZBEventComponent eventComponent = getComponent(EZBEventComponent.class);
        if (eventComponent == null) {
            throw new EZBContainerException("Event component is required !");
        }

        // Create/Start/Register a new event dispatcher
        IEventDispatcher eventDispatcher = eventComponent.createEventDispatcher();
        eventDispatcher.start();

        // The topic is common for all EZBContainer and Factory
        eventComponent.getEventService().registerDispatcher(Embedded.NAMING_EXTENSION_POINT,
                                                            eventDispatcher);

        logger.debug("EventService instance {0}", eventComponent.getEventService());

        // Wrap in a try/finally block to be able to stop/unregister the dispatcher afterall
        try {
            this.ejbJarInfo = new EJBJarInfo();
            // bind session beans
            EjbJarArchiveMetadata ejbMetadata = this.deployment.getEjbJarArchiveMetadata();
            if (ejbMetadata != null) {
                List<String> beanNames = this.deployment.getEjbJarArchiveMetadata().getBeanNames();
                for (String beanName : beanNames) {
                    for (EasyBeansEjbJarClassMetadata classAnnotationMetadata : this.deployment.getEjbJarArchiveMetadata()
                            .getClassesForBean(beanName)) {
                        Factory<?, ?> factory = null;
                        if (classAnnotationMetadata.isSession()) {
                            factory = createSessionBeanFactory(classAnnotationMetadata);
                        } else if (classAnnotationMetadata.isMdb()) {
                            factory = createMessageDrivenBeanFactory(classAnnotationMetadata);
                        }

                        // Post-Configure the created factories.
                        if (factory != null) {

                            // Adds more runtime info
                            IBeanInfo beanInfo = factory.getBeanInfo();

                            // EJB Name
                            beanInfo.setName(classAnnotationMetadata.getJCommonBean().getName());

                            // Adds security info.
                            beanInfo.setSecurityInfo(SecurityInfoHelper.getSecurityInfo(classAnnotationMetadata));

                            // Adds Business method info.
                            beanInfo.setBusinessMethodsInfo(BusinessMethodsInfoHelper.getMethods(classAnnotationMetadata));

                            // Cluster config
                            beanInfo.setCluster(classAnnotationMetadata.getCluster());

                            // Set invocation context factor

                            if (Boolean.getBoolean("easybeans.dynamicinterceptors")) {
                              factory.setInvocationContextFactory(new EasyBeansInvocationContextFactory(classAnnotationMetadata,
                                   this.classLoader));
                            }
                            // Sets the bean info
                            this.ejbJarInfo.addBeanInfo(beanInfo);

                            // Build java: Context
                            Context javaContext;
                            try {
                                javaContext = JavaContextHelper.build(classAnnotationMetadata, factory, eventDispatcher);
                            } catch (JavaContextHelperException e) {
                                throw new EZBContainerException("Cannot build environment", e);
                            }

                            // Set java: context
                            factory.setJavaContext(javaContext);

                            // Add Management
                            try {
                                MBeansHelper.getInstance().registerMBean(factory);
                            } catch (MBeansException me) {
                                throw new EZBContainerException("Cannot register the factory MBean", me);
                            }

                            // Pool config
                            poolConfiguration(factory, classAnnotationMetadata);

                            // Init factory
                            try {
                                factory.init();
                            } catch (FactoryException e) {
                                throw new EZBContainerException("Cannot initialize the factory.", e);
                            }

                            // Add the factory to the managed factories
                            this.factories.put(beanName, factory);

                        }
                    }
                }
                //Register clustered beans if necessary.
                eventDispatcher.dispatch(new EventLifeCycleClusteredBean(Embedded.NAMING_EXTENSION_POINT,
                        EZBClusteredBeanEvent.STARTING, this.bindingReferences));

                // Bind references only once
                bindReferences();

                // Permission Manager.
                try {
                    this.permissionManager = new PermissionManager(getArchive().getURL(), this.ejbJarInfo);
                    // translate metadata into permission
                    this.permissionManager.translateMetadata();
                    // commit
                    this.permissionManager.commit();
                } catch (PermissionManagerException e) {
                    throw new EZBContainerException("Cannot create permission manager", e);
                } catch (ArchiveException e) {
                    throw new EZBContainerException("Cannot create permission manager", e);
                }

            }
        } finally {
            eventDispatcher.stop();
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

                EZBContainerCallbackInfo info = getContainer3CallbackInfo();
                for (EZBContainerLifeCycleCallback lifeCycleCallback : lifeCycleCallbacks) {
                    try {
                        lifeCycleCallback.beforeBind(info, reference);
                    } catch (LifeCycleCallbackException e) {
                        throw new EZBContainerException("Cannot invoke the callback before binding.", e);
                    }
                }
            }

            // Bind it
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

        // get Activation spec object
        ActivationSpec activationSpec = null;
        try {
            activationSpec = (ActivationSpec) new InitialContext().lookup(activationSpecName);
        } catch (NamingException e1) {
            throw new EZBContainerException("Cannot get the activation spec with the name '"
                    + activationSpecName + "'.", e1);
        }

        // Marshall the given object in order to be sure to get a new Object each time
        if (activationSpec instanceof Serializable) {
            byte[] byteArgs;
            try {
                byteArgs = storeObject((Serializable) activationSpec);
            } catch (IOException e) {
                throw new EZBContainerException("Cannot serialize the activation spec object '" + activationSpec + "'.", e);
            }

            // Then load object from this array of bytes
            try {
                activationSpec = (ActivationSpec) loadObject(byteArgs);
            } catch (IOException e) {
               throw new EZBContainerException("Cannot load activation spec from the serialized object.", e);
            } catch (ClassNotFoundException e) {
                throw new EZBContainerException("Cannot load activation spec from the serialized object.", e);
            }

        }

        // get ResourceAdapter object
        ResourceAdapter resourceAdapter = null;
        try {
            resourceAdapter = MDBResourceAdapterHelper.getResourceAdapter(activationSpecName,
                    (Embedded) getConfiguration().getEZBServer());
        } catch (ResourceException e) {
            throw new EZBContainerException("Cannot get the resource adapter for this MDB factory", e);
        }

        // Associate Resource Adapter with ActivationSpec object (if not set)
        if (activationSpec.getResourceAdapter() == null) {
            try {
                activationSpec.setResourceAdapter(resourceAdapter);
            } catch (ResourceException e) {
                throw new EZBContainerException("Cannot associate resource adapter with activation spec object", e);
            }
        }

        // Get JMS Component
        JMSComponent jmsComponent = null;
        jmsComponent = getEmbedded().getComponent(JMSComponent.class);

        // Create factory
        MDBMessageEndPointFactory mdbMessageEndPointFactory = null;
        try {
            mdbMessageEndPointFactory = new MDBMessageEndPointFactory(className, this, activationSpec, resourceAdapter,
                    jmsComponent);
        } catch (FactoryException e) {
            throw new EZBContainerException("Cannot build the MDB MessageEndPoint factory", e);
        }

        // build runtime information
        MessageDrivenInfo messageDrivenInfo = new MessageDrivenInfo();
        messageDrivenInfo.setApplicationExceptions(messageDrivenBean.getEjbJarDeployableMetadata().getApplicationExceptions());
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

        if (sessionBean.isStateless()) {
            try {
                sessionFactory = new StatelessSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateless factory", fe);
            }
        } else if (sessionBean.isStateful()) {
            try {
                sessionFactory = new StatefulSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateful factory", fe);
            }
        } else if (sessionBean.isSingleton()) {
            try {
                sessionFactory = new SingletonSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateful factory", fe);
            }
        } else {
            throw new EZBContainerException("unknown session type for: " + sessionBean);
        }

        // Build runtime information
        SessionBeanInfo sessionBeanInfo = new SessionBeanInfo();
        sessionBeanInfo.setTransactionManagementType(sessionBean.getTransactionManagementType());
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

                                               final SessionFactory<?> factory) throws EZBContainerException {
        String itfClsName = remoteHome.replace('/', '.');
        try {
            this.classLoader.loadClass(itfClsName);
        } catch (ClassNotFoundException e) {
            throw new EZBContainerException(
                    "Cannot find the class '" + remoteHome + "' in Classloader '" + this.classLoader + "'.", e);
        }

        // get the name of the Remote Interface
        String remoteInterface = bean.getRemoteInterface();
View Full Code Here

Examples of org.ow2.easybeans.api.EZBContainerException

                                                   final SessionFactory<?> factory) throws EZBContainerException {
        String itfClsName = itf.replace('/', '.');
        try {
            this.classLoader.loadClass(itfClsName);
        } catch (ClassNotFoundException e) {
            throw new EZBContainerException(
                    "Cannot find the class '" + itf + "' in Classloader '" + this.classLoader + "'.", e);
        }

        // Build a reference
        EJBLocalHomeCallRef ejbLocalHomeCallRef = new EJBLocalHomeCallRef(itfClsName, embeddedId, containerID, factoryName, bean
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.