Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running WebLogic sh script that sets environment variables from ANT

 
Radu Codrin Leterna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My problem is the following:
I have a build.xml file that should automatically work with WebLogic... start/stop/undeploy/deploy.... this kind of stuff.
I am running "setWLSEnv.sh" script from ANT using the "exec" task. The script gets executed successfully.
Then, I want to start WebLogic using "wlserver" task. But the server doesn't want to start....

I found that the problem is that ANT runs the "setWLSEnv.sh" in a separate process and the PATH and CLASSPATH variables are not set correctly for the ANT session. Is there any way to force ANT to run a sh in the same process? Or setting the weblogic variables somehow that they will be accessible for the ANT script?

Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Radu,
The default is supposed to be to not use a new environment/process. Can you show your <exec> call in case something is inadvertently being set? Also, you aren't calling the .sh file itself in a new environment, right?
 
Radu Codrin Leterna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I am using a .sh script that is called from my main ANT script to execute "setWLSEnv.sh". So the configuration looks like this:

[ANT build.xml]

<project name="Automation" default="start" basedir=".">
<target name="start">
<exec executable="run_setWLSEnv.sh" resolveexecutable="true">
<arg value="/usr/local/bea/wlserver_10.3/server/bin" />
<arg value="setWLSEnv.sh" />
</exec>
</target>
</target>


[SH script]

echo "Now setting up the CLASSPATH and PATH for WebLogic..."
cd ${1}
. ./${2}
echo "All set."


I know I can run the "setWLSEnv.sh" script directly from ANT (and I've done it), but doing this does not set my PATH and CLASSPATH env variables for my ANT session and when I try to start WebLogic it just fails. The solution with ". ./" was suggested by someone, and it's working if I am running manually (so, before the ANT script just run from the command line the command: ". ./setWLSEnv.sh"). But, when I am running this command from my sh file, the CLASSPATH and PATH variables are not set in my ANT session.... so, same as before, WebLogic doesn't start.

The workaround I found is to set the CLASSPAT in a build.properties file and just use the property in my ANT script, in the "wlserver" task as the value for "classpath" argument. But this is just a temporary solution... an not very platform independent because I have hardcoded paths (currently working on Solaris, and if I move to Linux, the WL CLASSPATH is's proppably changed...).

So again... is there any way to have a build.xml file that STARTS WebLogic using "wlserver" task without the user having to run manually other external scripts and without hardcoding the CLASSPATH in the property file? I just want the script to be easy to use, generic, portable... just copy it to a machine that has the WebLogic installed, set the correct WL_HOME... and run it without any problems .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic