I have started to look into using ant to do some deployment tasks with SOA Suite. I am finding it difficult to actually detect when there is an error using the provided ant-sca-mgmt.xml scripts. So far I have run some tests from the command line with the following commands. This composite does not exist, my desired result would be for this command to show failure. However when I look at the return code I see a value of 0. Looking at the output it is clear there was a problem, but ant still shows a successful build.
ant -f ant-sca-mgmt.xml retireComposite -Duser=$USERNAME -Dpassword=$PASSWORD -Dhost=$SOAHOST \
-Dport=$SOAPORT -DcompositeName=ThisCompositeDoesNotExist -Dpartition=default -Drevision=1.0
/u00/soa/middleware/Oracle_SOA1/bin> ant -f ant-sca-mgmt.xml retireComposite -Duser=$USERNAME -Dpassword=$PASSWORD -Dhost=$SOAHOST \
> -Dport=$SOAPORT -DcompositeName=ThisCompositeDoesNotExist -Dpartition=default -Drevision=1.0
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.101.x86_64/lib/tools.jar
Buildfile: ant-sca-mgmt.xml
[echo] oracle.home = /u00/soa/middleware/Oracle_SOA1/bin/..
retireComposite:
[input] skipping input as property host has already been set.
[input] skipping input as property port has already been set.
[input] skipping input as property user has already been set.
[secure-input] skipping secure-input as property password has already been set.
[input] skipping input as property compositeName has already been set.
[input] skipping input as property revision has already been set.
[echo] oracle.home = /u00/soa/middleware/Oracle_SOA1/bin/..
compositeMgrTask:
[java] Connecting to JMX Server at host: hostname port 8005
[java] Connected successfully to: service:jmx:t3://hostname:8005/jndi/weblogic.management.mbeanservers.runtime
[java] connection initiated
[java] javax.management.MBeanException: The configuration file, deployed-composites.xml, does not contain the default/ThisCompositeDoesNotExist!1.0 composite-revision element.
[java] at oracle.as.jmx.framework.standardmbeans.spi.OracleStandardEmitterMBean.doInvoke(OracleStandardEmitterMBean.java:1025)
[java] at oracle.adf.mbean.share.AdfMBeanInterceptor.internalInvoke(AdfMBeanInterceptor.java:104)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.AbstractMBeanInterceptor.doInvoke(AbstractMBeanInterceptor.java:252)
[java] at oracle.as.jmx.framework.generic.spi.security.AbstractMBeanSecurityInterceptor.internalInvoke(AbstractMBeanSecurityInterceptor.java:190)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.AbstractMBeanInterceptor.doInvoke(AbstractMBeanInterceptor.java:252)
[java] at oracle.security.jps.ee.jmx.JpsJmxInterceptor$2.run(JpsJmxInterceptor.java:358)
[java] at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324)
[java] at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
[java] at oracle.security.jps.ee.jmx.JpsJmxInterceptor.internalInvoke(JpsJmxInterceptor.java:374)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.AbstractMBeanInterceptor.doInvoke(AbstractMBeanInterceptor.java:252)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.ContextClassLoaderMBeanInterceptor.internalInvoke(ContextClassLoaderMBeanInterceptor.java:103)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.AbstractMBeanInterceptor.doInvoke(AbstractMBeanInterceptor.java:252)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.MBeanRestartInterceptor.internalInvoke(MBeanRestartInterceptor.java:116)
[java] at oracle.as.jmx.framework.generic.spi.interceptors.AbstractMBeanInterceptor.doInvoke(AbstractMBeanInterceptor.java:252)
[java] at oracle.as.jmx.framework.standardmbeans.spi.OracleStandardEmitterMBean.invoke(OracleStandardEmitterMBean.java:924)
[java] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
[java] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:762)
[java] at weblogic.management.mbeanservers.internal.JMXContextInterceptor.invoke(JMXContextInterceptor.java:263)
[java] at weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$16.run(WLSMBeanServerInterceptorBase.java:449)
[java] at weblogic.management.mbeanservers.internal.SecurityInterceptor.invoke(SecurityInterceptor.java:444)
[java] at weblogic.management.jmx.mbeanserver.WLSMBeanServer.invoke(WLSMBeanServer.java:323)
[java] at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$11$1.run(JMXConnectorSubjectForwarder.java:663)
[java] at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$11.run(JMXConnectorSubjectForwarder.java:661)
[java] at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder.invoke(JMXConnectorSubjectForwarder.java:654)
[java] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:818)
[java] at javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
[java] at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:668)
[java] at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
[java] at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
[java] at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
[java] Caused by: oracle.fabric.management.deployedcomposites.mbean.CompositeNotFoundException: The configuration file, deployed-composites.xml, does not contain the default/ThisCompositeDoesNotExist!1.0 composite-revision element.
[java] at oracle.fabric.management.deployedcomposites.mbean.CompositeLifecycle.getCompositeRevision(CompositeLifecycle.java:487)
[java] at oracle.fabric.management.deployedcomposites.mbean.CompositeLifecycle.getComposite2(CompositeLifecycle.java:525)
[java] at oracle.fabric.management.deployedcomposites.mbean.CompositeLifecycle.getComposite2(CompositeLifecycle.java:512)
[java] at oracle.fabric.management.deployedcomposites.mbean.CompositeLifecycle.setCompositeMode(CompositeLifecycle.java:322)
[java] at sun.reflect.GeneratedMethodAccessor22564.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at oracle.as.jmx.framework.standardmbeans.spi.OracleStandardEmitterMBean.doInvoke(OracleStandardEmitterMBean.java:1012)
[java] ... 29 more
BUILD SUCCESSFUL
Total time: 0 seconds
I then created a ant script with a target to do this same exact thing. The behavior there was exactly the same. I have attempted to use a try catch similar to the following, but that does not detect the issue that the composite does not actually exist either. I did add the taskdef for the ant-contrib.jar so there were no issues with ant using the trycatch.
<target name="retireComposite">
<trycatch property="tryName" reference="exception_ref">
<try>
<ant antfile="${oracleHome}/bin/ant-sca-mgmt.xml" target="retireComposite" inheritall="false">
<property name="host" value="${env.SOAHOST}"/>
<property name="port" value="${env.SOAPORT}"/>
<property name="user" value="${env.USERNAME}"/>
<property name="password" value="${env.PASSWORD}"/>
<property name="compositeName" value="DoesNotActuallyExist"/>
<property name="partition" value="default"/>
<property name="revision" value="1.0"/>
</ant>
</try>
<catch>
<property name="exception" refid="exception_ref" />
<property name="message" value="ERROR IN TRYCATCH BLOCK:${line.separator}${exception}" />
<echo>=========================</echo>
<echo message="${message}" />
</catch>
</trycatch>
</target>
Does anyone know how you can catch failures like this in an ant script?