Search in sources :

Example 26 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ActiveJmsResourceAdapter method loadRAConfiguration.

/**
 * Loads RA configuration for MQ Resource adapter.
 *
 * @throws ConnectorRuntimeException in case of an exception.
 */
@Override
protected void loadRAConfiguration() throws ConnectorRuntimeException {
    JmsService jmsService = getJmsService();
    if (jmsService != null && jmsService.getType().equals("DISABLED")) {
        throw new ConnectorRuntimeException("JMS Broker is Disabled");
    }
    if (connectorRuntime.isServer()) {
        // Check whether MQ has started up or not.
        try {
            // if (!JmsProviderLifecycle.shouldUseMQRAForLifecycleControl()) {
            // JmsProviderLifecycle.checkProviderStartup();
            // } else {
            setLifecycleProperties();
        // }
        } catch (Exception e) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
            throw (ConnectorRuntimeException) cre.initCause(e);
        }
        setMdbContainerProperties();
        setJmsServiceProperties(null);
        setClusterRABeanProperties();
        setAvailabilityProperties();
    } else {
        setAppClientRABeanProperties();
    }
    super.loadRAConfiguration();
    postRAConfiguration();
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 27 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ActiveJmsResourceAdapter method getPhysicalDestinationFromConfiguration.

private String getPhysicalDestinationFromConfiguration(String logicalDest, String appName, String moduleName) throws ConnectorRuntimeException {
    Property ep = null;
    try {
        // ServerContext sc = ApplicationServer.getServerContext();
        // ConfigContext ctx = sc.getConfigContext();
        // Resources rbeans =                           ServerBeansFactory.getDomainBean(ctx).getResources();
        AdminObjectResource res = null;
        res = (AdminObjectResource) ResourcesUtil.createInstance().getResource(logicalDest, appName, moduleName, AdminObjectResource.class);
        // AdminObjectResource res = (AdminObjectResource)   allResources.getAdminObjectResourceByJndiName(logicalDest);
        if (res == null) {
            String msg = sm.getString("ajra.err_getting_dest", logicalDest);
            throw new ConnectorRuntimeException(msg);
        }
        // getElementPropertyByName(PHYSICAL_DESTINATION);
        ep = res.getProperty(PHYSICAL_DESTINATION);
    } catch (Exception ce) {
        String msg = sm.getString("ajra.err_getting_dest", logicalDest);
        ConnectorRuntimeException cre = new ConnectorRuntimeException(msg);
        cre.initCause(ce);
        throw cre;
    }
    if (ep == null) {
        String msg = sm.getString("ajra.cannot_find_phy_dest", null);
        throw new ConnectorRuntimeException(msg);
    }
    return ep.getValue();
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) Property(org.jvnet.hk2.config.types.Property) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 28 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class JMSDestination method getMQJMXConnectorInfos.

