I was scripting an ant task in Jenkins through which I hoped to start jboss. I am getting it started, but soon I am getting such an error. Jboss version is 4.0.4
Problem starting service jboss
java.lang.OutOfMemoryError: PermGen space
I have set ANT_OPTS and JAVA_OPTS as follows
-Xms1536m -Xmx2048m -XX:PermSize=1536m -XX:MaxPermSize=2048m
-Xmx2048M -XX:MaxPermSize=1024M -XX:MaxPermSize=1024M
This is what i did
<exec dir="${jbossHome}/bin" executable="cmd" spawn="true">
<arg line="/c run.bat"/>
</exec>
I even tried to start jboss by executing run.bat from Jenkins, got same error.
Thanks.
got that working with this.
<target name="start-jboss" depends="stop-update" >
<echo message=" jboss\bin folder is = ${jbossHome}/bin"/>
<exec dir="${jbossHome}/bin" executable="cmd" spawn="true">
<arg line="/c run.bat"/>
</exec>
<waitfor maxwait="50" maxwaitunit="second">
<available file="errors.log"/>
</waitfor>
</target>
Also gave this in run.bat of jboss.
set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx2048m -XX:MaxPermSize=512m
Related
I upgraded tomcat from 6 to version 8. Now my ant scripts stopped working.
I used to start tomcat 6 using following target:
<target name="start-server">
<java jar="${server.home}/bin/bootstrap.jar" fork="true" spawn="true">
<jvmarg line="-Dcatalina.home=${server.home} -Dcatalina.base=${server.home}"/>
</java>
</target>
This doesn't work any more.
You can try to use startup.bat or catalina.bat instead of starting it via Java.
<exec dir="${server.home}/bin" executable="cmd">
<arg value="/c"/>
<arg line="catalina.bat"/>
<arg line="start"/>
<env key="CATALINA_HOME" value="${server.home}"/>
<env key="JAVA_OPTS" value="-Xms256m -Xmx1024m"/>
</exec>
I created an Ant task that runs buildfile (dfs-build.xml) with parameters. It works well under OS Windows. But, I would like ANT task runs under Linux. Any ideas?
<exec executable="cmd">
<arg value="/c"/>
<arg value="${ant.basedir}\bin\ant -Dproperty.files.dir=${property.files.dir} -Dbasedir=${antscripts.basedir}/../DocumentumCoreProject/dfs6.7 -Dmodule.name=rbacs -f ${antscripts.basedir}\sub_ANTs\Create_EAR_WAR\dfs-build.xml generate"/>
</exec>
The exec task is simpler under Linux:
<exec executable="${ant.basedir}\bin\ant" osfamily="unix">
<arg value="-Dproperty.files.dir=${property.files.dir} -Dbasedir=${antscripts.basedir}/../DocumentumCoreProject/dfs6.7 -Dmodule.name=rbacs -f ${antscripts.basedir}\sub_ANTs\Create_EAR_WAR\dfs-build.xml generate"/>
</exec>
Another cross-platform option is to run the build within the same ANT process
<subant antfile="{antscripts.basedir}\sub_ANTs\Create_EAR_WAR\dfs-build.xml" target="generate">
<property name="property.files.dir" value="${property.files.dir}"/>
<property name="basedir" value="${antscripts.basedir}/../DocumentumCoreProject/dfs6.7"/>
<property name="module.name" value="rbacs"/>
</subant>
I have a script which detects OS using Catalina.bat for windows and Catalina.sh for UNIX..it executes successfully for UNIX but for windows its not able to extract OS version from Catalina.bat..the reason i find out is because in Catalina.bat when it executes this line
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
then OS version statement is not reached in catalina.bat file,so the solution to this is i guess; explicitly set CATALINA_HOME environment variable using my Ant script itself; how to do that plz suggest any solution.
i was using this code, here OS.version property should have cached the OS version from catalina.bat file similar code in UNIX is working fine but win i wonder whats wrong
<property name="version" location="${My_proj}\tomcat\bin\catalina.bat"/>
<exec executable="${version}" outputproperty="OS.version">
<arg value="version" />
<redirector>
<outputfilterchain>
<tokenfilter>
<containsstring contains="OS Name:"/>
<replacestring from="OS Name: " to=""/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
PROBLEM O SOLVED: you were right ..
<exec executable="cmd" outputproperty="tomcat.version">
<arg value="/c"/>
<arg value="${MY_PROJ}\tomcat\bin\version.bat"/>
<env key="CATALINA_HOME" value="${MY_PROJ}\tomcat\"/>
<redirector>
<outputfilterchain>
<tokenfilter>
<containsstring contains="Server version"/>
<replaceregex pattern="Server version: Apache Tomcat/(.*)$" replace="\1"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<echo message="tomcat.version: ${tomcat.version}"/>
OUTPUT:
versioncat:
[echo] tomcat.version: 6.0.33
LAST BUL NOT THE LEAST CAN ANY1 ANSWER OR SUGGEST A WORKAROUND FOR MY LAST COMMENT QUERY THE SILLY QUESTION
If I understand correctly, you are executing this OS detection from Ant. In that case, can you not instead use Ant's built-in support for OS identification - in the os condition?
However, if you really need to execute catalina.bat while setting CATALINA_HOME, you could do so using a nested env element in you exec task.
Here is a sample build file which uses both approaches:
<project default="test">
<target name="test">
<!-- Execute a command, in this case a simple bat file
which echoes the value of the var set in the env block
-->
<exec executable="cmd">
<arg value="/c"/>
<arg value="test.bat"/>
<env key="CATALINA_HOME" value="whatever"/>
</exec>
<!-- echo the values of built-in OS related properties -->
<echo message="os.arch: ${os.arch}"/>
<echo message="os.name: ${os.name}"/>
<echo message="os.version: ${os.version}"/>
<!-- test one of the os conditions -->
<condition property="is.windows">
<os family="windows"/>
</condition>
<echo message="is.windows ? ${is.windows}"/>
</target>
</project>
Here is the content of test.bat:
echo CATALINA_HOME=%CATALINA_HOME%
Here is the output:
test:
[exec]
[exec] C:\tmp\ant>echo CATALINA_HOME=whatever
[exec] CATALINA_HOME=whatever
[echo] os.arch: x86
[echo] os.name: Windows XP
[echo] os.version: 6.1 build 7601 Service Pack 1
[echo] is.windows ? true
Regarding your subsequent question (in comments) about tomcat version...
I now guess you are executing this version detection via Ant in your runtime environment.
Ant and Java don't know about your Tomcat environment, so now you're back to executing %CATALINA_HOME%\bin\catalina.bat -version and parsing what you need from the output.
Here's a working example:
<project default="version">
<property environment="env"/>
<condition property="script.ext" value="bat">
<os family="windows"/>
</condition>
<condition property="script.ext" value="sh">
<os family="unix"/>
</condition>
<target name="version">
<exec executable="${env.CATALINA_HOME}/bin/version.${script.ext}" outputproperty="tomcat.version">
<redirector>
<outputfilterchain>
<tokenfilter>
<containsstring contains="Server version"/>
<replaceregex pattern="Server version: Apache Tomcat/(.*)$" replace="\1"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<echo message="tomcat.version: ${tomcat.version}"/>
</target>
</project>
And here is the output:
version:
[echo] tomcat.version: 5.5.33
Note that this example assumes that you have the CATALINA_HOME (and JAVA_HOME) environment variable set in your terminal.
Alternatively, you could pass these variables using a nested <env> element as previously discussed. But it seems more likely that these should come from the runtime environment rather than embedded in your build file.
Do it like this :
<condition property="catalina.path" value="C:\Foo\catalina.bat">
<os family="windows"/>
</condition>
<condition property="catalina.path" value="/home/foo/catalina.sh">
<os family="unix"/>
</condition>
<exec> ... execute your script here </exec>
Depending on your situation, you may find this approach a little more platform agnostic and less error prone as you do not need to fork off a shell. This works at least as far back as Tomcat 6.x
<property environment="env"/>
<loadproperties>
<zipentry zipfile="${env.CATALINA_HOME}/bin/bootstrap.jar" name="META-INF/MANIFEST.MF"/>
<filterchain>
<prefixlines prefix="tomcat."/>
</filterchain>
</loadproperties>
<!-- Prints MAJOR.MINOR version, e.g.: 8.0 -->
<echo message="Tomcat Version: ${tomcat.Specification-Version}"/>
<!-- Prints full version, e.g.: 8.0.26 -->
<echo message="Tomcat Release: ${tomcat.Implementation-Version}"/>
I have gone through number of posts on the very forum but couldn't sort it out. I am trying to run a BAT file from ANT script. The folder hierarchy is like this
- Project
| - build.xml
| - build-C
| | - test.bat
The ANT file that i wrote so for is
<project name="MyProject" basedir=".">
<property name="buildC" value="${basedire}\build-C" />
<exec dir="${buildC}" executable="cmd" os="Windows XP">
<arg line="/c test.bat"/>
</exec>
</project>
The bat file content is
echo In Build-C Test.bat
It says that build failed .. :s i dun know what wrong am i doing ?
<property name="buildC" value="${basedire}\build-C" />
This should be ${basedir} I guess? Use
<echo>${buildC}</echo>
to make sure the dir is correct.
And shouldn't
<exec dir="${buildC}" executable="test.bat" os="Windows XP" />
do the job?
Hopefully this will help expand on the already given/accepted answers:
I suggest executing cmd with the batch script as a parameter:
<exec failonerror="true" executable="cmd" dir="${buildC}">
<arg line="/c "${buildC}/test.bat""/>
</exec>
Not sure if it is necessary to use the absolute path "${buildC}/test.bat" since dir is specified, but I put it just in case. It might be enough to use /c test.bat.
My project executes a batch script on Windows operating systems & a shell script on all others. Here is an example:
<target name="foo">
<!-- properties for Windows OSes -->
<condition property="script.exec" value="cmd">
<os family="windows"/>
</condition>
<condition property="script.param" value="/c "${basedir}/foo.bat"">
<os family="windows"/>
</condition>
<!-- properties for non-Windows OSes -->
<property name="script.exec" value="sh"/>
<property name="script.param" value=""${basedir}/foo.sh""/>
<echo message="Executing command: ${script.exec} ${script.param}"/>
<exec failonerror="true" executable="${script.exec}" dir="${basedir}">
<arg line="${script.param}"/>
</exec>
</target>
In IntelliJ IDEA I have this task in my Ant script
<target name="emulator-logcat">
<exec command="adb" spawn="false" osfamily="windows">
<arg value="-e"/>
<arg value="shell"/>
<arg value="logcat"/>
</exec>
</target>
It works but command output sent to IDEA ant window, not in Windows console window. How i can forward command output into new Windows console window as if i start this command from cmd.exe?
Problem resolved:
I create runner.bat file witch contains %* and call it like this
<target name="emulator-logcat">
<exec command="cmd.exe" spawn="true" osfamily="windows">
<arg line="/c start runner.bat adb -e shell logcat"/>
</exec>
</target>