You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Xavier Ottolini <xa...@qualipse.fr> on 2003/02/20 11:20:49 UTC
TexenTask , nullPointerException in setTemplatePath
Hi,
My project uses the Turbine framework. I need to useVelocity to generate
a monthly report. I have got a weird problem with TexenTask.
I created a class which extends TextenTask. It looks like this
public class StatTask extends TexenTask
{
public Context initControlContext()
throws Exception {
super.initControlContext();
VelocityContext context = new VelocityContext();
Date today = Today.getTodayDate();
Date yesterday = Today.getYesterday(today);
try {
context.put("dayBeforeCallDuration",
AvdqQueryPeer.getAverageCallDuration(yesterday, yesterday));
} catch (Exception e) {
Log.error("error","Exception dans DataList.doBuildTemplate :
" + e);
}
return context;
}
If I use ant to launch "initControlContext", there si no problem. But I
need to schedule the data export.
Then I created a class to lauch the report generation.
public class ReportsTask extends ScheduledJob {
/** Creates a new instance of ReportsTask */
public ReportsTask() {
// do task initialization here
}
public void run(JobEntry job) throws Exception {
try{
String pathToAppRoot = Turbine.getRealPath("/");
StatTask statTask = new StatTask();
// The null pointer exception is in the following line.
statTask.setTemplatePath("c:/");
statTask.setControlTemplate("ReportsForm.vm");
File outputDirectory = new File("c:/reports");
statTask.setOutputDirectory(outputDirectory );
statTask.setOutputFile("C:/reports/statistics.htm");
statTask.initControlContext();
statTask.execute();
} catch (Exception e) {
Log.error("error", "Impossible de réaliser les exports de
statistiques. " + e);
}
}
The method call "statTask.setTemplatePath("c:/");" throws a null pointer
exception.
Is there something that I forgot ?
I would appreciate some help.
Xavier
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: TexenTask , nullPointerException in setTemplatePath
Posted by Xavier Ottolini <xa...@qualipse.fr>.
Hi velocity users,
I discoverd that TextenTask.execute() can not be called by a servlet.
TexenTask needs to disable Velocity.
It would be great to verry usefull to execute TexenTask from a servlet.
We could generate easily reports with Velocity templates !
Regards.
Xavier
Xavier Ottolini wrote:
> Hi,
>
> My project uses the Turbine framework. I need to useVelocity to
> generate a monthly report. I have got a weird problem with TexenTask.
>
> I created a class which extends TextenTask. It looks like this
> public class StatTask extends TexenTask
> {
> public Context initControlContext()
> throws Exception {
> super.initControlContext();
> VelocityContext context = new VelocityContext();
> Date today = Today.getTodayDate();
> Date yesterday = Today.getYesterday(today);
>
> try {
> context.put("dayBeforeCallDuration",
> AvdqQueryPeer.getAverageCallDuration(yesterday, yesterday));
> } catch (Exception e) {
> Log.error("error","Exception dans DataList.doBuildTemplate
> : " + e);
> }
> return context;
> }
>
> If I use ant to launch "initControlContext", there si no problem. But
> I need to schedule the data export.
> Then I created a class to lauch the report generation.
>
> public class ReportsTask extends ScheduledJob {
> /** Creates a new instance of ReportsTask */
> public ReportsTask() {
> // do task initialization here
> }
> public void run(JobEntry job) throws Exception {
> try{
> String pathToAppRoot = Turbine.getRealPath("/");
> StatTask statTask = new StatTask();
> // The null pointer exception is in the following line.
> statTask.setTemplatePath("c:/");
> statTask.setControlTemplate("ReportsForm.vm");
> File outputDirectory = new File("c:/reports");
> statTask.setOutputDirectory(outputDirectory );
> statTask.setOutputFile("C:/reports/statistics.htm");
> statTask.initControlContext();
> statTask.execute();
> } catch (Exception e) {
> Log.error("error", "Impossible de réaliser les exports de
> statistiques. " + e);
> } }
>
> The method call "statTask.setTemplatePath("c:/");" throws a null
> pointer exception.
>
> Is there something that I forgot ?
>
> I would appreciate some help.
>
> Xavier
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org