You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Gérard BUNEL <ge...@ago.fr> on 2005/11/17 18:00:56 UTC

NullPointerException when evaluating

Hello all,

I'm trying to use Velocity in an EJB but when I call the evaluate() 
method I get an NullPointerException as follows

java.lang.NullPointerException
        at 
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
        at 
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
        at 
org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
        at 
com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)

Following examples provided with Velocity, my method is as following:

  public String getDtmfForInitiator() {
    try {
      BridgeTypeLocal bridgeType = getBridgeType();
      if (bridgeType == null)
        return null;
      BridgeTypeConfigurationLocal config = getConfiguration();
      VelocityEngine ve = new VelocityEngine();
      Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
      ve.init(new java.util.Properties());
      VelocityContext context = new VelocityContext();
      context.put("room", getRoom());
      context.put("code", getCode());
      context.put("tempo1", config.getTempo1());
      context.put("tempo2", config.getTempo2());
      context.put("tempo3", config.getTempo3());
      context.put("tempo4", config.getTempo4());
      context.put("tempo5", config.getTempo5());

      StringWriter w = new StringWriter();
      String s = bridgeType.getInitiatorDTMF();
      logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
      Velocity.evaluate( context, w, "dtmfForInitiator", s );
      return w.toString();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }


Any Idea where is the problem ?


 

-- 
BUNEL Gerard - ATLANTIDE
Consultant
Tel. : +33 (0)2 98 05 43 21
http://www.ago.fr/
--
Technopôle Brest Iroise
Site du Vernis - CS 23866
29238 Brest Cedex 3 - France
Tel. : +33 (0)2 98 05 43 21
Fax. : +33 (0)2 98 05 20 34
e-mail: atlantide-brest@ago.fr


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


Re: NullPointerException when evaluating

Posted by Gérard BUNEL <ge...@ago.fr>.
You're right. I should have been a bit more clear.
My real question: Does velocity internally creates threads.
As EJB are not allowed to create threads, it should have been a problem.
And I'm happy that it will not
Thanks

Nathan Bubna a écrit :

>i'm not sure exactly what you are asking.  if you are asking whether
>Velocity is multi-threaded in the sense that it uses multiple threads
>internally, then the answer is no.  if you are asking whether Velocity
>can be used in a multi-thread environment like a web application, then
>the answer is yes.
>
>parser.pool.size is a little used configuration setting that exists
>for tuning a velocity application's performance in a multi-thread
>environment.  if you expect to have more than twenty threads parsing
>templates with the same VelocityEngine (or with the singleton), then
>you might consider increasing that number.  but that is unlikely
>unless you have template caching off in a high-load production
>environment (which i doubt is ever justified).
>
>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>  
>
>>Really thanks for that answer. That's clear now. I'll try tomorrow a
>>sI'm at home now.
>>But I've another question:
>>
>>I'read a bit of the developper's guide and found some comment on the
>>property |parser.pool.size = 20
>>I'm not sure if this is related but I imagine that this is set for
>>multi-threading purpose
>>so that you're able to use velocity many times simultanously (is that
>>syntax correct ?)
>>But this lead to another question: Is Velocity multithreaded by itself ?
>>As I'm running Velocity inside EJB this should be forbidden. So the
>>answer is important for me.
>>|
>>Nathan Bubna a écrit :
>>
>>    
>>
>>>oh, and change your Velocity.setProperty(...) to ve.setProperty(...).
>>>
>>>you are mixing up singleton and engine usage.  choose one or the
>>>other.  i recommend using a VelocityEngine.
>>>
>>>On 11/17/05, Nathan Bubna <nb...@gmail.com> wrote:
>>>
>>>
>>>      
>>>
>>>>sorry.  i should have looked at your code more carefully.  the
>>>>exception you're getting is indeed caused by an uninitialized velocity
>>>>runtime.  the problem is that you are initializing a VelocityEngine
>>>>but then you are attempting to call the evaluate method on the
>>>>Velocity singleton.
>>>>
>>>>change your Velocity.evaluate(...);  line to ve.evaluate(...);
>>>>
>>>>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>>>>
>>>>
>>>>        
>>>>
>>>>>Yes as yous can see in the code below.
>>>>>I've no velocity.properties; Should it be a problem ?
>>>>>
>>>>>Nathan Bubna a écrit :
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>>>did you call init() first?
>>>>>>
>>>>>>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>>>>
>>>>>>>Hello all,
>>>>>>>
>>>>>>>I'm trying to use Velocity in an EJB but when I call the evaluate()
>>>>>>>method I get an NullPointerException as follows
>>>>>>>
>>>>>>>java.lang.NullPointerException
>>>>>>>      at
>>>>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
>>>>>>>      at
>>>>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
>>>>>>>      at
>>>>>>>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
>>>>>>>      at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
>>>>>>>      at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
>>>>>>>      at
>>>>>>>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
>>>>>>>
>>>>>>>Following examples provided with Velocity, my method is as following:
>>>>>>>
>>>>>>>public String getDtmfForInitiator() {
>>>>>>>  try {
>>>>>>>    BridgeTypeLocal bridgeType = getBridgeType();
>>>>>>>    if (bridgeType == null)
>>>>>>>      return null;
>>>>>>>    BridgeTypeConfigurationLocal config = getConfiguration();
>>>>>>>    VelocityEngine ve = new VelocityEngine();
>>>>>>>    Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
>>>>>>>    ve.init(new java.util.Properties());
>>>>>>>    VelocityContext context = new VelocityContext();
>>>>>>>    context.put("room", getRoom());
>>>>>>>    context.put("code", getCode());
>>>>>>>    context.put("tempo1", config.getTempo1());
>>>>>>>    context.put("tempo2", config.getTempo2());
>>>>>>>    context.put("tempo3", config.getTempo3());
>>>>>>>    context.put("tempo4", config.getTempo4());
>>>>>>>    context.put("tempo5", config.getTempo5());
>>>>>>>
>>>>>>>    StringWriter w = new StringWriter();
>>>>>>>    String s = bridgeType.getInitiatorDTMF();
>>>>>>>    logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
>>>>>>>    Velocity.evaluate( context, w, "dtmfForInitiator", s );
>>>>>>>    return w.toString();
>>>>>>>  } catch (Exception e) {
>>>>>>>    e.printStackTrace();
>>>>>>>  }
>>>>>>>  return null;
>>>>>>>}
>>>>>>>
>>>>>>>
>>>>>>>Any Idea where is the problem ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>--
>>>>>>>BUNEL Gerard - ATLANTIDE
>>>>>>>Consultant
>>>>>>>Tel. : +33 (0)2 98 05 43 21
>>>>>>>http://www.ago.fr/
>>>>>>>--
>>>>>>>Technopôle Brest Iroise
>>>>>>>Site du Vernis - CS 23866
>>>>>>>29238 Brest Cedex 3 - France
>>>>>>>Tel. : +33 (0)2 98 05 43 21
>>>>>>>Fax. : +33 (0)2 98 05 20 34
>>>>>>>e-mail: atlantide-brest@ago.fr
>>>>>>>
>>>>>>>
>>>>>>>---------------------------------------------------------------------
>>>>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>>>>
>>>>>--
>>>>>No virus found in this outgoing message.
>>>>>Checked by AVG Free Edition.
>>>>>Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>      
>>>
>>
>>--
>>No virus found in this outgoing message.
>>Checked by AVG Free Edition.
>>Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>  
>



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005



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