protected MQJMXConnectorInfo[] getMQJMXConnectorInfos(final String target, final Config config, final ServerContext serverContext, final Domain domain, ConnectorRuntime connectorRuntime) throws ConnectorRuntimeException {
    try {
        final JmsService jmsService = config.getExtensionByType(JmsService.class);
        ActiveJmsResourceAdapter air = getMQAdapter(connectorRuntime);
        final Class mqRAClassName = air.getResourceAdapter().getClass();
        final CommandTarget ctarget = this.getTypeForTarget(target);
        MQJMXConnectorInfo mqjmxForServer = (MQJMXConnectorInfo) java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {

            public java.lang.Object run() throws Exception {
                if (ctarget == CommandTarget.CLUSTER || ctarget == CommandTarget.CLUSTERED_INSTANCE) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "Getting JMX connector for" + " cluster target " + target);
                    }
                    return _getMQJMXConnectorInfoForCluster(target, jmsService, mqRAClassName, serverContext);
                } else {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "Getting JMX connector for" + " standalone target " + target);
                    }
                    return _getMQJMXConnectorInfo(target, jmsService, mqRAClassName, serverContext, config, domain);
                }
            }
        });
        return new MQJMXConnectorInfo[] { mqjmxForServer };
    } catch (Exception e) {
        // e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) CommandTarget(org.glassfish.config.support.CommandTarget) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 29 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class JMSDestination method _getMQJMXConnectorInfo.

protected MQJMXConnectorInfo _getMQJMXConnectorInfo(String targetName, JmsService jmsService, Class mqRAClassName, ServerContext serverContext, Config config, Domain domain) throws ConnectorRuntimeException {
    try {
        // If DAS, use the default address list, else obtain
        String connectionURL = null;
        MQAddressList mqadList = new MQAddressList();
        if (getTypeForTarget(targetName) == CommandTarget.DAS) {
            connectionURL = getDefaultAddressList(jmsService).toString();
        } else {
            // Standalone server instance
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "not in DAS");
                logger.log(Level.FINE, " _getMQJMXConnectorInfo - NOT in DAS");
            }
            JmsService serverJmsService = getJmsServiceOfStandaloneServerInstance(targetName, config, domain);
            // MQAddressList mqadList = new MQAddressList(serverJmsService, targetName);
            mqadList.setJmsService(serverJmsService);
            mqadList.setTargetName(targetName);
            mqadList.setup(false);
            connectionURL = mqadList.toString();
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - connection URL " + connectionURL);
        }
        String adminUserName = null;
        String adminPassword = null;
        JmsHost jmsHost = mqadList.getDefaultJmsHost(jmsService);
        if (jmsHost != null) {
            // && jmsHost.isEnabled()) {
            adminUserName = jmsHost.getAdminUserName();
            adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
        } else {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, " _getMQJMXConnectorInfo, using default jms admin user and password ");
            }
        }
        ResourceAdapter raInstance = getConfiguredRA(mqRAClassName, connectionURL, adminUserName, adminPassword);
        String jmxServiceURL = null, jmxServiceURLList = null;
        Map<String, ?> jmxConnectorEnv = null;
        Method[] methds = raInstance.getClass().getMethods();
        for (int i = 0; i < methds.length; i++) {
            Method m = methds[i];
            if (m.getName().equalsIgnoreCase("get" + JMXSERVICEURLLIST)) {
                jmxServiceURLList = (String) m.invoke(raInstance, new Object[] {});
            } else if (m.getName().equalsIgnoreCase("get" + JMXCONNECTORENV)) {
                jmxConnectorEnv = (Map<String, ?>) m.invoke(raInstance, new Object[] {});
            }
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxServiceURLList " + jmxServiceURLList);
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxConnectorEnv " + jmxConnectorEnv);
        }
        jmxServiceURL = getFirstJMXServiceURL(jmxServiceURLList);
        MQJMXConnectorInfo mqInfo = new MQJMXConnectorInfo(targetName, ActiveJmsResourceAdapter.getBrokerInstanceName(jmsService), jmsService.getType(), jmxServiceURL, jmxConnectorEnv);
        return mqInfo;
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) Method(java.lang.reflect.Method) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ResourceAdapter(javax.resource.spi.ResourceAdapter) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 30 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class MQJMXConnectorInfo method getMQMBeanServerConnection.

/**
 * Returns an <code>MBeanServerConnection</code> representing the MQ broker instance's MBean
 * server.
 * @return
 * @throws ConnectorRuntimeException
 */
// XXX:Enhance to support SSL (once MQ team delivers support in the next drop)
// XXX: Discuss how <code>ConnectionNotificationListeners</code> could
// be shared with the consumer of this API
public MBeanServerConnection getMQMBeanServerConnection() throws ConnectorRuntimeException {
    try {
        if (getJMXServiceURL() == null || getJMXServiceURL().equals("")) {
            String msg = localStrings.getLocalString("error.get.jmsserviceurl", "Failed to get MQ JMXServiceURL of {0}.", getASInstanceName());
            throw new ConnectorRuntimeException(msg);
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "creating MBeanServerConnection to MQ JMXServer with " + getJMXServiceURL());
        }
        JMXServiceURL jmxServiceURL = new JMXServiceURL(getJMXServiceURL());
        connector = JMXConnectorFactory.connect(jmxServiceURL, this.jmxConnectorEnv);
        // XXX: Do we need to pass in a Subject?
        MBeanServerConnection mbsc = connector.getMBeanServerConnection();
        return mbsc;
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JMXServiceURL(javax.management.remote.JMXServiceURL) MBeanServerConnection(javax.management.MBeanServerConnection) IOException(java.io.IOException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)71 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)13 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)10 PrivilegedActionException (java.security.PrivilegedActionException)9 ExecutionException (java.util.concurrent.ExecutionException)8 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)8 MultiException (org.glassfish.hk2.api.MultiException)8 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)7 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)5 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)5 IOException (java.io.IOException)5 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)4 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)3