You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by tharanga wijethilake <th...@ee.oulu.fi> on 2006/10/11 11:59:22 UTC
Problems in running ant in WebSphere studio site deveoper in bundles
Hi,
I am using the WSSD 5.1.2 trial version and I am trying to run an ant script in side a bundle using a java program. It is as follows.
package oulu.info.capnet.samples;
import java.io.File;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
/**
* @Author: Tharanga Wijethilake
* @Time : 10:54:25
*/
public class AntRunner implements Runnable{
private String fileName="C:\\Documents and Settings\\tharanga\\My Documents\\IBM\\wssitedev51\\workspace\\Runner\\build.xml";
private static AntRunner ar;
private Thread thread;
/**
*
*/
public AntRunner() {
super();
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
antRun();
}
public static AntRunner getInstance(){
if(ar==null){
ar=new AntRunner();
}
return ar;
}
public void antRun(){
File buildFile=new File(fileName);
if(buildFile.exists()){
Project p=new Project();
p.setUserProperty("ant.file",buildFile.getAbsolutePath());
p.init();
ProjectHelper helper=ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
} else{
System.out.println("File not found");
}
}
public void start(){
thread=new Thread(this);
thread.start();
}
public void stop(){
thread=null;
}
}
I did Every thing as indicated in the article "Invoking Apache Ant programmatically" (http://www-128.ibm.com/developerworks/websphere/library/techarticles/0502_gawor/0502_gawor.html)
and I am tring to run the same ant script given in the article. but when I run the bundle activator it gives the following error.
java.lang.NoClassDefFoundError: org/apache/tools/ant/Project
at oulu.info.capnet.samples.AntRunner.antRun(AntRunner.java:47)
at oulu.info.capnet.samples.AntRunner.run(AntRunner.java:34)
at java.lang.Thread.run(Thread.java:513)
Can some one suggest me what is wrong with this. I can run the class given in the article as a java application, it is only that I can not run it as a SMF bundle.
I hope some one would answer me.
Thank you in Advance.
Tharanga Wijethilake