Re: NullPointerException when evaluating

Posted by Nathan Bubna <nb...@gmail.com>.
i'm not sure exactly what you are asking.  if you are asking whether
Velocity is multi-threaded in the sense that it uses multiple threads
internally, then the answer is no.  if you are asking whether Velocity
can be used in a multi-thread environment like a web application, then
the answer is yes.

parser.pool.size is a little used configuration setting that exists
for tuning a velocity application's performance in a multi-thread
environment.  if you expect to have more than twenty threads parsing
templates with the same VelocityEngine (or with the singleton), then
you might consider increasing that number.  but that is unlikely
unless you have template caching off in a high-load production
environment (which i doubt is ever justified).

On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> Really thanks for that answer. That's clear now. I'll try tomorrow a
> sI'm at home now.
> But I've another question:
>
> I'read a bit of the developper's guide and found some comment on the
> property |parser.pool.size = 20
> I'm not sure if this is related but I imagine that this is set for
> multi-threading purpose
> so that you're able to use velocity many times simultanously (is that
> syntax correct ?)
> But this lead to another question: Is Velocity multithreaded by itself ?
> As I'm running Velocity inside EJB this should be forbidden. So the
> answer is important for me.
> |
> Nathan Bubna a écrit :
>
> >oh, and change your Velocity.setProperty(...) to ve.setProperty(...).
> >
> >you are mixing up singleton and engine usage.  choose one or the
> >other.  i recommend using a VelocityEngine.
> >
> >On 11/17/05, Nathan Bubna <nb...@gmail.com> wrote:
> >
> >
> >>sorry.  i should have looked at your code more carefully.  the
> >>exception you're getting is indeed caused by an uninitialized velocity
> >>runtime.  the problem is that you are initializing a VelocityEngine
> >>but then you are attempting to call the evaluate method on the
> >>Velocity singleton.
> >>
> >>change your Velocity.evaluate(...);  line to ve.evaluate(...);
> >>
> >>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> >>
> >>
> >>>Yes as yous can see in the code below.
> >>>I've no velocity.properties; Should it be a problem ?
> >>>
> >>>Nathan Bubna a écrit :
> >>>
> >>>
> >>>
> >>>>did you call init() first?
> >>>>
> >>>>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>Hello all,
> >>>>>
> >>>>>I'm trying to use Velocity in an EJB but when I call the evaluate()
> >>>>>method I get an NullPointerException as follows
> >>>>>
> >>>>>java.lang.NullPointerException
> >>>>>       at
> >>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
> >>>>>       at
> >>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
> >>>>>       at
> >>>>>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
> >>>>>       at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
> >>>>>       at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
> >>>>>       at
> >>>>>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
> >>>>>
> >>>>>Following examples provided with Velocity, my method is as following:
> >>>>>
> >>>>> public String getDtmfForInitiator() {
> >>>>>   try {
> >>>>>     BridgeTypeLocal bridgeType = getBridgeType();
> >>>>>     if (bridgeType == null)
> >>>>>       return null;
> >>>>>     BridgeTypeConfigurationLocal config = getConfiguration();
> >>>>>     VelocityEngine ve = new VelocityEngine();
> >>>>>     Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
> >>>>>     ve.init(new java.util.Properties());
> >>>>>     VelocityContext context = new VelocityContext();
> >>>>>     context.put("room", getRoom());
> >>>>>     context.put("code", getCode());
> >>>>>     context.put("tempo1", config.getTempo1());
> >>>>>     context.put("tempo2", config.getTempo2());
> >>>>>     context.put("tempo3", config.getTempo3());
> >>>>>     context.put("tempo4", config.getTempo4());
> >>>>>     context.put("tempo5", config.getTempo5());
> >>>>>
> >>>>>     StringWriter w = new StringWriter();
> >>>>>     String s = bridgeType.getInitiatorDTMF();
> >>>>>     logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
> >>>>>     Velocity.evaluate( context, w, "dtmfForInitiator", s );
> >>>>>     return w.toString();
> >>>>>   } catch (Exception e) {
> >>>>>     e.printStackTrace();
> >>>>>   }
> >>>>>   return null;
> >>>>> }
> >>>>>
> >>>>>
> >>>>>Any Idea where is the problem ?
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>--
> >>>>>BUNEL Gerard - ATLANTIDE
> >>>>>Consultant
> >>>>>Tel. : +33 (0)2 98 05 43 21
> >>>>>http://www.ago.fr/
> >>>>>--
> >>>>>Technopôle Brest Iroise
> >>>>>Site du Vernis - CS 23866
> >>>>>29238 Brest Cedex 3 - France
> >>>>>Tel. : +33 (0)2 98 05 43 21
> >>>>>Fax. : +33 (0)2 98 05 20 34
> >>>>>e-mail: atlantide-brest@ago.fr
> >>>>>
> >>>>>
> >>>>>---------------------------------------------------------------------
> >>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>--
> >>>No virus found in this outgoing message.
> >>>Checked by AVG Free Edition.
> >>>Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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


Re: NullPointerException when evaluating

Posted by Gérard BUNEL <ge...@ago.fr>.
Really thanks for that answer. That's clear now. I'll try tomorrow a 
sI'm at home now.
But I've another question:

I'read a bit of the developper's guide and found some comment on the 
property |parser.pool.size = 20
I'm not sure if this is related but I imagine that this is set for 
multi-threading purpose
so that you're able to use velocity many times simultanously (is that 
syntax correct ?)
But this lead to another question: Is Velocity multithreaded by itself ? 
As I'm running Velocity inside EJB this should be forbidden. So the 
answer is important for me.
|
Nathan Bubna a écrit :

>oh, and change your Velocity.setProperty(...) to ve.setProperty(...).
>
>you are mixing up singleton and engine usage.  choose one or the
>other.  i recommend using a VelocityEngine.
>
>On 11/17/05, Nathan Bubna <nb...@gmail.com> wrote:
>  
>
>>sorry.  i should have looked at your code more carefully.  the
>>exception you're getting is indeed caused by an uninitialized velocity
>>runtime.  the problem is that you are initializing a VelocityEngine
>>but then you are attempting to call the evaluate method on the
>>Velocity singleton.
>>
>>change your Velocity.evaluate(...);  line to ve.evaluate(...);
>>
>>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>>    
>>
>>>Yes as yous can see in the code below.
>>>I've no velocity.properties; Should it be a problem ?
>>>
>>>Nathan Bubna a écrit :
>>>
>>>      
>>>
>>>>did you call init() first?
>>>>
>>>>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>>>>
>>>>
>>>>        
>>>>
>>>>>Hello all,
>>>>>
>>>>>I'm trying to use Velocity in an EJB but when I call the evaluate()
>>>>>method I get an NullPointerException as follows
>>>>>
>>>>>java.lang.NullPointerException
>>>>>       at
>>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
>>>>>       at
>>>>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
>>>>>       at
>>>>>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
>>>>>       at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
>>>>>       at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
>>>>>       at
>>>>>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
>>>>>
>>>>>Following examples provided with Velocity, my method is as following:
>>>>>
>>>>> public String getDtmfForInitiator() {
>>>>>   try {
>>>>>     BridgeTypeLocal bridgeType = getBridgeType();
>>>>>     if (bridgeType == null)
>>>>>       return null;
>>>>>     BridgeTypeConfigurationLocal config = getConfiguration();
>>>>>     VelocityEngine ve = new VelocityEngine();
>>>>>     Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
>>>>>     ve.init(new java.util.Properties());
>>>>>     VelocityContext context = new VelocityContext();
>>>>>     context.put("room", getRoom());
>>>>>     context.put("code", getCode());
>>>>>     context.put("tempo1", config.getTempo1());
>>>>>     context.put("tempo2", config.getTempo2());
>>>>>     context.put("tempo3", config.getTempo3());
>>>>>     context.put("tempo4", config.getTempo4());
>>>>>     context.put("tempo5", config.getTempo5());
>>>>>
>>>>>     StringWriter w = new StringWriter();
>>>>>     String s = bridgeType.getInitiatorDTMF();
>>>>>     logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
>>>>>     Velocity.evaluate( context, w, "dtmfForInitiator", s );
>>>>>     return w.toString();
>>>>>   } catch (Exception e) {
>>>>>     e.printStackTrace();
>>>>>   }
>>>>>   return null;
>>>>> }
>>>>>
>>>>>
>>>>>Any Idea where is the problem ?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>--
>>>>>BUNEL Gerard - ATLANTIDE
>>>>>Consultant
>>>>>Tel. : +33 (0)2 98 05 43 21
>>>>>http://www.ago.fr/
>>>>>--
>>>>>Technopôle Brest Iroise
>>>>>Site du Vernis - CS 23866
>>>>>29238 Brest Cedex 3 - France
>>>>>Tel. : +33 (0)2 98 05 43 21
>>>>>Fax. : +33 (0)2 98 05 20 34
>>>>>e-mail: atlantide-brest@ago.fr
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>
>>>--
>>>No virus found in this outgoing message.
>>>Checked by AVG Free Edition.
>>>Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>
>>>
>>>      
>>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>  
>



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005



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


Re: NullPointerException when evaluating

Posted by Nathan Bubna <nb...@gmail.com>.
oh, and change your Velocity.setProperty(...) to ve.setProperty(...).

you are mixing up singleton and engine usage.  choose one or the
other.  i recommend using a VelocityEngine.

On 11/17/05, Nathan Bubna <nb...@gmail.com> wrote:
> sorry.  i should have looked at your code more carefully.  the
> exception you're getting is indeed caused by an uninitialized velocity
> runtime.  the problem is that you are initializing a VelocityEngine
> but then you are attempting to call the evaluate method on the
> Velocity singleton.
>
> change your Velocity.evaluate(...);  line to ve.evaluate(...);
>
> On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> > Yes as yous can see in the code below.
> > I've no velocity.properties; Should it be a problem ?
> >
> > Nathan Bubna a écrit :
> >
> > >did you call init() first?
> > >
> > >On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> > >
> > >
> > >>Hello all,
> > >>
> > >>I'm trying to use Velocity in an EJB but when I call the evaluate()
> > >>method I get an NullPointerException as follows
> > >>
> > >>java.lang.NullPointerException
> > >>        at
> > >>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
> > >>        at
> > >>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
> > >>        at
> > >>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
> > >>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
> > >>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
> > >>        at
> > >>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
> > >>
> > >>Following examples provided with Velocity, my method is as following:
> > >>
> > >>  public String getDtmfForInitiator() {
> > >>    try {
> > >>      BridgeTypeLocal bridgeType = getBridgeType();
> > >>      if (bridgeType == null)
> > >>        return null;
> > >>      BridgeTypeConfigurationLocal config = getConfiguration();
> > >>      VelocityEngine ve = new VelocityEngine();
> > >>      Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
> > >>      ve.init(new java.util.Properties());
> > >>      VelocityContext context = new VelocityContext();
> > >>      context.put("room", getRoom());
> > >>      context.put("code", getCode());
> > >>      context.put("tempo1", config.getTempo1());
> > >>      context.put("tempo2", config.getTempo2());
> > >>      context.put("tempo3", config.getTempo3());
> > >>      context.put("tempo4", config.getTempo4());
> > >>      context.put("tempo5", config.getTempo5());
> > >>
> > >>      StringWriter w = new StringWriter();
> > >>      String s = bridgeType.getInitiatorDTMF();
> > >>      logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
> > >>      Velocity.evaluate( context, w, "dtmfForInitiator", s );
> > >>      return w.toString();
> > >>    } catch (Exception e) {
> > >>      e.printStackTrace();
> > >>    }
> > >>    return null;
> > >>  }
> > >>
> > >>
> > >>Any Idea where is the problem ?
> > >>
> > >>
> > >>
> > >>
> > >>--
> > >>BUNEL Gerard - ATLANTIDE
> > >>Consultant
> > >>Tel. : +33 (0)2 98 05 43 21
> > >>http://www.ago.fr/
> > >>--
> > >>Technopôle Brest Iroise
> > >>Site du Vernis - CS 23866
> > >>29238 Brest Cedex 3 - France
> > >>Tel. : +33 (0)2 98 05 43 21
> > >>Fax. : +33 (0)2 98 05 20 34
> > >>e-mail: atlantide-brest@ago.fr
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > >>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> > >>
> > >>
> > >>
> > >>
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> > >
> > >
> > >
> >
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
>

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


Re: NullPointerException when evaluating

Posted by Nathan Bubna <nb...@gmail.com>.
sorry.  i should have looked at your code more carefully.  the
exception you're getting is indeed caused by an uninitialized velocity
runtime.  the problem is that you are initializing a VelocityEngine 
but then you are attempting to call the evaluate method on the
Velocity singleton.

change your Velocity.evaluate(...);  line to ve.evaluate(...);

On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> Yes as yous can see in the code below.
> I've no velocity.properties; Should it be a problem ?
>
> Nathan Bubna a écrit :
>
> >did you call init() first?
> >
> >On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> >
> >
> >>Hello all,
> >>
> >>I'm trying to use Velocity in an EJB but when I call the evaluate()
> >>method I get an NullPointerException as follows
> >>
> >>java.lang.NullPointerException
> >>        at
> >>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
> >>        at
> >>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
> >>        at
> >>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
> >>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
> >>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
> >>        at
> >>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
> >>
> >>Following examples provided with Velocity, my method is as following:
> >>
> >>  public String getDtmfForInitiator() {
> >>    try {
> >>      BridgeTypeLocal bridgeType = getBridgeType();
> >>      if (bridgeType == null)
> >>        return null;
> >>      BridgeTypeConfigurationLocal config = getConfiguration();
> >>      VelocityEngine ve = new VelocityEngine();
> >>      Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
> >>      ve.init(new java.util.Properties());
> >>      VelocityContext context = new VelocityContext();
> >>      context.put("room", getRoom());
> >>      context.put("code", getCode());
> >>      context.put("tempo1", config.getTempo1());
> >>      context.put("tempo2", config.getTempo2());
> >>      context.put("tempo3", config.getTempo3());
> >>      context.put("tempo4", config.getTempo4());
> >>      context.put("tempo5", config.getTempo5());
> >>
> >>      StringWriter w = new StringWriter();
> >>      String s = bridgeType.getInitiatorDTMF();
> >>      logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
> >>      Velocity.evaluate( context, w, "dtmfForInitiator", s );
> >>      return w.toString();
> >>    } catch (Exception e) {
> >>      e.printStackTrace();
> >>    }
> >>    return null;
> >>  }
> >>
> >>
> >>Any Idea where is the problem ?
> >>
> >>
> >>
> >>
> >>--
> >>BUNEL Gerard - ATLANTIDE
> >>Consultant
> >>Tel. : +33 (0)2 98 05 43 21
> >>http://www.ago.fr/
> >>--
> >>Technopôle Brest Iroise
> >>Site du Vernis - CS 23866
> >>29238 Brest Cedex 3 - France
> >>Tel. : +33 (0)2 98 05 43 21
> >>Fax. : +33 (0)2 98 05 20 34
> >>e-mail: atlantide-brest@ago.fr
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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


Re: NullPointerException when evaluating

Posted by Gérard BUNEL <ge...@ago.fr>.
Yes as yous can see in the code below.
I've no velocity.properties; Should it be a problem ?

Nathan Bubna a écrit :

>did you call init() first?
>
>On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
>  
>
>>Hello all,
>>
>>I'm trying to use Velocity in an EJB but when I call the evaluate()
>>method I get an NullPointerException as follows
>>
>>java.lang.NullPointerException
>>        at
>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
>>        at
>>org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
>>        at
>>org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
>>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
>>        at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
>>        at
>>com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
>>
>>Following examples provided with Velocity, my method is as following:
>>
>>  public String getDtmfForInitiator() {
>>    try {
>>      BridgeTypeLocal bridgeType = getBridgeType();
>>      if (bridgeType == null)
>>        return null;
>>      BridgeTypeConfigurationLocal config = getConfiguration();
>>      VelocityEngine ve = new VelocityEngine();
>>      Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
>>      ve.init(new java.util.Properties());
>>      VelocityContext context = new VelocityContext();
>>      context.put("room", getRoom());
>>      context.put("code", getCode());
>>      context.put("tempo1", config.getTempo1());
>>      context.put("tempo2", config.getTempo2());
>>      context.put("tempo3", config.getTempo3());
>>      context.put("tempo4", config.getTempo4());
>>      context.put("tempo5", config.getTempo5());
>>
>>      StringWriter w = new StringWriter();
>>      String s = bridgeType.getInitiatorDTMF();
>>      logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
>>      Velocity.evaluate( context, w, "dtmfForInitiator", s );
>>      return w.toString();
>>    } catch (Exception e) {
>>      e.printStackTrace();
>>    }
>>    return null;
>>  }
>>
>>
>>Any Idea where is the problem ?
>>
>>
>>
>>
>>--
>>BUNEL Gerard - ATLANTIDE
>>Consultant
>>Tel. : +33 (0)2 98 05 43 21
>>http://www.ago.fr/
>>--
>>Technopôle Brest Iroise
>>Site du Vernis - CS 23866
>>29238 Brest Cedex 3 - France
>>Tel. : +33 (0)2 98 05 43 21
>>Fax. : +33 (0)2 98 05 20 34
>>e-mail: atlantide-brest@ago.fr
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>  
>



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 16/11/2005



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


