ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: NullPointerException with ant Javac() api
Date Wed, 16 Apr 2008 05:24:36 GMT
Your task doesnt have a reference to your project, therefore 
    task.getProject() returns null

Try setting the project reference
    task.setProject(project);
    task.execute();


Maybe you want to have a look at Leafcutter
https://leafcutter.dev.java.net/


Jan


> -----Urspr√ľngliche Nachricht-----
> Von: Paolo [mailto:paolo@wci.ath.cx] 
> Gesendet: Dienstag, 15. April 2008 17:35
> An: user@ant.apache.org
> Betreff: NullPointerException with ant Javac() api
> 
> Hello,
> I'm new to ant api. i would like to compile a source from my
> application, and i wrote the method below.
> 
> When i execute it, i get a NullPointerException at
> org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:807)
> 
> where it says: File srcDir = getProject().resolveFile(list[i]);
> (it's on the last instruction of this snippet, task.execute())
> 
> so i guess i screwed up with all the Path stuff..
> But how to create and set up a Path object to feed Javac object?
> thanks in advance,
> Paolo
> 
> 
> 
> 	public void subsystemCreate(String id, String poolSize) {
> 	
> 		String beanName = "BpsAgent"+id;
> 		String jbossHome =
> System.getProperty("jboss.home.dir"+"/"); String serverHome =
> System.getProperty("jboss.server.home.dir"+"/"); String tmpDir =
> System.getProperty("jboss.server.home.dir")+"/deploy/"+appName
> +".ear/tmp/src/com/mersy/batch/mdb/";
> String appDir =
> System.getProperty("jboss.server.home.dir")+"/deploy/"+appName
> +".ear/";
> String src =
> System.getProperty("jboss.server.home.dir")+"/deploy/"+appName
> +".ear/tmp/src/";
> String dst =
> System.getProperty("jboss.server.home.dir")+"/deploy/"+appName
> +".ear/tmp/bin/";
> System.out.println(beanName); System.out.println(jbossHome);
> System.out.println(serverHome); System.out.println(tmpDir);
> 		System.out.println(appDir);
> 		System.out.println(src);
> 		System.out.println(dst);
> 		
> 		
> 		boolean success = (new File(tmpDir)).mkdirs();
> 	    if (!success) {
> 	        System.out.println("Megaerrore1");
> 	        return ;
> 	    }
> 	    
> 		File dstPath=new File(dst);
> 		success = (dstPath.mkdirs());
> 	    if (!success) {
> 	        System.out.println("Megaerrore2");
> 	        return ;
> 	    }
> 	    
> 	    createMdb(id,poolSize,tmpDir);
> 	    
> 	    
> 		Project project = new Project();
> 		Path path = new Path(project);
> 		path.setPath(jbossHome+"/lib/hibernate3.jar;" +
> 				serverHome+"/lib/ejb3-persistence.jar;"
> + serverHome+"/lib/hibernate-annotations.jar;"+
> 				serverHome+"/lib/jboss-remoting.jar;"+
> 				
> serverHome+"/deploy/ejb3.deployer/jboss-ejb3.jar;"+
> 				
> serverHome+"/deploy/ejb3.deployer/jboss-ejb3x.jar;"+
> 				
> serverHome+"/deploy/ejb3.deployer/jboss-annotations-ejb3.jar;"+
> 				appDir+"/locallib/javaee.jar;"+
> 				appDir+"/locallib/a001llayer.jar;"+
> 				serverHome+"/lib/log4j.jar");
> 		
> 		Path srcPath=new Path(project);
> 		srcPath.setPath(src);
> 		
> 
> 		
> 		Javac task = new Javac();
> 		
> 		task.setSrcdir(srcPath);
> 		task.setDestdir(dstPath);
> 		task.setClasspath(path);
> 		
> 		task.execute();
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message