You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Julien Martin <ba...@gmail.com> on 2012/01/10 17:46:01 UTC
Novice user of Tapestry needs help with classpath issue
Hello,
I have an app with:
-a web layer (Tapestry5)
-a service layer (Spring)
-a domain layer (Jpa)
I have a mail template located a the root of the my-project-service.jar
file (service layer) and it seems that Tapestry imposes its own classpath
location which causes the velocity template resolution to fail as follows:
*org.apache.tapestry5.runtime.ComponentEventException: Unable to find
resource 'request-childminder-confirmation-mail-template_fr.htm' [at
classpath:com/bignibou/web/pages/InscriptionProfessionnelGardeEnfant.tml,
line 20]*
Can anyone please help?
Regards,
Julien.
Re: Novice user of Tapestry needs help with classpath issue
Posted by Julien Martin <ba...@gmail.com>.
Hello and thanks for the reply Muhammar,
Here is the relevant code:
*String content =
VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,
"request-childminder-confirmation-mail-template_fr.htm",
"UTF-8", model);*
*
*
*
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
</bean>
*
*
*
Regards,
Julien.
P.S. Note that the template file is located within a jar.
2012/1/10 Muhammad Gelbana <m....@gmail.com>
> Also please state the code causing the exception.
>
> On Tue, Jan 10, 2012 at 7:59 PM, Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
> > On Tue, 10 Jan 2012 14:46:01 -0200, Julien Martin <ba...@gmail.com>
> > wrote:
> >
> > Hello,
> >>
> >
> > Hi!
> >
> >
> > *org.apache.tapestry5.runtime.**ComponentEventException: Unable to find
> >> resource 'request-childminder-**confirmation-mail-template_fr.**htm' [at
> >> classpath:com/bignibou/web/**pages/**InscriptionProfessionnelGardeE**
> >> nfant.tml,
> >> line 20]*
> >>
> >
> > Full stack trace please. In addition, loading a resource from the
> > classpath using Tapestry is exactly the same as without Tapestry.
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> > and instructor
> > Owner, Ars Machina Tecnologia da Informação Ltda.
> > http://www.arsmachina.com.br
> >
> > ------------------------------**------------------------------**---------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
> users-unsubscribe@tapestry.apache.org>
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> *Regards,*
> *Muhammad Gelbana
> Java Developer*
>
Re: Novice user of Tapestry needs help with classpath issue
Posted by Muhammad Gelbana <m....@gmail.com>.
Also please state the code causing the exception.
On Tue, Jan 10, 2012 at 7:59 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Tue, 10 Jan 2012 14:46:01 -0200, Julien Martin <ba...@gmail.com>
> wrote:
>
> Hello,
>>
>
> Hi!
>
>
> *org.apache.tapestry5.runtime.**ComponentEventException: Unable to find
>> resource 'request-childminder-**confirmation-mail-template_fr.**htm' [at
>> classpath:com/bignibou/web/**pages/**InscriptionProfessionnelGardeE**
>> nfant.tml,
>> line 20]*
>>
>
> Full stack trace please. In addition, loading a resource from the
> classpath using Tapestry is exactly the same as without Tapestry.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
*Regards,*
*Muhammad Gelbana
Java Developer*
Re: Novice user of Tapestry needs help with classpath issue
Posted by Julien Martin <ba...@gmail.com>.
Yes it was just that.
J.
2012/1/10 Julien Martin <ba...@gmail.com>
> Thanks Jonathan.
> I am realizing it is probably a basic mistake on my part on the Spring
> configuration side.
> The exception I got was misleading.
> Julien.
>
> 2012/1/10 Jonathan Barker <jo...@gmail.com>
>
>> I was noticing that I hooked up that service using Spring, rather than
>> in AppModule, but it shouldn't matter much.
>>
>> private void init() {
>>
>> _logger.debug("init() starting");
>> if (_configuration == null) {
>> _configuration = new Configuration();
>> String directory = null;
>> directory = Messages
>>
>> .getString("SurveyActivityEmailRendererImpl.templateDirectory");
>>
>> _configuration.setClassForTemplateLoading(getClass(), directory);
>> if (_logger.isDebugEnabled())
>> _logger.debug("init(): set template
>> directory to " + directory);
>> } else {
>> _logger.debug("init(): using existing
>> Configuration");
>> }
>> _configuration.setObjectWrapper(new
>> DefaultObjectWrapper());
>>
>> try {
>> String file = Messages
>>
>> .getString("SurveyActivityEmailRendererImpl.templateHtml");
>> _template =
>> _configuration.getTemplate(file);
>> if (_logger.isDebugEnabled())
>> _logger.debug("init(): loaded
>> template from " + file);
>>
>> } catch (IOException e) {
>> throw new RuntimeException("init(): error on
>> template load", e);
>> }
>> initialized = true;
>> _logger.debug("init() completed initialization");
>> }
>>
>> My messages.properties file contained in the same directory as the
>> service contains:
>>
>> SurveyActivityEmailRendererImpl.templateDirectory=/
>> SurveyActivityEmailRendererImpl.templateHtml=nightly-notification.ftl
>>
>> The template is in the root of the jar.
>>
>> The actual generation uses:
>>
>> try {
>> Writer out = new StringWriter();
>> _template.process(data, out);
>> out.flush();
>> htmlEmail = ((StringWriter) out).toString();
>> } catch (IOException e) {
>> throw new RuntimeException(e);
>> } catch (TemplateException e) {
>> throw new RuntimeException(e);
>> }
>> return htmlEmail;
>>
>>
>>
>> On Tue, Jan 10, 2012 at 2:50 PM, Julien Martin <ba...@gmail.com> wrote:
>> > Thanks a lot for your reply Jonathan,
>> > Can you share some code sample (if you have it to hand) please?
>> > Also where does this code go?
>> > *configuration.setClassForTemplateLoading(Class clazz, String
>> directory)*
>> > Regards,
>> > Julien.
>> >
>> > 2012/1/10 Jonathan Barker <jo...@gmail.com>
>> >
>> >> The Freemarker project gave me similar problems. They have a
>> >> Configuration object where you can do
>> >> configuration.setClassForTemplateLoading(Class clazz, String
>> >> directory). Does Velocity have the same option? If it does, I just
>> >> used getClass() within my service to supply that Class parameter.
>> >>
>> >> On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo
>> >> <th...@gmail.com> wrote:
>> >> > On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com>
>> >> wrote:
>> >> >
>> >> >> Caused by: org.apache.velocity.exception.ResourceNotFoundException:
>> >> Unable
>> >> >> to find resource
>> 'request-childminder-confirmation-mail-template_fr.htm'
>> >> >> at
>> >> >>
>> >>
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
>> >> >
>> >> >
>> >> > This is where the problem is. Tapestry itself doesn't change the
>> >> classpath
>> >> > at all, just the classloader for classes in the controlled packages,
>> so
>> >> this
>> >> > isn't related to Tapestry.
>> >> >
>> >> >
>> >> > --
>> >> > Thiago H. de Paula Figueiredo
>> >> > Independent Java, Apache Tapestry 5 and Hibernate consultant,
>> developer,
>> >> and
>> >> > instructor
>> >> > Owner, Ars Machina Tecnologia da Informação Ltda.
>> >> > http://www.arsmachina.com.br
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Jonathan Barker
>> >> ITStrategic
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>>
>>
>>
>> --
>> Jonathan Barker
>> ITStrategic
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
Re: Novice user of Tapestry needs help with classpath issue
Posted by Julien Martin <ba...@gmail.com>.
Thanks Jonathan.
I am realizing it is probably a basic mistake on my part on the Spring
configuration side.
The exception I got was misleading.
Julien.
2012/1/10 Jonathan Barker <jo...@gmail.com>
> I was noticing that I hooked up that service using Spring, rather than
> in AppModule, but it shouldn't matter much.
>
> private void init() {
>
> _logger.debug("init() starting");
> if (_configuration == null) {
> _configuration = new Configuration();
> String directory = null;
> directory = Messages
>
> .getString("SurveyActivityEmailRendererImpl.templateDirectory");
>
> _configuration.setClassForTemplateLoading(getClass(), directory);
> if (_logger.isDebugEnabled())
> _logger.debug("init(): set template
> directory to " + directory);
> } else {
> _logger.debug("init(): using existing
> Configuration");
> }
> _configuration.setObjectWrapper(new DefaultObjectWrapper());
>
> try {
> String file = Messages
>
> .getString("SurveyActivityEmailRendererImpl.templateHtml");
> _template =
> _configuration.getTemplate(file);
> if (_logger.isDebugEnabled())
> _logger.debug("init(): loaded
> template from " + file);
>
> } catch (IOException e) {
> throw new RuntimeException("init(): error on
> template load", e);
> }
> initialized = true;
> _logger.debug("init() completed initialization");
> }
>
> My messages.properties file contained in the same directory as the
> service contains:
>
> SurveyActivityEmailRendererImpl.templateDirectory=/
> SurveyActivityEmailRendererImpl.templateHtml=nightly-notification.ftl
>
> The template is in the root of the jar.
>
> The actual generation uses:
>
> try {
> Writer out = new StringWriter();
> _template.process(data, out);
> out.flush();
> htmlEmail = ((StringWriter) out).toString();
> } catch (IOException e) {
> throw new RuntimeException(e);
> } catch (TemplateException e) {
> throw new RuntimeException(e);
> }
> return htmlEmail;
>
>
>
> On Tue, Jan 10, 2012 at 2:50 PM, Julien Martin <ba...@gmail.com> wrote:
> > Thanks a lot for your reply Jonathan,
> > Can you share some code sample (if you have it to hand) please?
> > Also where does this code go?
> > *configuration.setClassForTemplateLoading(Class clazz, String directory)*
> > Regards,
> > Julien.
> >
> > 2012/1/10 Jonathan Barker <jo...@gmail.com>
> >
> >> The Freemarker project gave me similar problems. They have a
> >> Configuration object where you can do
> >> configuration.setClassForTemplateLoading(Class clazz, String
> >> directory). Does Velocity have the same option? If it does, I just
> >> used getClass() within my service to supply that Class parameter.
> >>
> >> On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo
> >> <th...@gmail.com> wrote:
> >> > On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com>
> >> wrote:
> >> >
> >> >> Caused by: org.apache.velocity.exception.ResourceNotFoundException:
> >> Unable
> >> >> to find resource
> 'request-childminder-confirmation-mail-template_fr.htm'
> >> >> at
> >> >>
> >>
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
> >> >
> >> >
> >> > This is where the problem is. Tapestry itself doesn't change the
> >> classpath
> >> > at all, just the classloader for classes in the controlled packages,
> so
> >> this
> >> > isn't related to Tapestry.
> >> >
> >> >
> >> > --
> >> > Thiago H. de Paula Figueiredo
> >> > Independent Java, Apache Tapestry 5 and Hibernate consultant,
> developer,
> >> and
> >> > instructor
> >> > Owner, Ars Machina Tecnologia da Informação Ltda.
> >> > http://www.arsmachina.com.br
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >>
> >>
> >>
> >> --
> >> Jonathan Barker
> >> ITStrategic
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
>
>
>
> --
> Jonathan Barker
> ITStrategic
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Novice user of Tapestry needs help with classpath issue
Posted by Jonathan Barker <jo...@gmail.com>.
I was noticing that I hooked up that service using Spring, rather than
in AppModule, but it shouldn't matter much.
private void init() {
_logger.debug("init() starting");
if (_configuration == null) {
_configuration = new Configuration();
String directory = null;
directory = Messages
.getString("SurveyActivityEmailRendererImpl.templateDirectory");
_configuration.setClassForTemplateLoading(getClass(), directory);
if (_logger.isDebugEnabled())
_logger.debug("init(): set template directory to " + directory);
} else {
_logger.debug("init(): using existing Configuration");
}
_configuration.setObjectWrapper(new DefaultObjectWrapper());
try {
String file = Messages
.getString("SurveyActivityEmailRendererImpl.templateHtml");
_template = _configuration.getTemplate(file);
if (_logger.isDebugEnabled())
_logger.debug("init(): loaded template from " + file);
} catch (IOException e) {
throw new RuntimeException("init(): error on template load", e);
}
initialized = true;
_logger.debug("init() completed initialization");
}
My messages.properties file contained in the same directory as the
service contains:
SurveyActivityEmailRendererImpl.templateDirectory=/
SurveyActivityEmailRendererImpl.templateHtml=nightly-notification.ftl
The template is in the root of the jar.
The actual generation uses:
try {
Writer out = new StringWriter();
_template.process(data, out);
out.flush();
htmlEmail = ((StringWriter) out).toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (TemplateException e) {
throw new RuntimeException(e);
}
return htmlEmail;
On Tue, Jan 10, 2012 at 2:50 PM, Julien Martin <ba...@gmail.com> wrote:
> Thanks a lot for your reply Jonathan,
> Can you share some code sample (if you have it to hand) please?
> Also where does this code go?
> *configuration.setClassForTemplateLoading(Class clazz, String directory)*
> Regards,
> Julien.
>
> 2012/1/10 Jonathan Barker <jo...@gmail.com>
>
>> The Freemarker project gave me similar problems. They have a
>> Configuration object where you can do
>> configuration.setClassForTemplateLoading(Class clazz, String
>> directory). Does Velocity have the same option? If it does, I just
>> used getClass() within my service to supply that Class parameter.
>>
>> On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo
>> <th...@gmail.com> wrote:
>> > On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com>
>> wrote:
>> >
>> >> Caused by: org.apache.velocity.exception.ResourceNotFoundException:
>> Unable
>> >> to find resource 'request-childminder-confirmation-mail-template_fr.htm'
>> >> at
>> >>
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
>> >
>> >
>> > This is where the problem is. Tapestry itself doesn't change the
>> classpath
>> > at all, just the classloader for classes in the controlled packages, so
>> this
>> > isn't related to Tapestry.
>> >
>> >
>> > --
>> > Thiago H. de Paula Figueiredo
>> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> > instructor
>> > Owner, Ars Machina Tecnologia da Informação Ltda.
>> > http://www.arsmachina.com.br
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>>
>>
>> --
>> Jonathan Barker
>> ITStrategic
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
--
Jonathan Barker
ITStrategic
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Novice user of Tapestry needs help with classpath issue
Posted by Julien Martin <ba...@gmail.com>.
Thanks a lot for your reply Jonathan,
Can you share some code sample (if you have it to hand) please?
Also where does this code go?
*configuration.setClassForTemplateLoading(Class clazz, String directory)*
Regards,
Julien.
2012/1/10 Jonathan Barker <jo...@gmail.com>
> The Freemarker project gave me similar problems. They have a
> Configuration object where you can do
> configuration.setClassForTemplateLoading(Class clazz, String
> directory). Does Velocity have the same option? If it does, I just
> used getClass() within my service to supply that Class parameter.
>
> On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
> > On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com>
> wrote:
> >
> >> Caused by: org.apache.velocity.exception.ResourceNotFoundException:
> Unable
> >> to find resource 'request-childminder-confirmation-mail-template_fr.htm'
> >> at
> >>
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
> >
> >
> > This is where the problem is. Tapestry itself doesn't change the
> classpath
> > at all, just the classloader for classes in the controlled packages, so
> this
> > isn't related to Tapestry.
> >
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and
> > instructor
> > Owner, Ars Machina Tecnologia da Informação Ltda.
> > http://www.arsmachina.com.br
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
>
> --
> Jonathan Barker
> ITStrategic
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Novice user of Tapestry needs help with classpath issue
Posted by Jonathan Barker <jo...@gmail.com>.
The Freemarker project gave me similar problems. They have a
Configuration object where you can do
configuration.setClassForTemplateLoading(Class clazz, String
directory). Does Velocity have the same option? If it does, I just
used getClass() within my service to supply that Class parameter.
On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com> wrote:
>
>> Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable
>> to find resource 'request-childminder-confirmation-mail-template_fr.htm'
>> at
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
>
>
> This is where the problem is. Tapestry itself doesn't change the classpath
> at all, just the classloader for classes in the controlled packages, so this
> isn't related to Tapestry.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
--
Jonathan Barker
ITStrategic
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Novice user of Tapestry needs help with classpath issue
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <ba...@gmail.com> wrote:
> Caused by: org.apache.velocity.exception.ResourceNotFoundException:
> Unable to find resource
> 'request-childminder-confirmation-mail-template_fr.htm'
> at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
This is where the problem is. Tapestry itself doesn't change the classpath
at all, just the classloader for classes in the controlled packages, so
this isn't related to Tapestry.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Novice user of Tapestry needs help with classpath issue
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 10 Jan 2012 14:46:01 -0200, Julien Martin <ba...@gmail.com> wrote:
> Hello,
Hi!
> *org.apache.tapestry5.runtime.ComponentEventException: Unable to find
> resource 'request-childminder-confirmation-mail-template_fr.htm' [at
> classpath:com/bignibou/web/pages/InscriptionProfessionnelGardeEnfant.tml,
> line 20]*
Full stack trace please. In addition, loading a resource from the
classpath using Tapestry is exactly the same as without Tapestry.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org