With Soa Suite 11g we can add unit tests (test suites) to our composite applications and start these tests with the ant scripts provided by Oracle. The soa test ant script can start and generate an junit xml which can be read for the result of the test. For more info see my previous blogpost about the ant scripts and the testsuite option in Soa Suite 11g.
So the last step is to combine the test suite feature and the ant scripts of mine and Oracle so we can use it in a continuous build system. I will use Hudson for this.
We start by downloading the lastest hudson war.
Start hudson by setting the java home and path
set JAVA_HOME=c:\java\jdk160_05
set PATH=%JAVA_HOME%\bin;%PATH
java -jar hudson.war
this will start Hudson and open a browser and go to http://localhost:8080.
First we install Hudson as a windows service. Just provide the location. I will use c:\java\hudson
This will restart hudson. Now we can configure Hudson
Provide the ant and java location of the jdeveloper 11g R1 home.
Put the soa projects and ant scripts in subversion, so Hudson can check this out
This is how it looks. Very important my ant scripts need this folder paths.
Now we can create a new job.
Configure this new job. We start by adding the svn url.
Then add the ant script ( build.xml ) and fill the target ( deployAll) and for the oracle ant scripts we need to set the basedir java parameter to the jdeveloper bin folder.
And provide the location where Hudson can find the junit xml files.
Now we have to add ant-contrib-1.0XXXX.jar the to the jdeveloper\ant\lib folder and add a environment variable to the ant.bat
set CURRENT_FOLDER=%CD%
I need this for the ant scripts so I can use relative paths.
Let's press build now and look at the result. My example composite application contains two tests, in my case they are both succesfull.
Look at the test.
And the performance.
That's all. This will save you a lot of testing time and off course Hudson can blame the person who checked in as last.
Here is my test project and ant scripts
hi,
ReplyDeletei configured the Oracle SOA with Hudson but i got the following error,please give me solution for this ( Cannot find ${oracle.home}/integration/bpel....)
Started by user anonymous
Updating https://localhost/svn/OracleFusion/trunk
At revision 58
no change for https://localhost/svn/OracleFusion/trunk since the previous build
[ant] $ cmd.exe /C '"C:\Oracle\Middleware\jdeveloper\ant\bin\ant.bat -file build.xml deployAll && exit %%ERRORLEVEL%%"'
Buildfile: build.xml
BUILD FAILED
C:\Documents and Settings\subbu\.hudson\jobs\NewJob\workspace\trunk\tools\ant\build.xml:25: Cannot find ${oracle.home}/integration/bpel/utilities/ant-orabpel.xml imported from C:\Documents and Settings\subbu\.hudson\jobs\NewJob\workspace\trunk\tools\ant\build.xml
Total time: 2 seconds
Finished: FAILURE
Hi,
ReplyDeleteDid you install jdeveloper with the soasuite addon on the hudson server and make sure you set the basedir java parameter to the jdeveloper bin folder in hudson , see the hudson picture
thanks
Hi,
ReplyDeleteI have a problem while deploying a SOA project from Hudson. I have used the ant scripts provided in this site. I am trying to compile & deploy a sample application initially.
It is failing during the compilation. Getting the following error
[scac] error: location {/ns:composite}(12,61): Parse of component type files failed, check the adf-config.xml file : "oracle.fabric.common.FabricException: oracle.fabric.common.FabricException: javax.management.InstanceNotFoundException: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: javax.management.InstanceNotFoundException: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: oracle.fabric.common.FabricException: javax.management.InstanceNotFoundException: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: javax.management.InstanceNotFoundException: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean: com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"
Some hints/help would be very much appreciated.
Thanks
@Venkat
ReplyDeleteI got the same error and it is quite misleading! The problem is the scac.application.home property. It needs to point to the correct directory containing an adf-config.xml file with your MDS connection configuration.
Then it works like a charm...
Oh God !!!
DeleteThanks to save my life... very usefull !
Your site is a life saver. A question: in your applications folder you have projects and inside a project you the .adf file. This confuses me, as the .adf file doesn't normally live in an application, and the build.xml you've generously shared doesn't expect it to be in there. Without the actual JDeveloper application, where does adf-config.xml actually get picked up from?
ReplyDeleteHi,
DeleteIn the application folder I got a workspace helloworld with the .adf folder and the workspace contains a project also called helloworld. I think it is only necessary for compiling ( lookup mds resource ) and not necessary in the sar or for deployment.
thanks
It makes sense. Thank you. I am having another issue. Perhaps you've come across this or know of a way to resolve it: If I set basedir to ORACLE_HOME/JDeveloper/bin, using your script, all the output, including the builds and logs directories, is written there. That doesn't make sense so I leave it unset. Everything works from the command line, outside of Jenkins. If I don't set basedir the Jenkins build runs all the way until the activation of the composite, when it finally fails with: compositeMgrTask: java.net.MalformedURLException: Unsupported protocol: t3. Looking at build files, it seems the libraries to support t3 should already be properly sourced. It's finding everything else.
DeleteHi,
DeleteI think you need to set basedir to the jdeveloper bin folder. maybe in the ant soa scripts there is a hard reference to the weblogic.jar.
maybe you can generate a wlfullclient.jar and add this to the classpath or bin.
thanks
Adding wlfullclient.jar did the trick. I had to hack it into the Oracle script. Having it available to ant wasn't enough. But it works. Thank you!
DeletePlease explain the below instruction in a little more detail.
ReplyDeleteNow we have to add ant-contrib-1.0XXXX.jar the to the jdeveloper\ant\lib folder and add a environment variable to the ant.bat
What is the ant-contrib-1.0XXXX.jar file and when is it found?
Thanks,
Paul
Hi,
Deleteit is extension of ant and it adds some extra features to ant like foreach etc
here it is
http://ant-contrib.sourceforge.net/
thanks
Hi Edwin,
ReplyDeleteThis was a really useful article for setting Hudson jobs but one thing we've noticed is when running the tests, if there is a failure in a test the build is still marked as successful.
If we publish the unit test report in the job then the job is marked as unstable but I would expect the job to fail as my unit tests have failed.
I've looked through the ant-sca-test script and can't see any failure conditions on the task. Can I ask how you've overcome this problem as your example only shows successful test results.
Many thanks,
Wayne
Hi,
Deleteit looks like a bug cause I also had some failed tests and I got see them in hudson. Or did your test crash instead of a different expected output
Thanks
Hi Edwin,
ReplyDeleteThank you for your post.
Could you have another post to guide me to use hudson to build (not need to test or deploy) SOA application with one composite and one human task UI project.
Thanks
HI,
ReplyDeleteThe following error occurred when I was trying to make a SOA build. Can you please let know the error.
compile-package:
BUILD FAILED
/var/lib/jenkins/workspace/Build_SOA/build.xml:11: The following error occurred while executing this line:
java.io.FileNotFoundException: /var/lib/jenkins/workspace/Build_SOA/${ant-sca-package.xml} (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:146)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:250)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:178)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:392)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Thanks