You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Rohit Khamkar <rk...@gmail.com> on 2010/06/28 03:25:47 UTC

Using Velocity tools with Velocity Engine

I want to use Velocity Tools with Velocity Engine in  a standalone
mode. For some reason I am not able to use anything within Velocity
tools.

Here is what I have:

I tried several approaches - but the moment anything with Velocity
Tools is accessed - the program seems to hang/stop at the call to
anything in the tools.

Approach 1:

VelocityEngine ve = new VelocityEngine();
	ve.init();
	    Context context = new VelocityContext();
	   	    logDebug("here 1");
context.put ("number", new NumberTool());
logDebug ("Here 2");

Does not execute the line below context.put ("number", new
NumberTool()), When I do not have the line context.put ("number", new
NumberTool()), things seem to proceed in a normal way.


Approach 2:
VelocityEngine ve = new VelocityEngine();
	ve.init();
 logDebug("here 1");
	    ToolManager manager = new ToolManager();
	    logDebug("here 2...");
	    // manager.configure("/path/to/my/configuration.xml");
	    Context contexttm = manager.createContext();	   	

Does not execute the line below ToolManager manager = new ToolManager().


Using Velocity engine  1.6.3 and velocity tools 2.0

-Rohit

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


Re: Using Velocity tools with Velocity Engine

Posted by Rohit Khamkar <rk...@gmail.com>.
Yes, you are correct. It is the class not found exception. The module
that I used to fire my instance never had a reference of the velocity
tools jar - build however did, no never realized that was the case.
Thanks for pointing me in the correct direction.


On Mon, Jun 28, 2010 at 10:16 AM, Nathan Bubna <nb...@gmail.com> wrote:
> On Mon, Jun 28, 2010 at 9:56 AM, Rohit Khamkar <rk...@gmail.com> wrote:
>> Different from the standard out i meant. So in case there were any
>> exception, I should see them in the logs.
>
> standard out is the final fallback.  it will try to use log4j,
> commons-log, or jdk15 logging before resorting to that.
>
>> Well my environment is WebSphere app server, with java 1.5
>>
>> I am using Velocity engine and trying to use Velocity Tools in
>> standalone fashion. Not sure what else you need to know for velocity
>> in a standalone environment.
>
> i've never used websphere, but are you sure that VelocityTools is
> present in the classpath?  i'm pretty much certain that the only way
> "new NumberTool()" could halt code execution is a
> ClassNotFoundException.
>
>
>> On Mon, Jun 28, 2010 at 9:28 AM, Nathan Bubna <nb...@gmail.com> wrote:
>>> On Mon, Jun 28, 2010 at 8:39 AM, Antonio Petrelli
>>> <an...@gmail.com> wrote:
>>>> 2010/6/28 Rohit Khamkar <rk...@gmail.com>:
>>>>> Not even a single line of stacktrace. Does Velocity log under a
>>>>> different file?
>>>
>>> different file from what?
>>>
>>>> I don't think so.
>>>>
>>>>> I would hope to see anything under such case written
>>>>> to standard error. Is there a different approach in doing this?
>>>>
>>>> Well, I must admit that Velocity Tools (probably Velocity too) have a
>>>> bad habit in ignoring or swallowing exceptions. At this point your
>>>> only way to discover your problem is by debugging.
>>>
>>> sorry, but the NumberTool and ToolManager constructors do not catch
>>> any exceptions.  heck, the NumberTool class has no explicit
>>> constructor, just the default one.  and if they did catch exceptions,
>>> the code would continue running rather than stop.  you're gonna have
>>> to tell us about your environment, because you have something funky.
>>> if i had to guess, i would bet that your setup is swallowing
>>> ClassNotFoundExceptions.  this looks for all the world like
>>> VelocityTools is not in the classpath at runtime and you are somehow
>>> not seeing the CNFEs.
>>>
>>>
>>>> Antonio
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: Using Velocity tools with Velocity Engine

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Jun 28, 2010 at 9:56 AM, Rohit Khamkar <rk...@gmail.com> wrote:
> Different from the standard out i meant. So in case there were any
> exception, I should see them in the logs.

standard out is the final fallback.  it will try to use log4j,
commons-log, or jdk15 logging before resorting to that.

> Well my environment is WebSphere app server, with java 1.5
>
> I am using Velocity engine and trying to use Velocity Tools in
> standalone fashion. Not sure what else you need to know for velocity
> in a standalone environment.

i've never used websphere, but are you sure that VelocityTools is
present in the classpath?  i'm pretty much certain that the only way
"new NumberTool()" could halt code execution is a
ClassNotFoundException.


> On Mon, Jun 28, 2010 at 9:28 AM, Nathan Bubna <nb...@gmail.com> wrote:
>> On Mon, Jun 28, 2010 at 8:39 AM, Antonio Petrelli
>> <an...@gmail.com> wrote:
>>> 2010/6/28 Rohit Khamkar <rk...@gmail.com>:
>>>> Not even a single line of stacktrace. Does Velocity log under a
>>>> different file?
>>
>> different file from what?
>>
>>> I don't think so.
>>>
>>>> I would hope to see anything under such case written
>>>> to standard error. Is there a different approach in doing this?
>>>
>>> Well, I must admit that Velocity Tools (probably Velocity too) have a
>>> bad habit in ignoring or swallowing exceptions. At this point your
>>> only way to discover your problem is by debugging.
>>
>> sorry, but the NumberTool and ToolManager constructors do not catch
>> any exceptions.  heck, the NumberTool class has no explicit
>> constructor, just the default one.  and if they did catch exceptions,
>> the code would continue running rather than stop.  you're gonna have
>> to tell us about your environment, because you have something funky.
>> if i had to guess, i would bet that your setup is swallowing
>> ClassNotFoundExceptions.  this looks for all the world like
>> VelocityTools is not in the classpath at runtime and you are somehow
>> not seeing the CNFEs.
>>
>>
>>> Antonio
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: Using Velocity tools with Velocity Engine

