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:

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

Thursday, October 7, 2010

How to Debug Application Initialization Using Eclipse

We use weblogic here. In Eclipse, you can start a server in the debug mode. Usually you do the remote debugging of an Java enterprise application by setting break points in the source code and then invoke the application by using the web browser or other clients. But this process does not apply to the initialization process of the application. After the application is deployed and is running, its initialization such as the context initialization has already been finished. What if you want to debug the initialization?
You can start the application in the debug mode from Eclipse. Set the break points in the source code that is called during the initialization. Then invoke the ant build target from Eclipse to deploy the application again. The deploy process will stop at the break points during the initialization and you can debug it now.