Tuesday, October 19, 2010

How to Run Ant Build for Weblogic in Eclipse

When you build an application and deploy it to weblogic server, you may need to set the environment first such as calling the following:
C:\bea1032\wlserver_10.3\server\bin\setWLSEnv.cmd. Then you can run the Ant targets that use the weblogic task wlcompile, wlappc, wldeploy, etc. This can be easily done on command line. But how to do it in the Eclipse IDE?

To solve this, just check what setWLSEnv.cmd does for the Ant. This script puts some jars on the classpath. We can put these jars on the classpath of the Ant that Eclipse invokes. You can configure the Ant for your build file. The following is an example for Weblogic workshop Eclipse that comes with Weblogic 10.3.
Right-click on build.xml. Select "Run as" -> "Open External tools Dialog". This will open up the configuration screen for running Ant on the build file.
In the Classpath tab, choose C:\bea10\modules\org.apache.ant_1.6.5 as the Ant Home. Then add the following jars to the classpath:
C:\bea10\wlserver_10.3\server\lib\weblogic.jar
C:\bea10\modules\features\weblogic.server.modules_10.3.0.0.jar
C:\bea10.slwerver_10.3\server\lib\webservices.jar
C:\bea10\modules\org.apache.ant_1.6.5\lib\ant-all.jar
C:\bea10\modules\net.sf.antcontrib_1.0.0.0_1-ob2\lib\ant-contrib.jar

That's it. You can now run the Ant target in the build file directly from Eclipse now.

No comments:

Post a Comment