You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ilya Sterin <st...@gmail.com> on 2006/05/07 00:25:43 UTC
Including files from another module in the webapp module
All, I have a multi-module project, one called domain (where most
business logic is located) and the other is webapp.
I'm using Spring.
In my domain module, I have various Spring context configuration files
in the resources directory. In order to make things work with Spring
MVC in the webapp module, my web.xml file has the following...
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-web.xml
/WEB-INF/applicationContext-domain.xml
</param-value>
</context-param>
Specifying the various collections of Spring configuration files.
The question is, when I build my webapp module, what is the best way
to grab the applicationContext-domain.xml file from the domain modules
resources dir and place it in WEB-INF?
Also, I might still have a Ant way of doing things:-), so if you have
any recommendations of the best way of doing this, please let me know.
I can't simply have this file in the WEB-INF dir to begin with, since
the domain module needs to be able to run independent unit tests and
will eventually provide other services that are not served to a web
client.
Any ideas would be appreciated.
Thanks.
Ilya Sterin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including files from another module in the webapp module
Posted by Ilya Sterin <st...@gmail.com>.
Great, thanks, that will work.
Ilya
On 5/8/06, ian.d.stewart@jpmchase.com <ia...@jpmchase.com> wrote:
> If applicationContext-domain.xml is a resource within a sub-project with
> packaging="jar", then it should be accessible using the classpath: pseudo
> protocol from any projects that depend on the sub-project.
>
> For example:
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>classpath:applicationContext-domain.xml</param-value>
> </context-param>
>
> A better practive, IMO, is to place the application context XML document in
> the project-specific package. Then you could have something like:
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> classpath:com/example/myproj/applicationContext.xml
> classpath:com/example/myproj/domain/applicationContext.xml
> classpath:com/example/myproj/web/applicationContext.xml
> </param-value>
> </context-param>
>
> Where com/example/myproj/applicationContext.xml contains bean definitions
> common to both domain and web, any beans defined in
> com/example/myproj/domain/applicationContext.xml will override beans with
> the same id as those defined in com/example/myproj/applicationContext.xml,
> same thing for com/example/myproj/web/applicationContext.xml vis-a-vis
> com/example/myproj/domain/applicationContext.xml
>
> It's better to be hated for who you are
> than loved for who you are not
>
> Ian D. Stewart
> Appl Dev Analyst-Advisory, DCS Automation
> JPMorganChase Global Technology Infrastructure
> Phone: (614) 244-2564
> Pager: (888) 260-0078
>
>
>
> "Alexandre
> Poitras" To: "Maven Users List" <us...@maven.apache.org>
> <alexandre.poitras cc:
> @gmail.com> Subject: Re: Including files from another module in the webapp module
>
> 05/06/2006 10:36
> PM
> Please respond to
> "Maven Users List"
>
>
>
>
>
> If you also use those files in the domain project, they shouldn't be in the
> WEB-INF directory because you would have to duplicate them. It wouldn't be
> a
> very good design. So your issue isn't related to Maven but to your
> application structure. You should fix this by specifying the following
> entries in your web.xml file :
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
>
> > <param-value>
> > applicationContext-web.xml
> > applicationContext-domain.xml
> > </param-value>
> > </context-param>
>
>
> Simple as that.
>
> On 5/6/06, Ilya Sterin <st...@gmail.com> wrote:
> >
> > All, I have a multi-module project, one called domain (where most
> > business logic is located) and the other is webapp.
> >
> > I'm using Spring.
> >
> > In my domain module, I have various Spring context configuration files
> > in the resources directory. In order to make things work with Spring
> > MVC in the webapp module, my web.xml file has the following...
> >
> > <context-param>
> > <param-name>contextConfigLocation</param-name>
> > <param-value>
> > /WEB-INF/applicationContext-web.xml
> > /WEB-INF/applicationContext-domain.xml
> > </param-value>
> > </context-param>
> >
> > Specifying the various collections of Spring configuration files.
> >
> > The question is, when I build my webapp module, what is the best way
> > to grab the applicationContext-domain.xml file from the domain modules
> > resources dir and place it in WEB-INF?
> >
> > Also, I might still have a Ant way of doing things:-), so if you have
> > any recommendations of the best way of doing this, please let me know.
> > I can't simply have this file in the WEB-INF dir to begin with, since
> > the domain module needs to be able to run independent unit tests and
> > will eventually provide other services that are not served to a web
> > client.
> >
> > Any ideas would be appreciated.
> >
> > Thanks.
> >
> > Ilya Sterin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including files from another module in the webapp module
Posted by ia...@jpmchase.com.
If applicationContext-domain.xml is a resource within a sub-project with
packaging="jar", then it should be accessible using the classpath: pseudo
protocol from any projects that depend on the sub-project.
For example:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-domain.xml</param-value>
</context-param>
A better practive, IMO, is to place the application context XML document in
the project-specific package. Then you could have something like:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/example/myproj/applicationContext.xml
classpath:com/example/myproj/domain/applicationContext.xml
classpath:com/example/myproj/web/applicationContext.xml
</param-value>
</context-param>
Where com/example/myproj/applicationContext.xml contains bean definitions
common to both domain and web, any beans defined in
com/example/myproj/domain/applicationContext.xml will override beans with
the same id as those defined in com/example/myproj/applicationContext.xml,
same thing for com/example/myproj/web/applicationContext.xml vis-a-vis
com/example/myproj/domain/applicationContext.xml
It's better to be hated for who you are
than loved for who you are not
Ian D. Stewart
Appl Dev Analyst-Advisory, DCS Automation
JPMorganChase Global Technology Infrastructure
Phone: (614) 244-2564
Pager: (888) 260-0078
"Alexandre
Poitras" To: "Maven Users List" <us...@maven.apache.org>
<alexandre.poitras cc:
@gmail.com> Subject: Re: Including files from another module in the webapp module
05/06/2006 10:36
PM
Please respond to
"Maven Users List"
If you also use those files in the domain project, they shouldn't be in the
WEB-INF directory because you would have to duplicate them. It wouldn't be
a
very good design. So your issue isn't related to Maven but to your
application structure. You should fix this by specifying the following
entries in your web.xml file :
<context-param>
<param-name>contextConfigLocation</param-name>
> <param-value>
> applicationContext-web.xml
> applicationContext-domain.xml
> </param-value>
> </context-param>
Simple as that.
On 5/6/06, Ilya Sterin <st...@gmail.com> wrote:
>
> All, I have a multi-module project, one called domain (where most
> business logic is located) and the other is webapp.
>
> I'm using Spring.
>
> In my domain module, I have various Spring context configuration files
> in the resources directory. In order to make things work with Spring
> MVC in the webapp module, my web.xml file has the following...
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> /WEB-INF/applicationContext-web.xml
> /WEB-INF/applicationContext-domain.xml
> </param-value>
> </context-param>
>
> Specifying the various collections of Spring configuration files.
>
> The question is, when I build my webapp module, what is the best way
> to grab the applicationContext-domain.xml file from the domain modules
> resources dir and place it in WEB-INF?
>
> Also, I might still have a Ant way of doing things:-), so if you have
> any recommendations of the best way of doing this, please let me know.
> I can't simply have this file in the WEB-INF dir to begin with, since
> the domain module needs to be able to run independent unit tests and
> will eventually provide other services that are not served to a web
> client.
>
> Any ideas would be appreciated.
>
> Thanks.
>
> Ilya Sterin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including files from another module in the webapp module
Posted by Alexandre Poitras <al...@gmail.com>.
If you also use those files in the domain project, they shouldn't be in the
WEB-INF directory because you would have to duplicate them. It wouldn't be a
very good design. So your issue isn't related to Maven but to your
application structure. You should fix this by specifying the following
entries in your web.xml file :
<context-param>
<param-name>contextConfigLocation</param-name>
> <param-value>
> applicationContext-web.xml
> applicationContext-domain.xml
> </param-value>
> </context-param>
Simple as that.
On 5/6/06, Ilya Sterin <st...@gmail.com> wrote:
>
> All, I have a multi-module project, one called domain (where most
> business logic is located) and the other is webapp.
>
> I'm using Spring.
>
> In my domain module, I have various Spring context configuration files
> in the resources directory. In order to make things work with Spring
> MVC in the webapp module, my web.xml file has the following...
>
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> /WEB-INF/applicationContext-web.xml
> /WEB-INF/applicationContext-domain.xml
> </param-value>
> </context-param>
>
> Specifying the various collections of Spring configuration files.
>
> The question is, when I build my webapp module, what is the best way
> to grab the applicationContext-domain.xml file from the domain modules
> resources dir and place it in WEB-INF?
>
> Also, I might still have a Ant way of doing things:-), so if you have
> any recommendations of the best way of doing this, please let me know.
> I can't simply have this file in the WEB-INF dir to begin with, since
> the domain module needs to be able to run independent unit tests and
> will eventually provide other services that are not served to a web
> client.
>
> Any ideas would be appreciated.
>
> Thanks.
>
> Ilya Sterin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>