You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Daniel Crompton <D....@detelefoongids.nl> on 2011/09/15 18:20:19 UTC

Velocity Issue

 
Hi,
 
    I'm new to the list, and I was having some problems with
camel-velocity. In my unit tests the velocity templates as used in the
following piece of code resolve the location of the template on the
classpath. However when I deploy the bundle to ServiceMix it doesn't
find the file on the classpath eventhough it is in the bundle.
 
I've looked for a solution and thought I might find one in the setting
of the properties[3]
 
 
[1]
Velocity.init();

VelocityContext context = new VelocityContext();

context.put("textfullname", escapeHtml(fullName));

StringWriter w = new StringWriter();

Template template = Velocity.getTemplate("AddressModule.xml");

 

[2]
17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  | velocity
| ?                                   ? | 94 -
org.apache.servicemix.bundle
s.velocity - 1.7.0.1 | ResourceManager : unable to find resource
'AddressModule.xml' in any resource loader.
17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  |
DefaultErrorHandler              | ?                                   ?
| 57 - org.apache.camel.camel-core
- 2.7.1.fuse-00-43 | Failed delivery for exchangeId:
ID-DTAMS0883-4138-1316102252587-2-30. Exhausted after delivery attempt:
1 caught: org.apache.velo
city.exception.ResourceNotFoundException: Unable to find resource
'AddressModule.xml'
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'AddressModule.xml'
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
sourceManagerImpl.java:474)[94:org.apache.servicemix.bundles.veloci
ty:1.7.0.1]
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
ourceManagerImpl.java:352)[94:org.apache.servicemix.bundles.velocit
y:1.7.0.1]
        at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1533)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
        at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1514)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
        at
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleto
n.java:299)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
        at
org.apache.velocity.app.Velocity.getTemplate(Velocity.java:358)[94:org.a
pache.servicemix.bundles.velocity:1.7.0.1]
        at
nl.dtg.services.hi.HumanInferenceValidator.validateName(HumanInferenceVa
lidator.java:180)[172:nl.dtg.services.hi:1.0.0.SNAPSHOT]

[3]


Dit bericht is afkomstig van De Telefoongids BV en uitsluitend bestemd voor de geadresseerde. Dit bericht kan vertrouwelijke informatie bevatten. Als u dit bericht per abuis hebt ontvangen, dan wordt u verzocht de afzender te informeren en het bericht en eventuele bijlagen te vernietigen. 

Communicatie via Internet is niet beveiligd. De Telefoongids BV aanvaardt geen aansprakelijkheid voor wijzigingen in de inhoud van het bericht en eventuele bijlagen, onrechtmatige openbaarmaking ervan jegens derden of schade als gevolg van gebruik van e-mailcommunicatie.

De Telefoongids BV is gevestigd te Amsterdam (Handelregister nr. 27198207).

----------------------------------------------------------------------------------------------------------------------------

This message is sent from De Telefoongids BV and is intended only for use by the recipient. It may contain confidential information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments.

Internet communications are not secure. De Telefoongids BV does not accept any liability for mutilations to the contents of this message and attachments thereto, if any, unlawful disclosure thereof to third parties, or damage resulting from the use of e-mail communications.

De Telefoongids BV is a private limited company with its seat in Amsterdam (Trade Register no. 27198207).

RE: Velocity Issue

Posted by Daniel Crompton <D....@detelefoongids.nl>.
I solved it by removing the properties file, for some reason this was
creating a conflict.

Thanks,
D.
 

> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
> Sent: Thursday, September 15, 2011 8:02 PM
> To: users@camel.apache.org
> Subject: Re: Velocity Issue
> 
> If you create VelocityContext yourself then you need to play 
> all the hops to get it working in OSGi land.
> If you on the other hand use it as a Camel endpoint then we 
> (try) to make sure it works in osgi. I think we identified a 
> bug recently.
Dit bericht is afkomstig van De Telefoongids BV en uitsluitend bestemd voor de geadresseerde. Dit bericht kan vertrouwelijke informatie bevatten. Als u dit bericht per abuis hebt ontvangen, dan wordt u verzocht de afzender te informeren en het bericht en eventuele bijlagen te vernietigen. 

