Pages

Thursday, November 25, 2010

Start or Stop your SOA Suite 11g Composite in Java

In this short blogpost I will show you how can execute operations on a SOA Suite 11g Composite in java. The operations are start, stop, activate, retire, set the default version and list all the deployed composites.

I use for this the oracle.fabric.management.deployedcomposites.CompositeManager class ( located in the fabric runtime ) with its static methods.
The SOA ANT scripts also uses this class or you can do it yourself by looking up the right Composite MBean and invoke the same operations.

Before PS2 you could lookup the composite and call the start/ stop methods, but this not working anymore so now you need to use this ( or use the EM or the MBeans )
package nl.whitehorses.soa.client;

import oracle.fabric.management.deployedcomposites.CompositeManager;

public class ActivateComposite {

    public static void main(String[] args) {
      try {
           CompositeManager.initConnection("localhost", "8001", "weblogic", "weblogic1");

           CompositeManager.assignDefaultComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/Helloworld!1.0");

           CompositeManager.stopComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/Helloworld!1.0");

           CompositeManager.startComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/Helloworld!1.0");

           CompositeManager.activateComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/Helloworld!1.0");

           CompositeManager.retireComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/Helloworld!1.0");

           System.out.println(CompositeManager.listDeployedComposites(CompositeManager.getCompositeLifeCycleMBean()));

           CompositeManager.closeConnection(); 

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

With this as result.
Connecting to: service:jmx:t3://localhost:8001/jndi/weblogic.management.mbeanservers.runtime

Following 5 composites are currently deployed to the platform:

1. HttpBinding[1.0], mode=active, state=on, isDefault=true, deployedTime=2010-08-20T22:42:58.888+02:00
2. SoaSpring[1.0], mode=active, state=on, isDefault=true, deployedTime=2010-07-10T15:41:07.640+02:00
3. bpm[1.0], mode=active, state=on, isDefault=true, deployedTime=2010-07-10T15:58:13.853+02:00
4. Helloworld[1.0], mode=retired, state=on, isDefault=true, deployedTime=2010-09-22T02:37:50.924+02:00
5. BPELCorrelation[1.0], mode=active, state=on, isDefault=true, deployedTime=2010-09-01T22:14:59.374+02:00

8 comments:

  1. HI Edwin,

    We are trying to use the JAVA code which you shared for "Start or Stop your SOA Suite 11g Composite in Java", but it didn't worked for me.

    I have copied the fabric-runtime.jar in the classpath, but when i am trying to run it i am getting a malformed exception.

    So i have copied "wljmxclient.jar" that resolved me the malformed exception.

    Now still, i am not able to run it successfully as i am seeing "java.lang.NoClassDefFoundError: weblogic/rmi/extensions/DisconnectListen"

    Could you please help me in this regard. and suggest me how to proceed?

    Thanks,
    Sri

    ReplyDelete
    Replies
    1. Hi,

      Can you generate a wlfullclient jar , this one jar of 50mb contains all the necessary classes you need.

      cd WL_HOME/server/lib
      java -jar wljarbuilder.jar
      Add the wlfullclient.jar to the client application's classpath.

      Thanks

      Delete
  2. Hi Edwin,

    I've also tried with wlfullclient.jar in classpath but I am not able to see changes. Please advise.

    Thanks,
    Maulik

    ReplyDelete
  3. I just got it working. We need soa-infra-mgmt.jar in classpath as CompositeManager class is referred from that jar only.

    ReplyDelete
  4. Hi Edwin,

    I am using your above code and added all jars to my classpath.

    =============
    CompositeManager.initConnection("vmwsoaapp11-dev", "8001", "user", "password");
    System.out.println(CompositeManager.getCompositeLifeCycleMBean());
    // CompositeManager.assignDefaultComposite(CompositeManager.getCompositeLifeCycleMBean(), "SFDC_OPTYMGMT/SyncOpptyRespSFDCProvABCSImpl!1.0.0");
    CompositeManager.stopComposite(CompositeManager.getCompositeLifeCycleMBean(), "default/SFDC_WSDL!1.0");
    System.out.println(CompositeManager.listDeployedComposites(CompositeManager.getCompositeLifeCycleMBean()));
    CompositeManager.closeConnection();
    =============

    But i am getting the runtime error mention below
    and it seems -
    "null" value is returning from "CompositeManager.getCompositeLifeCycleMBean()",

    Error-
    Connecting to: service:jmx:t3://vmwsoaapp11-dev:8001/jndi/weblogic.management.mbeanservers.runtime
    null
    javax.management.RuntimeOperationsException
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
    at javax.management.remote.rmi.RMIConnectionImpl_1036_WLStub.invoke(Unknown Source)
    at weblogic.management.remote.common.RMIConnectionWrapper$15.run(ClientProviderBase.java:709)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.security.Security.runAs(Security.java:61)
    at weblogic.management.remote.common.RMIConnectionWrapper.invoke(ClientProviderBase.java:707)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(Unknown Source)
    at oracle.fabric.management.deployedcomposites.CompositeManager.stopComposite(CompositeManager.java:90)
    at ActivateComposite.main(ActivateComposite.java:10)
    Caused by: java.lang.IllegalArgumentException: ObjectName must not be null
    at javax.management.remote.rmi.RMIConnectionImpl.checkNonNull(RMIConnectionImpl.java:1643)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:785)
    at javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:252)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

    Could you please help me.

    Thanks,
    Mukesh

    ReplyDelete
    Replies
    1. Hi,

      Does the "SFDC_OPTYMGMT/SyncOpptyRespSFDCProvABCSImpl!1.0.0"
      or "default/SFDC_WSDL!1.0" exists

      maybe you can look at the MBean browser of the EM and do it from there to check if it works

      Thanks

      Delete
  5. Even I am seeing the same problem - "null" value is returning from "CompositeManager.getCompositeLifeCycleMBean()" !! I have two jars - wlfullclient.jar and oa-infra-mgmt.jar in the classpath.
    Any clue what else is needed?

    ReplyDelete
    Replies
    1. Hi

      is oa-infra-mgmt.jar the right jar.?, oa is a bit strange
      Mostly it is the name ( start with partition / composite name / !version )

      Thanks

      Delete