Problem using velocity component

2008-12-16 Thread Alfie Kirkpatrick
Hi, I am attempting to write a plugin that uses Velocity to template
some config files. I have been developing the plugin using m2eclipse
embedded maven runtime and it works fine. But it gives a NPE when I run
it in maven standalone, even with the 2.1M1 release.

 

I have the following in my class:

 

  /**

   * @component

   */

  protected VelocityComponent velocityComponent;

 

The line giving the NPE is:

 

  Template template =
velocityComponent.getEngine().getTemplate(/+templateName+.vm);

 

When running standalone the velocityComponent is initialised with a
DefaultVelocityComponent but with a null engine, so getTemplate gives
the NPE.

 

Am struggling to understand if I'm doing this correctly and why it
should work in maven embedder (in m2eclipse) but not standalone?

 

As an aside, my class implements org.codehaus.plexus.logging.LogEnabled
and running with maven embedder, the enableLogging method is called with
a PlexusLoggerAdapter, but running standalone this method is not called.
Can't help feeling this is related...

 

Any help much appreciated!

 

Regards, Alfie.



Re: Problem using velocity component

2008-12-16 Thread Jason van Zyl
If you jar up your plugin project I'll take a look. Create a JIRA  
issue and attach the project and I'll see it.


On 16-Dec-08, at 6:34 PM, Alfie Kirkpatrick wrote:


Hi, I am attempting to write a plugin that uses Velocity to template
some config files. I have been developing the plugin using m2eclipse
embedded maven runtime and it works fine. But it gives a NPE when I  
run

it in maven standalone, even with the 2.1M1 release.



I have the following in my class:



 /**

  * @component

  */

 protected VelocityComponent velocityComponent;



The line giving the NPE is:



 Template template =
velocityComponent.getEngine().getTemplate(/+templateName+.vm);



When running standalone the velocityComponent is initialised with a
DefaultVelocityComponent but with a null engine, so getTemplate gives
the NPE.



Am struggling to understand if I'm doing this correctly and why it
should work in maven embedder (in m2eclipse) but not standalone?



As an aside, my class implements  
org.codehaus.plexus.logging.LogEnabled
and running with maven embedder, the enableLogging method is called  
with
a PlexusLoggerAdapter, but running standalone this method is not  
called.

Can't help feeling this is related...



Any help much appreciated!



Regards, Alfie.



Thanks,

Jason

--
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
--

Selfish deeds are the shortest path to self destruction.

 -- The Seven Samuari, Akira Kurosawa


-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org