Search in sources :

Example 16 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class TxBridgeInboundRecoveryService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    // XTS expects the TCCL to be set to something that will locate the XTS service implementation classes.
    final ClassLoader loader = TxBridgeInboundRecoveryService.class.getClassLoader();
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(loader);
    try {
        InboundBridgeRecoveryManager service = new InboundBridgeRecoveryManager();
        try {
            service.start();
        } catch (Exception e) {
            throw XtsAsLogger.ROOT_LOGGER.txBridgeInboundRecoveryServiceFailedToStart();
        }
        inboundBridgeRecoveryManager = service;
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged((ClassLoader) null);
    }
}
Also used : InboundBridgeRecoveryManager(org.jboss.jbossts.txbridge.inbound.InboundBridgeRecoveryManager) StartException(org.jboss.msc.service.StartException)

Example 17 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class ApplicationClientStartService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    final ServiceContainer serviceContainer = context.getController().getServiceContainer();
    thread = new Thread(new Runnable() {

        @Override
        public void run() {
            final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
            try {
                try {
                    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
                    applicationClientDeploymentServiceInjectedValue.getValue().getDeploymentCompleteLatch().await();
                    NamespaceContextSelector.setDefault(namespaceContextSelectorInjectedValue);
                    try {
                        //perform any additional setup that may be needed
                        for (SetupAction action : setupActions) {
                            action.setup(Collections.<String, Object>emptyMap());
                        }
                        //do static injection etc
                        instance = applicationClientComponent.getValue().createInstance();
                        mainMethod.invoke(null, new Object[] { parameters });
                    } finally {
                        final ListIterator<SetupAction> iterator = setupActions.listIterator(setupActions.size());
                        Throwable error = null;
                        while (iterator.hasPrevious()) {
                            SetupAction action = iterator.previous();
                            try {
                                action.teardown(Collections.<String, Object>emptyMap());
                            } catch (Throwable e) {
                                error = e;
                            }
                        }
                        if (error != null) {
                            throw new RuntimeException(error);
                        }
                    }
                } catch (Exception e) {
                    ROOT_LOGGER.exceptionRunningAppClient(e, e.getClass().getSimpleName());
                } finally {
                    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
                }
            } finally {
                serviceContainer.shutdown();
            }
        }
    });
    thread.start();
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            if (serviceContainer != null) {
                serviceContainer.shutdown();
            }
        }
    }));
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) SetupAction(org.jboss.as.server.deployment.SetupAction) StartException(org.jboss.msc.service.StartException)

Example 18 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class ChannelBuilder method start.

@Override
public void start(StartContext context) throws StartException {
    try {
        this.channel = this.factory.getValue().createChannel(this.name);
    } catch (Exception e) {
        throw new StartException(e);
    }
    if (JGroupsLogger.ROOT_LOGGER.isTraceEnabled()) {
        String output = this.channel.getProtocolStack().printProtocolSpec(true);
        JGroupsLogger.ROOT_LOGGER.tracef("JGroups channel %s created with configuration:%n %s", this.name, output);
    }
    if (this.channel instanceof JChannel) {
        JChannel channel = (JChannel) this.channel;
        channel.enableStats(this.statisticsEnabled);
        if (this.server != null) {
            try {
                JmxConfigurator.registerChannel((JChannel) this.channel, this.server.getValue(), this.name);
            } catch (Exception e) {
                JGroupsLogger.ROOT_LOGGER.debug(e.getLocalizedMessage(), e);
            }
        }
    }
    try {
        this.channel.connect(this.cluster.getValue());
    } catch (Exception e) {
        throw new StartException(e);
    }
}
Also used : JChannel(org.jgroups.JChannel) StartException(org.jboss.msc.service.StartException) StartException(org.jboss.msc.service.StartException) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 19 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class DistributedWorkManagerService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName());
    ChannelFactory factory = this.jGroupsChannelFactory.getValue();
    JGroupsTransport transport = new ForkChannelTransport(factory);
    try {
        transport.setChannel(factory.createChannel(this.value.getName()));
        transport.setClusterName(this.value.getName());
        this.value.setTransport(transport);
    } catch (Exception e) {
        ROOT_LOGGER.trace("failed to start JGroups channel", e);
        throw ROOT_LOGGER.failedToStartJGroupsChannel(this.value.getName(), this.value.getName());
    }
    BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue();
    if (longRunning != null) {
        this.value.setLongRunningThreadPool(longRunning);
        this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
    } else {
        this.value.setLongRunningThreadPool((BlockingExecutor) executorShort.getValue());
        this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
    }
    this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue()));
    WorkManagerCoordinator.getInstance().registerWorkManager(value);
    try {
        transport.startup();
    } catch (Throwable throwable) {
        ROOT_LOGGER.trace("failed to start DWM transport:", throwable);
        throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName());
    }
    if (this.value.isElytronEnabled()) {
        this.value.setSecurityIntegration(new ElytronSecurityIntegration());
    } else {
        this.value.setSecurityIntegration(new PicketBoxSecurityIntegration());
    }
    ROOT_LOGGER.debugf("Started JCA DistributedWorkManager: ", value.getName());
}
Also used : JGroupsTransport(org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport) PicketBoxSecurityIntegration(org.jboss.jca.core.security.picketbox.PicketBoxSecurityIntegration) ForkChannelTransport(org.jboss.as.connector.services.workmanager.transport.ForkChannelTransport) ElytronSecurityIntegration(org.jboss.as.connector.security.ElytronSecurityIntegration) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory) XATerminatorImpl(org.jboss.jca.core.tx.jbossts.XATerminatorImpl) StartException(org.jboss.msc.service.StartException) BlockingExecutor(org.jboss.threads.BlockingExecutor)