Communicatie via Internet is niet beveiligd. De Telefoongids BV aanvaardt geen aansprakelijkheid voor wijzigingen in de inhoud van het bericht en eventuele bijlagen, onrechtmatige openbaarmaking ervan jegens derden of schade als gevolg van gebruik van e-mailcommunicatie.

De Telefoongids BV is gevestigd te Amsterdam (Handelregister nr. 27198207).

----------------------------------------------------------------------------------------------------------------------------

This message is sent from De Telefoongids BV and is intended only for use by the recipient. It may contain confidential information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments.

Internet communications are not secure. De Telefoongids BV does not accept any liability for mutilations to the contents of this message and attachments thereto, if any, unlawful disclosure thereof to third parties, or damage resulting from the use of e-mail communications.

De Telefoongids BV is a private limited company with its seat in Amsterdam (Trade Register no. 27198207).

Re: Velocity Issue

Posted by Claus Ibsen <cl...@gmail.com>.
If you create VelocityContext yourself then you need to play all the
hops to get it working in OSGi land.
If you on the other hand use it as a Camel endpoint then we (try) to
make sure it works in osgi. I think we identified a bug recently.



On Thu, Sep 15, 2011 at 6:20 PM, Daniel Crompton
<D....@detelefoongids.nl> wrote:
>
> Hi,
>
>    I'm new to the list, and I was having some problems with
> camel-velocity. In my unit tests the velocity templates as used in the
> following piece of code resolve the location of the template on the
> classpath. However when I deploy the bundle to ServiceMix it doesn't
> find the file on the classpath eventhough it is in the bundle.
>
> I've looked for a solution and thought I might find one in the setting
> of the properties[3]
>
>
> [1]
> Velocity.init();
>
> VelocityContext context = new VelocityContext();
>
> context.put("textfullname", escapeHtml(fullName));
>
> StringWriter w = new StringWriter();
>
> Template template = Velocity.getTemplate("AddressModule.xml");
>
>
>
> [2]
> 17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  | velocity
> | ?                                   ? | 94 -
> org.apache.servicemix.bundle
> s.velocity - 1.7.0.1 | ResourceManager : unable to find resource
> 'AddressModule.xml' in any resource loader.
> 17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  |
> DefaultErrorHandler              | ?                                   ?
> | 57 - org.apache.camel.camel-core
> - 2.7.1.fuse-00-43 | Failed delivery for exchangeId:
> ID-DTAMS0883-4138-1316102252587-2-30. Exhausted after delivery attempt:
> 1 caught: org.apache.velo
> city.exception.ResourceNotFoundException: Unable to find resource
> 'AddressModule.xml'
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'AddressModule.xml'
>        at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
> sourceManagerImpl.java:474)[94:org.apache.servicemix.bundles.veloci
> ty:1.7.0.1]
>        at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
> ourceManagerImpl.java:352)[94:org.apache.servicemix.bundles.velocit
> y:1.7.0.1]
>        at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
> java:1533)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
>        at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
> java:1514)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
>        at
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleto
> n.java:299)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
>        at
> org.apache.velocity.app.Velocity.getTemplate(Velocity.java:358)[94:org.a
> pache.servicemix.bundles.velocity:1.7.0.1]
>        at
> nl.dtg.services.hi.HumanInferenceValidator.validateName(HumanInferenceVa
> lidator.java:180)[172:nl.dtg.services.hi:1.0.0.SNAPSHOT]
>
> [3]
>
>
> Dit bericht is afkomstig van De Telefoongids BV en uitsluitend bestemd voor de geadresseerde. Dit bericht kan vertrouwelijke informatie bevatten. Als u dit bericht per abuis hebt ontvangen, dan wordt u verzocht de afzender te informeren en het bericht en eventuele bijlagen te vernietigen.
>
> Communicatie via Internet is niet beveiligd. De Telefoongids BV aanvaardt geen aansprakelijkheid voor wijzigingen in de inhoud van het bericht en eventuele bijlagen, onrechtmatige openbaarmaking ervan jegens derden of schade als gevolg van gebruik van e-mailcommunicatie.
>
> De Telefoongids BV is gevestigd te Amsterdam (Handelregister nr. 27198207).
>
> ----------------------------------------------------------------------------------------------------------------------------
>
> This message is sent from De Telefoongids BV and is intended only for use by the recipient. It may contain confidential information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments.
>
> Internet communications are not secure. De Telefoongids BV does not accept any liability for mutilations to the contents of this message and attachments thereto, if any, unlawful disclosure thereof to third parties, or damage resulting from the use of e-mail communications.
>
> De Telefoongids BV is a private limited company with its seat in Amsterdam (Trade Register no. 27198207).
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

RE: Velocity Issue

Posted by Daniel Crompton <D....@detelefoongids.nl>.
 
Oops, missed the last reference[3] which also didn't work
 
Thanks for any help you can give me,
 
Kind regards,
D.
 



________________________________

	From: Daniel Crompton 
	Sent: Thursday, September 15, 2011 6:20 PM
	To: 'users@camel.apache.org'
	Subject: Velocity Issue
	
	
	 
	Hi,
	 
	    I'm new to the list, and I was having some problems with
camel-velocity. In my unit tests the velocity templates as used in the
following piece of code resolve the location of the template on the
classpath. However when I deploy the bundle to ServiceMix it doesn't
find the file on the classpath eventhough it is in the bundle.
	 
	I've looked for a solution and thought I might find one in the
setting of the properties[3]
	 
	 
	[1]
	Velocity.init();

	

	VelocityContext context = new VelocityContext();

	

	context.put("textfullname", escapeHtml(fullName));

	

	StringWriter w = new StringWriter();

	

	Template template = Velocity.getTemplate("AddressModule.xml");

	 

	[2]
	17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  |
velocity                         | ?                                   ?
| 94 - org.apache.servicemix.bundle
	s.velocity - 1.7.0.1 | ResourceManager : unable to find resource
'AddressModule.xml' in any resource loader.
	17:57:48,806 | ERROR | 1 - file://inbox <file://inbox>  |
DefaultErrorHandler              | ?                                   ?
| 57 - org.apache.camel.camel-core
	- 2.7.1.fuse-00-43 | Failed delivery for exchangeId:
ID-DTAMS0883-4138-1316102252587-2-30. Exhausted after delivery attempt:
1 caught: org.apache.velo
	city.exception.ResourceNotFoundException: Unable to find
resource 'AddressModule.xml'
	org.apache.velocity.exception.ResourceNotFoundException: Unable
to find resource 'AddressModule.xml'
	        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
sourceManagerImpl.java:474)[94:org.apache.servicemix.bundles.veloci
	ty:1.7.0.1]
	        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
ourceManagerImpl.java:352)[94:org.apache.servicemix.bundles.velocit
	y:1.7.0.1]
	        at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1533)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
	        at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1514)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
	        at
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleto
n.java:299)[94:org.apache.servicemix.bundles.velocity:1.7.0.1]
	        at
org.apache.velocity.app.Velocity.getTemplate(Velocity.java:358)[94:org.a
pache.servicemix.bundles.velocity:1.7.0.1]
	        at
nl.dtg.services.hi.HumanInferenceValidator.validateName(HumanInferenceVa
lidator.java:180)[172:nl.dtg.services.hi:1.0.0.SNAPSHOT]

	
	[3]
	Properties props = new Properties();

	props.setProperty("resource.loader", "class");

	props.setProperty(

	"class.resource.loader.class",

	
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

	props.setProperty("class.resource.loader.path", "/");


Dit bericht is afkomstig van De Telefoongids BV en uitsluitend bestemd voor de geadresseerde. Dit bericht kan vertrouwelijke informatie bevatten. Als u dit bericht per abuis hebt ontvangen, dan wordt u verzocht de afzender te informeren en het bericht en eventuele bijlagen te vernietigen. 

Communicatie via Internet is niet beveiligd. De Telefoongids BV aanvaardt geen aansprakelijkheid voor wijzigingen in de inhoud van het bericht en eventuele bijlagen, onrechtmatige openbaarmaking ervan jegens derden of schade als gevolg van gebruik van e-mailcommunicatie.

De Telefoongids BV is gevestigd te Amsterdam (Handelregister nr. 27198207).

----------------------------------------------------------------------------------------------------------------------------

This message is sent from De Telefoongids BV and is intended only for use by the recipient. It may contain confidential information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments.

Internet communications are not secure. De Telefoongids BV does not accept any liability for mutilations to the contents of this message and attachments thereto, if any, unlawful disclosure thereof to third parties, or damage resulting from the use of e-mail communications.

De Telefoongids BV is a private limited company with its seat in Amsterdam (Trade Register no. 27198207).