File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Running WebLogic sh script that sets environment variables from ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Running WebLogic sh script that sets environment variables from ANT" Watch "Running WebLogic sh script that sets environment variables from ANT" New topic
Author

Running WebLogic sh script that sets environment variables from ANT

Radu Codrin Leterna
Greenhorn

Joined: Jul 15, 2010
Posts: 5
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Radu Codrin Leterna
Greenhorn

Joined: Jul 15, 2010
Posts: 5
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running WebLogic sh script that sets environment variables from ANT