Posted by Rohit Khamkar <rk...@gmail.com>.
Different from the standard out i meant. So in case there were any
exception, I should see them in the logs.

Well my environment is WebSphere app server, with java 1.5

I am using Velocity engine and trying to use Velocity Tools in
standalone fashion. Not sure what else you need to know for velocity
in a standalone environment.


On Mon, Jun 28, 2010 at 9:28 AM, Nathan Bubna <nb...@gmail.com> wrote:
> On Mon, Jun 28, 2010 at 8:39 AM, Antonio Petrelli
> <an...@gmail.com> wrote:
>> 2010/6/28 Rohit Khamkar <rk...@gmail.com>:
>>> Not even a single line of stacktrace. Does Velocity log under a
>>> different file?
>
> different file from what?
>
>> I don't think so.
>>
>>> I would hope to see anything under such case written
>>> to standard error. Is there a different approach in doing this?
>>
>> Well, I must admit that Velocity Tools (probably Velocity too) have a
>> bad habit in ignoring or swallowing exceptions. At this point your
>> only way to discover your problem is by debugging.
>
> sorry, but the NumberTool and ToolManager constructors do not catch
> any exceptions.  heck, the NumberTool class has no explicit
> constructor, just the default one.  and if they did catch exceptions,
> the code would continue running rather than stop.  you're gonna have
> to tell us about your environment, because you have something funky.
> if i had to guess, i would bet that your setup is swallowing
> ClassNotFoundExceptions.  this looks for all the world like
> VelocityTools is not in the classpath at runtime and you are somehow
> not seeing the CNFEs.
>
>
>> Antonio
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: Using Velocity tools with Velocity Engine

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Jun 28, 2010 at 8:39 AM, Antonio Petrelli
<an...@gmail.com> wrote:
> 2010/6/28 Rohit Khamkar <rk...@gmail.com>:
>> Not even a single line of stacktrace. Does Velocity log under a
>> different file?

different file from what?

> I don't think so.
>
>> I would hope to see anything under such case written
>> to standard error. Is there a different approach in doing this?
>
> Well, I must admit that Velocity Tools (probably Velocity too) have a
> bad habit in ignoring or swallowing exceptions. At this point your
> only way to discover your problem is by debugging.

sorry, but the NumberTool and ToolManager constructors do not catch
any exceptions.  heck, the NumberTool class has no explicit
constructor, just the default one.  and if they did catch exceptions,
the code would continue running rather than stop.  you're gonna have
to tell us about your environment, because you have something funky.
if i had to guess, i would bet that your setup is swallowing
ClassNotFoundExceptions.  this looks for all the world like
VelocityTools is not in the classpath at runtime and you are somehow
not seeing the CNFEs.


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

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


Re: Using Velocity tools with Velocity Engine

Posted by Antonio Petrelli <an...@gmail.com>.
2010/6/28 Rohit Khamkar <rk...@gmail.com>:
> Not even a single line of stacktrace. Does Velocity log under a
> different file?

I don't think so.

> I would hope to see anything under such case written
> to standard error. Is there a different approach in doing this?

Well, I must admit that Velocity Tools (probably Velocity too) have a
bad habit in ignoring or swallowing exceptions. At this point your
only way to discover your problem is by debugging.

Antonio

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


Re: Using Velocity tools with Velocity Engine

Posted by Rohit Khamkar <rk...@gmail.com>.
Not even a single line of stacktrace. Does Velocity log under a
different file? I would hope to see anything under such case written
to standard error. Is there a different approach in doing this?

On Mon, Jun 28, 2010 at 12:19 AM, Antonio Petrelli
<an...@gmail.com> wrote:
> 2010/6/28 Rohit Khamkar <rk...@gmail.com>:
>> context.put ("number", new NumberTool());
>> logDebug ("Here 2");
>>
>> Does not execute the line below context.put ("number", new
>> NumberTool()), When I do not have the line context.put ("number", new
>> NumberTool()), things seem to proceed in a normal way.
>>...
>>
>> Approach 2:
>>            ToolManager manager = new ToolManager();
>>            logDebug("here 2...");
>> ...
>> Does not execute the line below ToolManager manager = new ToolManager().
>
> Strange, the only reason because this happens is that you have an
> exception. Do you see any stacktrace?
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: Using Velocity tools with Velocity Engine

Posted by Antonio Petrelli <an...@gmail.com>.
2010/6/28 Rohit Khamkar <rk...@gmail.com>:
> context.put ("number", new NumberTool());
> logDebug ("Here 2");
>
> Does not execute the line below context.put ("number", new
> NumberTool()), When I do not have the line context.put ("number", new
> NumberTool()), things seem to proceed in a normal way.
>...
>
> Approach 2:
>            ToolManager manager = new ToolManager();
>            logDebug("here 2...");
> ...
> Does not execute the line below ToolManager manager = new ToolManager().

Strange, the only reason because this happens is that you have an
exception. Do you see any stacktrace?

Antonio

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