« Code==Data | Main | Crash »

Cruisecontrol not starting JBoss container

Came across this one in work yesterday. What's happening is that some of the guys are using Cruisecontrol (2.2) to run a nightly build along with a deploy/smoketest into JBoss; as part of the build JBoss is stopped, and then started via a Java target. This setup works fine when the build is called directly via Ant, but when run from Cruisecontrol, JBoss is not started and the Cruisecontrol cycle hangs.

Here's the Cruisecontrol fragment that calls the ant build file:

    <schedule>
      <ant time="0300" 
        antscript="C:/Projects/P3/build/cc-build.bat" 
        antworkingdir="C:/Projects/P3/build" 
        buildfile="cc-build.xml" 
        uselogger="true"/>
    </schedule> 

The target in cc-build.xml being invoked looks like this:

  <target name="build" depends="stop.appserver, init, clean, get-code">
    <ant antfile="build.xml" 
    dir="${src.localpath}\build" target="nightly-build"/>    
    <antcall target="start.appserver"/>	  
  </target>

And the start.appserver target looks like this:

  <target name="start.appserver" description="Start the Appserver server." depends="init">
    <java dir="${appserver.home.dir}/bin" classname="org.jboss.Main" fork="true" spawn="true">
      <arg line="-c default"/>
      <jvmarg value="-Xms32m"/>
      <jvmarg value="-Xmx200m"/>      
      <classpath>
        <pathelement path="${appserver.home.dir}/bin/run.jar"/>
        <pathelement path="${java.home}/lib/tools.jar"/>
      </classpath>
    </java>
  </target>

I suspect the JBoss JVM process is forking out in a way that perhaps has the Cruisecontrol JVM hung waiting for it to return. I haven't had to time to really go digging into this but I'm thinking that an exec target might work better instead of Java. Another possibility I suppose is that the running JBoss is not being stopped fully before the new instance is started (but that doesn't happen via Ant). Anyhow, I thought I'd throw out there to see if anyone had come cross this before.


April 20, 2005 10:14 AM

Comments

Mathias Meyer
(April 20, 2005 05:36 PM #)

I ran over the same problem, when I implemented a nightly build. I use exec with the spawn attribute set to true. It's not the best way, but until now, I haven't found a better way to do it. And yes, I let Ant sleep for some time after spawning JBoss. It can be annoying and error prone. I'd like to hear some other opportunities as well ;)

Seth Ladd
(September 26, 2005 11:52 PM #)

Hi Bill,

Did you ever find the solution for this problem? I'm using and spawn="true", and it doesn't seem to fix this issue. My CruiseControl install continues to hang after I start Jboss via Ant.

Thanks,
Seth

Tobias Anderberg
(December 7, 2005 09:45 AM #)

I am having the same problem! No matter how i try to start the server (java or exec or anything), cc hangs! It does not matter if i use an ant-builder or if i use the antbootstrapper!

Please! Has anyone found a solution!?!

Mat
(March 15, 2006 09:46 PM #)

I have a similar problem. Everything has been working fine, but now all of a sudden CruiseControl hangs waiting for the server to start, even though the server starts normally.

It used to work... nothing has really changed, except I think the CruiseControl machine now has multiple threads running different build processes. On my local machine the process works fine.

I am also using an exec with spawn="true" ... Any solutions found?

Gerd V.
(April 19, 2006 12:10 PM #)

I've got the same problem (CC waiting eternally for JBoss) and I found out the reason is, that CruiseControl is not only waiting for the ANT task to stop before going on, but for any process initiated by ANT.
So far so good: but I still need a solution for that.

Gerd V.
(April 21, 2006 07:27 AM #)

I've got a solution to that "CruiseControl waits eternally"-problem:
The ANT-task which makes CC hang, has to be enclosed in ... and ... and - if used in the task - the 'spawn' attribute must be set to 'false'.

This makes the task run in a separate thread (-> parallel) without being watched by ANT/CruiseControl (-> daemons). If ANT should nevertheless notice success of this task, you have to do that yourself e.g. by using the tag (which must be outside the tag here).

Gerd V.
(April 25, 2006 05:01 AM #)

Well, where it says '...' it means the opening and the closing 'parallel'-tag.

Jeff J.
(August 1, 2006 08:38 PM #)

I found that I had to use the nested <daemons> element inside the <parallel> element to get it to work.

<target name="start.jboss" description="Starts the server">
<echo>Starting JBoss server</echo>
<!--
NOTE: Parallel daemons required to prevent CruiseControl from hanging.
And, java "spawn" must be set to "false".
-->
<parallel>
<daemons>
<java dir="${jboss.home}/bin"
classname="org.jboss.Main"
fork="true"
spawn="false">
<jvmarg value="-Xms128m" />
<jvmarg value="-Xmx512m" />
<jvmarg value="-Dsun.rmi.dgc.client.gcInterval=3600000" />
<jvmarg value="-Dsun.rmi.dgc.server.gcInterval=3600000" />
<jvmarg value="-Djava.endorsed.dirs=${jboss.home}/lib/endorsed" />
<classpath>
<pathelement path="${java.home}/lib/tools.jar" />
<pathelement path="${jboss.home}/bin/run.jar" />
</classpath>
</java>
</daemons>
</parallel>
<sleep seconds="20" />
</target>

R Perich
(October 4, 2006 11:46 AM #)

Another option is to simply install your JBoss server as a windows service. I have done this and it works great.

Say your service is called "JBossService" and it is on machine "XYZ".

You can write a simple ant macro like









and you call that within your target.

servername="XYZ" />

This allows you to control a JBoss server installed on the same machine as CC or even on other network machines. I use this to control my JBoss servers, WebsFear servers, etc.

I've even used Windows services to run Ant scripts installed on remote machines without using sshexec or the like. One reason I needed to do this was because the WebsFear I use cannot do remote installations of applications, only local. Using WebsFear Ant tasks and a little .jacl magic, I can install the apps on the reomte machines using an Ant Windows Service.

R Perich
(October 4, 2006 11:51 AM #)

Sorry. Didn't use the correct html markup. Should be

<macrodef name="service">
<attribute name="service" />
<attribute name="action" />
<attribute name="serverName" />
<sequential>
<exec executable="sc">
<arg line=" \\@{serverName} @{action} '@{service}'" />
</exec>
</sequential>
</macrodef>

<service action="start" service="JBossService" servername="XYZ/>

Post a comment

(you may use HTML tags for style)




Remember Me?

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/1540