Example 20 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class EjbIIOPService method start.

public synchronized void start(final StartContext startContext) throws StartException {
    try {
        final RiverMarshallerFactory factory = new RiverMarshallerFactory();
        final MarshallingConfiguration configuration = new MarshallingConfiguration();
        configuration.setClassResolver(ModularClassResolver.getInstance(serviceModuleLoaderInjectedValue.getValue()));
        this.configuration = configuration;
        this.factory = factory;
        final TransactionManager jtsTransactionManager = transactionManagerInjectedValue.getValue().getTransactionManager();
        assert !(jtsTransactionManager instanceof ContextTransactionManager);
        // Should create a CORBA interface repository?
        final boolean interfaceRepositorySupported = false;
        // Build binding name of the bean.
        final EJBComponent component = ejbComponentInjectedValue.getValue();
        final String earApplicationName = component.getEarApplicationName();
        if (iiopMetaData != null && iiopMetaData.getBindingName() != null) {
            name = iiopMetaData.getBindingName();
        } else if (useQualifiedName) {
            if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getComponentName();
            } else {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName();
            }
        } else {
            name = component.getComponentName();
        }
        name = name.replace(".", "_");
        final ORB orb = this.orb.getValue();
        if (interfaceRepositorySupported) {
            // Create a CORBA interface repository for the enterprise bean
            iri = new InterfaceRepository(orb, irPoa.getValue(), name);
            // Add bean interface info to the interface repository
            iri.mapClass(remoteView.getValue().getViewClass());
            iri.mapClass(homeView.getValue().getViewClass());
            iri.finishBuild();
            EjbLogger.ROOT_LOGGER.cobraInterfaceRepository(name, orb.object_to_string(iri.getReference()));
        }
        IORSecurityConfigMetaData iorSecurityConfigMetaData = this.iorSecConfigMetaData.getOptionalValue();
        if (this.iiopMetaData != null && this.iiopMetaData.getIorSecurityConfigMetaData() != null)
            iorSecurityConfigMetaData = this.iiopMetaData.getIorSecurityConfigMetaData();
        // Create security policies if security metadata has been provided.
        List<Policy> policyList = new ArrayList<Policy>();
        if (iorSecurityConfigMetaData != null) {
            // Create csiv2Policy for both home and remote containing IorSecurityConfigMetadata.
            final Any secPolicy = orb.create_any();
            secPolicy.insert_Value(iorSecurityConfigMetaData);
            Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
            policyList.add(csiv2Policy);
            //  Add ZeroPortPolicy if ssl is required (it ensures home and remote IORs will have port 0 in the primary address).
            boolean sslRequired = false;
            if (iorSecurityConfigMetaData != null && iorSecurityConfigMetaData.getTransportConfig() != null) {
                IORTransportConfigMetaData tc = iorSecurityConfigMetaData.getTransportConfig();
                sslRequired = IORTransportConfigMetaData.INTEGRITY_REQUIRED.equals(tc.getIntegrity()) || IORTransportConfigMetaData.CONFIDENTIALITY_REQUIRED.equals(tc.getConfidentiality()) || IORTransportConfigMetaData.ESTABLISH_TRUST_IN_CLIENT_REQUIRED.equals(tc.getEstablishTrustInClient());
            }
            if (sslRequired) {
                policyList.add(ZeroPortPolicy.getPolicy());
            }
        }
        //TODO: what should this default to
        String securityDomain = "CORBA_REMOTE";
        if (component.getSecurityMetaData() != null) {
            securityDomain = component.getSecurityMetaData().getSecurityDomain();
        }
        Policy[] policies = policyList.toArray(new Policy[policyList.size()]);
        // If there is an interface repository, then get the homeInterfaceDef from the IR
        InterfaceDef homeInterfaceDef = null;
        if (iri != null) {
            Repository ir = iri.getReference();
            homeInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(homeRepositoryIds[0]));
        }
        // Get the POACurrent object
        Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
        // Instantiate home servant, bind it to the servant registry, and create CORBA reference to the EJBHome.
        final EjbCorbaServant homeServant = new EjbCorbaServant(poaCurrent, homeMethodMap, homeRepositoryIds, homeInterfaceDef, orb, homeView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), true, securityDomain, component.getSecurityDomain());
        homeServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
        ReferenceFactory homeReferenceFactory = homeServantRegistry.bind(homeServantName(name), homeServant, policies);
        final org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
        //we do this twice to force eager dynamic stub creation
        ejbHome = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
        final HomeHandleImplIIOP homeHandle = new HomeHandleImplIIOP(orb.object_to_string(corbaRef));
        homeServant.setHomeHandle(homeHandle);
        // Initialize beanPOA and create metadata
        // This is a session bean (lifespan: transient)
        beanServantRegistry = poaRegistry.getValue().getRegistryWithTransientPOAPerServant();
        if (component instanceof StatelessSessionComponent) {
            // Stateless session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, true, homeHandle);
        } else {
            // Stateful session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, false, homeHandle);
        }
        homeServant.setEjbMetaData(ejbMetaData);
        // If there is an interface repository, then get the beanInterfaceDef from the IR
        InterfaceDef beanInterfaceDef = null;
        if (iri != null) {
            final Repository ir = iri.getReference();
            beanInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
        }
        // Instantiate the ejb object servant and bind it to the servant registry.
        final EjbCorbaServant beanServant = new EjbCorbaServant(poaCurrent, beanMethodMap, beanRepositoryIds, beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), false, securityDomain, component.getSecurityDomain());
        beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies);
        // Register bean home in local CORBA naming context
        rebind(corbaNamingContext.getValue(), name, corbaRef);
        EjbLogger.ROOT_LOGGER.debugf("Home IOR for %s bound to %s in CORBA naming service", component.getComponentName(), this.name);
        //now eagerly force stub creation, so de-serialization of stubs will work correctly
        final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
            try {
                DynamicStubFactoryFactory.makeStubClass(homeView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(homeView.getValue().getViewClass().getName(), e);
            }
            try {
                DynamicStubFactoryFactory.makeStubClass(remoteView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(remoteView.getValue().getViewClass().getName(), e);
            }
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
        }
    } catch (Exception e) {
        throw new StartException(e);
    }
}
Also used : ZeroPortPolicy(com.sun.corba.se.spi.extension.ZeroPortPolicy) CSIv2Policy(org.wildfly.iiop.openjdk.csiv2.CSIv2Policy) Policy(org.omg.CORBA.Policy) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) ArrayList(java.util.ArrayList) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Any(org.omg.CORBA.Any) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) EJBMetaDataImplIIOP(org.jboss.ejb.iiop.EJBMetaDataImplIIOP) StartException(org.jboss.msc.service.StartException) IORTransportConfigMetaData(org.jboss.metadata.ejb.jboss.IORTransportConfigMetaData) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) StartException(org.jboss.msc.service.StartException) InterfaceDef(org.omg.CORBA.InterfaceDef) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Repository(org.omg.CORBA.Repository) IORSecurityConfigMetaData(org.jboss.metadata.ejb.jboss.IORSecurityConfigMetaData) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) Current(org.omg.PortableServer.Current) ORB(org.omg.CORBA.ORB) HomeHandleImplIIOP(org.jboss.ejb.iiop.HomeHandleImplIIOP)

Aggregations

StartException (org.jboss.msc.service.StartException)43 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ExecutorService (java.util.concurrent.ExecutorService)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 ORB (org.omg.CORBA.ORB)4 InetSocketAddress (java.net.InetSocketAddress)3 PrivilegedAction (java.security.PrivilegedAction)3 HashMap (java.util.HashMap)3 PostInitLoader (com.arjuna.orbportability.internal.utils.PostInitLoader)2 HandlerWrapper (io.undertow.server.HandlerWrapper)2 HttpHandler (io.undertow.server.HttpHandler)2 File (java.io.File)2 AccessControlContext (java.security.AccessControlContext)2 Map (java.util.Map)2 TempClassLoaderFactoryImpl (org.jboss.as.jpa.classloader.TempClassLoaderFactoryImpl)2 SocketBinding (org.jboss.as.network.SocketBinding)2 ModuleLoadException (org.jboss.modules.ModuleLoadException)2 Service (org.jboss.msc.service.Service)2 ServiceContainer (org.jboss.msc.service.ServiceContainer)2