You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Robby Pelssers <ro...@ciber.nl> on 2009/01/28 18:50:57 UTC
Using spring configurator (for properties) in block
Hi all,
I read the documentation on the spring configurator. First let me
describe the usecase. I want to develop a block which should do not
much more then reading xml files from the filesystem. I want to use a
property file for the sitemap of the block.
Example:
<map:generate src="file://${repository.dir.flyerdefinitions}/{1}.xml
<file:///\\$%7brepository.dir.flyerdefinitions%7d\%7b1%7d.xml> " />
So I created following property file in
/META-INF/cocoon/properties/application.properties
repository.dir=D:/testdata
repository.dir.released=${repository.dir}/XML Repository
repository.dir.flyerdefinitions=${repository.dir.released}/Flyer
Definitions
However, to activate the spring configurator I would need to modify the
web.xml (configure listeners) and applicationContext.xml (initialize the
springconfigurator) of the webapp. Since I built the webapp using the
maven archetype all this was already in place. But it is not clear to
me if I need to perform an extra step to be able to read/use the
properties in the block which I declared as a dependency of my webapp.
Now I get following stacktrace so it seems the property file is not
found or properly read by the spring configurator.
Many thanks in advance,
Robby Pelssers
[INFO] Started Jetty Server
2009-01-28 18:12:36.069::WARN: Nested in
javax.servlet.ServletException: org.apache.cocoon.ProcessingException:
Sitemap: error invoking matcher
at <map:match> -
file:///D:/development/workspaces/nxp/productpreview2/target/work/blocks
/common/sitemap.xmap:30:36:
org.apache.cocoon.ProcessingException: Sitemap: error invoking matcher
at <map:match> -
file:///D:/development/workspaces/nxp/productpreview2/target/work/blocks
/common/sitemap.xmap:30:36
at
org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.j
ava:111)
at
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(Matc
hNode.java:90)
at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.
invokeNodes(AbstractParentProcessingNode.java:78)
at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(P
ipelineNode.java:143)
at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.
invokeNodes(AbstractParentProcessingNode.java:78)
at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(
PipelinesNode.java:81)
at
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process
(ConcreteTreeProcessor.java:239)
at
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process
(ConcreteTreeProcessor.java:171)
at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreePro
cessor.java:247)
at
org.apache.cocoon.servlet.RequestProcessor.process(RequestProcessor.java
:351)
at
org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java
:169)
at
org.apache.cocoon.sitemap.SitemapServlet.service(SitemapServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
org.apache.cocoon.servletservice.ServletServiceContext$PathDispatcher.fo
rward(ServletServiceContext.java:468)
at
org.apache.cocoon.servletservice.ServletServiceContext$PathDispatcher.fo
rward(ServletServiceContext.java:443)
at
org.apache.cocoon.servletservice.spring.ServletFactoryBean$ServiceInterc
eptor.invoke(ServletFactoryBean.java:264)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
pProxy.java:204)
at $Proxy5.service(Unknown Source)
at
org.apache.cocoon.servletservice.DispatcherServlet.service(DispatcherSer
vlet.java:106)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHan
dler.java:1093)
at
org.apache.cocoon.servlet.multipart.MultipartFilter.doFilter(MultipartFi
lter.java:131)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHan
dler.java:1084)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:2
16)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandler
Collection.java:206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.jav
a:114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConne
ction.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.ja
va:450)
Caused by: org.apache.cocoon.sitemap.PatternException: No value for
xpath: repository.dir
at
org.apache.cocoon.components.treeprocessor.variables.StringTemplateParse
rVariableResolver.resolve(StringTemplateParserVariableResolver.java:81)
at
org.apache.cocoon.components.treeprocessor.sitemap.GenerateNode.invoke(G
enerateNode.java:62)
at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.
invokeNodes(AbstractParentProcessingNode.java:55)
at
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(Matc
hNode.java:87)
... 39 more
Caused by: org.apache.commons.jxpath.JXPathException: No value for
xpath: repository.dir
at
org.apache.cocoon.components.treeprocessor.variables.LegacySubstitutions
.toString(LegacySubstitutions.java:57)
at
org.apache.cocoon.components.treeprocessor.variables.StringTemplateParse
rVariableResolver.resolve(StringTemplateParserVariableResolver.java:77)
Re: Using spring configurator (for properties) in block
Posted by Hubert Klein Ikkink <h....@gmail.com>.
Hi,
the Settings object is a Spring defined bean. So you can write your Java code
and inject the Settings object just like any other Spring bean.
public class MyJava {
private Settings settings;
@Required
public void setSettings(Settings s) {
this.settings = s;
}
}
See also http://static.springframework.org/spring/docs/2.5.x/reference/beans.html
Kind regards, Hubert Klein Ikkink
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Re: Using spring configurator (for properties) in block
Posted by Robby Pelssers <ro...@ciber.nl>.
One more question:
If I want to use these properties in my java classes... how can I use
them?
Anyone who can shortly show me the java code how to do this?
Thx,
Robby
-----Original Message-----
From: Robby Pelssers [mailto:robby.pelssers@ciber.nl]
Sent: donderdag 29 januari 2009 10:47
To: users@cocoon.apache.org; lmorandini@ieee.org
Subject: RE: Re: Using spring configurator (for properties) in block
Thx Luca,
You just saved me a lot of time.
I solved it by putting the environment (running mode) specific property
in a separate property file:
/META-INF/cocoon/properties/dev/repositorylocation.properties
repository.dir=D:/nxp/testdata
and the other shared properties in
/META-INF/cocoon/properties/reposistory.properties
repository.dir.flyerdefinitions=${repository.dir}/XML Repository/Flyer
Definitions
Works like a charm ;-)
Cheers,
Robby
-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Luca Morandini
Sent: donderdag 29 januari 2009 1:02
To: users@cocoon.apache.org
Subject: Re: Using spring configurator (for properties) in block
Robby Pelssers wrote:
>
> So I created following property file in
> /META-INF/cocoon/properties/application.properties
> repository.dir=D:/_testdata_
> repository.dir.released=${repository._dir_}/XML Repository
> repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
> Definitions
Maven doesn't expand properties like Ant does, you either have to avoid
it, like in:
repository.dir.flyerdefinitions=D:/_testdata_/XML Repository/Flyer
Definitions
...or ...since Cocoon reads properties files according to their names,
you can still enjoy properties expansion by splitting the properties
into different files:
/META-INF/cocoon/properties/application.properties
repository.dir=D:/_testdata_
/META-INF/cocoon/properties/b-application.properties
repository.dir.released=${repository._dir_}/XML Repository
/META-INF/cocoon/properties/c-application.properties
repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
Definitions
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Re: Using spring configurator (for properties) in block
Posted by Robby Pelssers <ro...@ciber.nl>.
Thx Luca,
You just saved me a lot of time.
I solved it by putting the environment (running mode) specific property
in a separate property file:
/META-INF/cocoon/properties/dev/repositorylocation.properties
repository.dir=D:/nxp/testdata
and the other shared properties in
/META-INF/cocoon/properties/reposistory.properties
repository.dir.flyerdefinitions=${repository.dir}/XML Repository/Flyer
Definitions
Works like a charm ;-)
Cheers,
Robby
-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Luca Morandini
Sent: donderdag 29 januari 2009 1:02
To: users@cocoon.apache.org
Subject: Re: Using spring configurator (for properties) in block
Robby Pelssers wrote:
>
> So I created following property file in
> /META-INF/cocoon/properties/application.properties
> repository.dir=D:/_testdata_
> repository.dir.released=${repository._dir_}/XML Repository
> repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
> Definitions
Maven doesn't expand properties like Ant does, you either have to avoid
it, like in:
repository.dir.flyerdefinitions=D:/_testdata_/XML Repository/Flyer
Definitions
...or ...since Cocoon reads properties files according to their names,
you can still enjoy properties expansion by splitting the properties
into different files:
/META-INF/cocoon/properties/application.properties
repository.dir=D:/_testdata_
/META-INF/cocoon/properties/b-application.properties
repository.dir.released=${repository._dir_}/XML Repository
/META-INF/cocoon/properties/c-application.properties
repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
Definitions
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Using spring configurator (for properties) in block
Posted by Luca Morandini <lm...@ieee.org>.
Robby Pelssers wrote:
>
> So I created following property file in
> /META-INF/cocoon/properties/application.properties
> repository.dir=D:/_testdata_
> repository.dir.released=${repository._dir_}/XML Repository
> repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
> Definitions
Maven doesn't expand properties like Ant does, you either have to avoid
it, like in:
repository.dir.flyerdefinitions=D:/_testdata_/XML Repository/Flyer
Definitions
...or ...since Cocoon reads properties files according to their names,
you can still enjoy properties expansion by splitting the properties
into different files:
/META-INF/cocoon/properties/application.properties
repository.dir=D:/_testdata_
/META-INF/cocoon/properties/b-application.properties
repository.dir.released=${repository._dir_}/XML Repository
/META-INF/cocoon/properties/c-application.properties
repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
Definitions
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Using spring configurator (for properties) in block
Posted by Reinhard Pötz <re...@apache.org>.
Robby Pelssers wrote:
> Hi all,
>
> I read the documentation on the spring configurator. First let me
> describe the usecase. I want to develop a block which should do not
> much more then reading xml files from the filesystem. I want to use a
> property file for the sitemap of the block.
>
>
>
> Example:
>
> <map:generate src="file://${repository.dir.flyerdefinitions}/{1}.xml
> <file:///\\$%7brepository.dir.flyerdefinitions%7d\%7b1%7d.xml>" />
>
>
>
> So I created following property file in
> /META-INF/cocoon/properties/application.properties
>
>
>
> repository.dir=D:/_testdata_
>
> repository.dir.released=${repository._dir_}/XML Repository
>
> repository.dir.flyerdefinitions=${repository._dir_.released}/Flyer
> Definitions
<snip/>
you don't use the correct expression to access your properties. IIRC it
should be {global:repository.dir} in your case.
HTH
--
Reinhard Pötz Managing Director, {Indoqa} GmbH
http://www.indoqa.com/en/people/reinhard.poetz/
Member of the Apache Software Foundation
Apache Cocoon Committer, PMC member reinhard@apache.org
________________________________________________________________________