Wednesday, April 29, 2015

How to get the audit level settings of a Composite through Java - Oracle SOA Suite

How to get the audit level settings of a Composite through Java - Oracle SOA Suite

This blog will explain how to get the audit level settings of a Composite through Java in Oracle SOA Suite

import java.util.Hashtable;
import java.util.Set;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import javax.naming.Context;

import oracle.fabric.composite.model.CompositeNameModel;

public class GetCompositeAuditLevel {
    static MBeanServerConnection m_connection = null;

    public static String getCompositeAuditLevel(String compositeName,String version) throws Exception {
        String auditLevel = "";
        String mBeanName = "*:j2eeType=SCAComposite,revision=" + version + ",*,name=\"" + compositeName + "\"";
        Set<ObjectName> mbeans = m_connection.queryNames(new ObjectName(mBeanName), null);
        System.out.println(mbeans);
        ObjectName mbean = (ObjectName)mbeans.iterator().next();
        javax.management.openmbean.CompositeData[] properties =(javax.management.openmbean.CompositeData[])m_connection.getAttribute(mbean,"Properties");
        if (properties.length > 0) {
            for (int i = 0; i < properties.length; i++) {
                CompositeDataSupport cds = (CompositeDataSupport)properties[i];
                if (cds.get("name").equals("auditLevel")) {
                    auditLevel = (String)cds.get("value");
                    break;
                }
                auditLevel = "Inherit";
            }
        }
        if (auditLevel.equals("Inherit")) {
            auditLevel = getSOAINFRAAuditLevel();
        }
        return auditLevel;
    }

    public static String getSOAINFRAAuditLevel() throws Exception {
        String auditLevel = "";
        String mBeanName ="*:*,name=soa-infra,type=SoaInfraConfig,Application=soa-infra";
        Set<ObjectName> mbeans = m_connection.queryNames(new ObjectName(mBeanName), null);
        ObjectName mbean = (ObjectName)mbeans.iterator().next();
        auditLevel = (String)m_connection.getAttribute(mbean, "AuditLevel");
        return auditLevel;
    }


    public static String getDefaultCompositeRevision(String partiitionName,
                                                     String compositeName) throws Exception {
        ObjectName compositeLifeCycleMBean = null;
        Set queryResult = m_connection.queryNames(new ObjectName("*:j2eeType=CompositeLifecycleConfig,*"), null);
        if (!queryResult.isEmpty()) {
            compositeLifeCycleMBean =(ObjectName)queryResult.iterator().next();
        }
        //CompositeDN - DomainName/CompositeName
        String compositeDN = partiitionName + '/' + compositeName;
        String revision = null;
        CompositeData deployedComposite =(CompositeData)m_connection.invoke(compositeLifeCycleMBean, "getDefaultComposite",
                                               new Object[] { compositeDN },
                                               new String[] { String.class.getName() });
        if (deployedComposite != null) {
            CompositeNameModel cm = CompositeNameModel.parseDN((String)deployedComposite.get("DN"));
            revision = cm.getRevision();
        }
        return revision;
    }

    public static MBeanServerConnection getMbeanServerConnection(String host,int port,String userName,
                                                                 String password) throws Exception {
        String jndiroot = "/jndi/";
        MBeanServerConnection m_connection = null;
        try {
            Hashtable jndiProps = new Hashtable();
            jndiProps.put(Context.SECURITY_PRINCIPAL, userName);
            jndiProps.put(Context.SECURITY_CREDENTIALS, password);
            jndiProps.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");

            JMXServiceURL serviceURL =new JMXServiceURL("t3", host, port, jndiroot +"weblogic.management.mbeanservers.runtime");
            JMXConnector m_connector =JMXConnectorFactory.newJMXConnector(serviceURL, jndiProps);
            m_connector.connect();
            m_connection = m_connector.getMBeanServerConnection();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return m_connection;
    }


    public static void main(String[] args) {
        try {
            m_connection =getMbeanServerConnection("localhost", 7001,"weblogic", "welcome1");
            String defaultVersion =getDefaultCompositeRevision("default", "TestComposite");
            String auditLevel=getCompositeAuditLevel("TestComposite", defaultVersion);
             System.out.println("auditLevel:"+auditLevel);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

Jar files required in the class path:

  • SOA Runtime jars 
  • weblogic.jar


Tuesday, April 28, 2015

Multipart Message Support in Oracle BPEL

Multipart Message Support in Oracle SOA Suite BPEL component.



Multipart_Message_Support_OracleBPEL.pdf


Saturday, April 18, 2015

How to change the SOAINFRA Schema in Oracle SOA Suite 11g?

This post will explains how to change the SOAINFRA schema in Oracle SOA Suite 11g



Wednesday, February 18, 2015

The Admin console is not up/accessible – Oracle SOA Suite

The Admin console is not up/accessible –  Oracle SOA Suite

We were facing a strange issue in our Oracle SOA Suite production server in Solaris, we could not able to access the admin console even though the server is started properly and there is no error in the log file.

We were able to telnet the admin server listen address from Admin server node but not able to do it from other nodes.

The root cause of the issue is with Gateway server, the admin server listen address is not listed on the Gateway - the gateway server is not online (the servers listen address is configured in Gateway).

After Solaris admin team made the Gateway server online, we were able to see the admin server listen address listed on the gateway.

After restarting the admin server we were able to access the console page.

The following command can be used for checking the Gateway server status

 netstat –r  


Saturday, December 13, 2014

java.net.ConnectException,Bootstrap to server failed while deploying the compoite - Orace SOA Suite

 java.net.ConnectException,Bootstrap to server failed while deploying the compoite - Orace SOA Suite

Sometimes we may receive the following exception while deploying the composite to Oracle SOA Suite server using even though the sever is running fine and reachable.

oracle.rc.asadapter.connection.ConnectionException
at oracle.rc.asadapter.weblogic.connection.spi.Weblogic10JndiProvider.getPresentation(Weblogic10JndiProvider.java:86)

Caused by: javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3://127.0.0.1:8000: Bootstrap to localhost/127.0.0.1:8000 failed. It is likely that the remote side declared peer gone on this JVM]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:40)

Caused by: java.net.ConnectException: t3://127.0.0.1:8000: Bootstrap to localhost/127.0.0.1:8000 failed. It is likely that the remote side declared peer gone on this JVM

Caused by: java.rmi.ConnectException: Bootstrap to localhost/127.0.0.1:8000 failed. It is likely that the remote side declared peer gone on this JVM
at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:334)


This issue can be resolved by configuring valid machine IP or complete name of the machines, including the domain extension as listen address in weblogic server.