Re: NullPointerException when evaluating

Posted by Nathan Bubna <nb...@gmail.com>.
did you call init() first?

On 11/17/05, Gérard BUNEL <ge...@ago.fr> wrote:
> Hello all,
>
> I'm trying to use Velocity in an EJB but when I call the evaluate()
> method I get an NullPointerException as follows
>
> java.lang.NullPointerException
>         at
> org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:735)
>         at
> org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
>         at
> org.apache.velocity.runtime.RuntimeSingleton.parse(RuntimeSingleton.java:251)
>         at org.apache.velocity.app.Velocity.evaluate(Velocity.java:282)
>         at org.apache.velocity.app.Velocity.evaluate(Velocity.java:210)
>         at
> com.ftrd.iaca.ejb.ConferenceBridgeBean.getDtmfForInitiator(ConferenceBridgeBean.java:584)
>
> Following examples provided with Velocity, my method is as following:
>
>   public String getDtmfForInitiator() {
>     try {
>       BridgeTypeLocal bridgeType = getBridgeType();
>       if (bridgeType == null)
>         return null;
>       BridgeTypeConfigurationLocal config = getConfiguration();
>       VelocityEngine ve = new VelocityEngine();
>       Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
>       ve.init(new java.util.Properties());
>       VelocityContext context = new VelocityContext();
>       context.put("room", getRoom());
>       context.put("code", getCode());
>       context.put("tempo1", config.getTempo1());
>       context.put("tempo2", config.getTempo2());
>       context.put("tempo3", config.getTempo3());
>       context.put("tempo4", config.getTempo4());
>       context.put("tempo5", config.getTempo5());
>
>       StringWriter w = new StringWriter();
>       String s = bridgeType.getInitiatorDTMF();
>       logger.log(BasicLevel.INFO, "Initiator DTMF: "+ s);
>       Velocity.evaluate( context, w, "dtmfForInitiator", s );
>       return w.toString();
>     } catch (Exception e) {
>       e.printStackTrace();
>     }
>     return null;
>   }
>
>
> Any Idea where is the problem ?
>
>
>
>
> --
> BUNEL Gerard - ATLANTIDE
> Consultant
> Tel. : +33 (0)2 98 05 43 21
> http://www.ago.fr/
> --
> Technopôle Brest Iroise
> Site du Vernis - CS 23866
> 29238 Brest Cedex 3 - France
> Tel. : +33 (0)2 98 05 43 21
> Fax. : +33 (0)2 98 05 20 34
> e-mail: atlantide-brest@ago.fr
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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