You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sigmond Hola <si...@gmail.com> on 2018/01/13 02:33:09 UTC

Running tomcat maven plugin in a multi modules project

I have a multi-module project like this:

ROOT:pom
    --- web:war
    --- domain:jar
    --- service:jar
    --- dao:jar

And i configure tomcat7-maven-plugin in pom.xml of module *web *so that I
can using tomcat:run to run this web application.

But if I change something in other module, for example, add a new entity
class in module domain, I have to install the ROOT to local repo first
before I run tomcat:run within module web, otherwise a error: cannot find
symbol will be reported if I run tomcat:run directly.

So how can I install other modules first before I run tomcat:run within
module web if I change something in other modules?

Thanks in advance.

Best regards.

Re: Running tomcat maven plugin in a multi modules project

Posted by Martin Gainty <mg...@hotmail.com>.
MG>this is a helpful link to implement "deploy your war to Tomcat via tomcat-maven-plugin"

https://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/

How to deploy Maven based war file to Tomcat - Mkyong<https://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/>
www.mkyong.com
In this tutorial, we will show you how to use Maven-Tomcat plugin to package and deploy a WAR file to Tomcat, both in Tomcat 6 and 7. This example shows you how to ...

MG>this *assumes* uptodate artifact jars from <dependencies> are pre-installed to repository(your local repository)



________________________________
From: Martin Gainty <mg...@hotmail.com>
Sent: Friday, January 12, 2018 10:05 PM
To: Maven Users List
Subject: Re: Running tomcat maven plugin in a multi modules project


MG>knowing you're not going to find your artifacts in any of maven repositories you will need to deploy local repo
MG>look at the Tomcat autodeploy feature for any changes to war to 'autodeploy' to specified location (which in TC is MG>webapps folder but for maven-plugin you will <auto>deploy to your local repo)

MG>if you could clone project to github and share the link we could more closely track any errors you are experiencing


________________________________
From: Sigmond Hola <si...@gmail.com>
Sent: Friday, January 12, 2018 9:33 PM
To: users@maven.apache.org
Subject: Running tomcat maven plugin in a multi modules project

I have a multi-module project like this:

ROOT:pom
    --- web:war
    --- domain:jar
    --- service:jar
    --- dao:jar

And i configure tomcat7-maven-plugin in pom.xml of module *web *so that I
can using tomcat:run to run this web application.

But if I change something in other module, for example, add a new entity
class in module domain, I have to install the ROOT to local repo first
before I run tomcat:run within module web, otherwise a error: cannot find
symbol will be reported if I run tomcat:run directly.

So how can I install other modules first before I run tomcat:run within
module web if I change something in other modules?

Thanks in advance.

Best regards.

Re: Running tomcat maven plugin in a multi modules project

Posted by Martin Gainty <mg...@hotmail.com>.
MG>knowing you're not going to find your artifacts in any of maven repositories you will need to deploy local repo
MG>look at the Tomcat autodeploy feature for any changes to war to 'autodeploy' to specified location (which in TC is MG>webapps folder but for maven-plugin you will <auto>deploy to your local repo)

MG>if you could clone project to github and share the link we could more closely track any errors you are experiencing


________________________________
From: Sigmond Hola <si...@gmail.com>
Sent: Friday, January 12, 2018 9:33 PM
To: users@maven.apache.org
Subject: Running tomcat maven plugin in a multi modules project

I have a multi-module project like this:

ROOT:pom
    --- web:war
    --- domain:jar
    --- service:jar
    --- dao:jar

And i configure tomcat7-maven-plugin in pom.xml of module *web *so that I
can using tomcat:run to run this web application.

But if I change something in other module, for example, add a new entity
class in module domain, I have to install the ROOT to local repo first
before I run tomcat:run within module web, otherwise a error: cannot find
symbol will be reported if I run tomcat:run directly.

So how can I install other modules first before I run tomcat:run within
module web if I change something in other modules?

Thanks in advance.

Best regards.

Re: Running tomcat maven plugin in a multi modules project

Posted by Martin Gainty <mg...@hotmail.com>.
FWIK of TC

anything you pack into war deployed to $TOMCAT_HOME will be unpacked when TC autodeploy feature is true

if you may have something like contents of webapp1:
webapp1/WEB-INF/classes/AllWebapp1*.class

              ./WEB-INF/lib/dependencyA.jar

              ./WEB-INF/lib/dependencyB.jar

              ./WEB-INF/web.xml

              ./WEB-INF/index.jsp

*when TC HTTPClient issues request to http://server:8080/reload?path=webapp1.war will reload (when autodeploy=true)*

$TOMCAT_HOME/webapps/webapp1/WEB-INF/classes/AllWebapp1*.class

                                                             ./WEB-INF/lib/dependencyA.jar

                                                             ./WEB-INF/lib/dependencyB.jar

                                                             ./WEB-INF/web.xml

                                                             ./WEB-INF/index.jsp

so the effort here is to fatpack your webapp war with all dependencies will need before issuing HTTPClient request to tc


does this conform to your understanding?

Martin
______________________________________________



________________________________
From: Thomas Broyer <t....@gmail.com>
Sent: Sunday, January 14, 2018 3:32 AM
To: Maven Users List
Subject: Re: Running tomcat maven plugin in a multi modules project

Oh great, thanks for the heads up! (I had asked for this years ago and then
they moved to Eclipse and I lost track)

Le sam. 13 janv. 2018 23:24, Olivier Lamy <ol...@apache.org> a écrit :

> Hi,
> Well to be fair Jetty Maven Plugin has now this feature as well...
>
> On 14 January 2018 at 03:25, Thomas Broyer <t....@gmail.com> wrote:
>
> > On Sat, Jan 13, 2018 at 3:20 PM Thomas Broyer <t....@gmail.com>
> wrote:
> >
> > > Tomcat Maven plugin has built-in support for reactors, so run it at
> root
> > > rather than within the web submodule (possibly with "-pl web -am"). It
> > will
> > > automatically compile all (needed) submodules and launch Tomcat, and
> with
> > > auto-deploy will automatically reload the webapp to pickup changes in
> any
> > > submodule.
> > >
> >
> > From https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html
Apache Tomcat Maven Plugin - Run Mojo<https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html>
tomcat.apache.org
Run Mojo: run your Maven war project quickly! When developing a war project, you usually build your war and deploy it to an installed Tomcat instance.



> > > NOTE If you have a multi module Maven project and use Maven3,
> > > you don't need to install all modules before using the run goal, just
> > > use tomcat6/7:run from the root module and the plugin will auto
> > > detect the build output directory from various modules and replace
> > > dependencies with those directories in the webapp classloader.
> >
> > (too bad there's been no new release for 4 years though, this is probably
> > one of the best thought-out Maven plugin out there in terms of usability
> > wrt multi-module projects, and without being "hackish"; without that,
> > people keep having to install all their snapshots into their local repo
> and
> > rebuilding them over and over again, if only to make sure they're the
> ones
> > for the correct commit / code state)
> >
> >
> > > Le sam. 13 janv. 2018 03:33, Sigmond Hola <si...@gmail.com> a
> > > écrit :
> > >
> > >> I have a multi-module project like this:
> > >>
> > >> ROOT:pom
> > >>     --- web:war
> > >>     --- domain:jar
> > >>     --- service:jar
> > >>     --- dao:jar
> > >>
> > >> And i configure tomcat7-maven-plugin in pom.xml of module *web *so
> that
> > I
> > >> can using tomcat:run to run this web application.
> > >>
> > >> But if I change something in other module, for example, add a new
> entity
> > >> class in module domain, I have to install the ROOT to local repo first
> > >> before I run tomcat:run within module web, otherwise a error: cannot
> > find
> > >> symbol will be reported if I run tomcat:run directly.
> > >>
> > >> So how can I install other modules first before I run tomcat:run
> within
> > >> module web if I change something in other modules?
> > >>
> > >> Thanks in advance.
> > >>
> > >> Best regards.
> > >>
> > >
> >
>
>
>
> --
> Olivier Lamy
> http://twitter.com/olamy | http://linkedin.com/in/olamy
[https://media-exp2.licdn.com/mpr/mpr/shrinknp_200_200/AAEAAQAAAAAAAAaBAAAAJDY5Y2Q3ZjA5LTAzMGItNGRlNC05MTdjLTM2ZDMzMjdkYzkwOQ.jpg]<http://linkedin.com/in/olamy>

Olivier Lamy | Professional Profile | LinkedIn<http://linkedin.com/in/olamy>
linkedin.com
View Olivier Lamy’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like Olivier Lamy discover inside connections to recommended job candidates, industry experts, and business partners.


[https://abs.twimg.com/a/1513823426/img/search/ic_places_foursquare_logo.png]<http://twitter.com/olamy>

Olivier Lamy (@olamy) | Twitter<http://twitter.com/olamy>
twitter.com
The latest Tweets from Olivier Lamy (@olamy). Speaking English with a strong French accent! #OpenSource #Apache #jetty #jenkins #ultrarunning. Living #downunder ...



>

Re: Running tomcat maven plugin in a multi modules project

Posted by Thomas Broyer <t....@gmail.com>.
Oh great, thanks for the heads up! (I had asked for this years ago and then
they moved to Eclipse and I lost track)

Le sam. 13 janv. 2018 23:24, Olivier Lamy <ol...@apache.org> a écrit :

> Hi,
> Well to be fair Jetty Maven Plugin has now this feature as well...
>
> On 14 January 2018 at 03:25, Thomas Broyer <t....@gmail.com> wrote:
>
> > On Sat, Jan 13, 2018 at 3:20 PM Thomas Broyer <t....@gmail.com>
> wrote:
> >
> > > Tomcat Maven plugin has built-in support for reactors, so run it at
> root
> > > rather than within the web submodule (possibly with "-pl web -am"). It
> > will
> > > automatically compile all (needed) submodules and launch Tomcat, and
> with
> > > auto-deploy will automatically reload the webapp to pickup changes in
> any
> > > submodule.
> > >
> >
> > From https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html
> > > NOTE If you have a multi module Maven project and use Maven3,
> > > you don't need to install all modules before using the run goal, just
> > > use tomcat6/7:run from the root module and the plugin will auto
> > > detect the build output directory from various modules and replace
> > > dependencies with those directories in the webapp classloader.
> >
> > (too bad there's been no new release for 4 years though, this is probably
> > one of the best thought-out Maven plugin out there in terms of usability
> > wrt multi-module projects, and without being "hackish"; without that,
> > people keep having to install all their snapshots into their local repo
> and
> > rebuilding them over and over again, if only to make sure they're the
> ones
> > for the correct commit / code state)
> >
> >
> > > Le sam. 13 janv. 2018 03:33, Sigmond Hola <si...@gmail.com> a
> > > écrit :
> > >
> > >> I have a multi-module project like this:
> > >>
> > >> ROOT:pom
> > >>     --- web:war
> > >>     --- domain:jar
> > >>     --- service:jar
> > >>     --- dao:jar
> > >>
> > >> And i configure tomcat7-maven-plugin in pom.xml of module *web *so
> that
> > I
> > >> can using tomcat:run to run this web application.
> > >>
> > >> But if I change something in other module, for example, add a new
> entity
> > >> class in module domain, I have to install the ROOT to local repo first
> > >> before I run tomcat:run within module web, otherwise a error: cannot
> > find
> > >> symbol will be reported if I run tomcat:run directly.
> > >>
> > >> So how can I install other modules first before I run tomcat:run
> within
> > >> module web if I change something in other modules?
> > >>
> > >> Thanks in advance.
> > >>
> > >> Best regards.
> > >>
> > >
> >
>
>
>
> --
> Olivier Lamy
> http://twitter.com/olamy | http://linkedin.com/in/olamy
>

Re: Running tomcat maven plugin in a multi modules project

Posted by Olivier Lamy <ol...@apache.org>.
Hi,
Well to be fair Jetty Maven Plugin has now this feature as well...

On 14 January 2018 at 03:25, Thomas Broyer <t....@gmail.com> wrote:

> On Sat, Jan 13, 2018 at 3:20 PM Thomas Broyer <t....@gmail.com> wrote:
>
> > Tomcat Maven plugin has built-in support for reactors, so run it at root
> > rather than within the web submodule (possibly with "-pl web -am"). It
> will
> > automatically compile all (needed) submodules and launch Tomcat, and with
> > auto-deploy will automatically reload the webapp to pickup changes in any
> > submodule.
> >
>
> From https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html
> > NOTE If you have a multi module Maven project and use Maven3,
> > you don't need to install all modules before using the run goal, just
> > use tomcat6/7:run from the root module and the plugin will auto
> > detect the build output directory from various modules and replace
> > dependencies with those directories in the webapp classloader.
>
> (too bad there's been no new release for 4 years though, this is probably
> one of the best thought-out Maven plugin out there in terms of usability
> wrt multi-module projects, and without being "hackish"; without that,
> people keep having to install all their snapshots into their local repo and
> rebuilding them over and over again, if only to make sure they're the ones
> for the correct commit / code state)
>
>
> > Le sam. 13 janv. 2018 03:33, Sigmond Hola <si...@gmail.com> a
> > écrit :
> >
> >> I have a multi-module project like this:
> >>
> >> ROOT:pom
> >>     --- web:war
> >>     --- domain:jar
> >>     --- service:jar
> >>     --- dao:jar
> >>
> >> And i configure tomcat7-maven-plugin in pom.xml of module *web *so that
> I
> >> can using tomcat:run to run this web application.
> >>
> >> But if I change something in other module, for example, add a new entity
> >> class in module domain, I have to install the ROOT to local repo first
> >> before I run tomcat:run within module web, otherwise a error: cannot
> find
> >> symbol will be reported if I run tomcat:run directly.
> >>
> >> So how can I install other modules first before I run tomcat:run within
> >> module web if I change something in other modules?
> >>
> >> Thanks in advance.
> >>
> >> Best regards.
> >>
> >
>



-- 
Olivier Lamy
http://twitter.com/olamy | http://linkedin.com/in/olamy

Re: Running tomcat maven plugin in a multi modules project

Posted by Thomas Broyer <t....@gmail.com>.
On Sat, Jan 13, 2018 at 3:20 PM Thomas Broyer <t....@gmail.com> wrote:

> Tomcat Maven plugin has built-in support for reactors, so run it at root
> rather than within the web submodule (possibly with "-pl web -am"). It will
> automatically compile all (needed) submodules and launch Tomcat, and with
> auto-deploy will automatically reload the webapp to pickup changes in any
> submodule.
>

From https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html
> NOTE If you have a multi module Maven project and use Maven3,
> you don't need to install all modules before using the run goal, just
> use tomcat6/7:run from the root module and the plugin will auto
> detect the build output directory from various modules and replace
> dependencies with those directories in the webapp classloader.

(too bad there's been no new release for 4 years though, this is probably
one of the best thought-out Maven plugin out there in terms of usability
wrt multi-module projects, and without being "hackish"; without that,
people keep having to install all their snapshots into their local repo and
rebuilding them over and over again, if only to make sure they're the ones
for the correct commit / code state)


> Le sam. 13 janv. 2018 03:33, Sigmond Hola <si...@gmail.com> a
> écrit :
>
>> I have a multi-module project like this:
>>
>> ROOT:pom
>>     --- web:war
>>     --- domain:jar
>>     --- service:jar
>>     --- dao:jar
>>
>> And i configure tomcat7-maven-plugin in pom.xml of module *web *so that I
>> can using tomcat:run to run this web application.
>>
>> But if I change something in other module, for example, add a new entity
>> class in module domain, I have to install the ROOT to local repo first
>> before I run tomcat:run within module web, otherwise a error: cannot find
>> symbol will be reported if I run tomcat:run directly.
>>
>> So how can I install other modules first before I run tomcat:run within
>> module web if I change something in other modules?
>>
>> Thanks in advance.
>>
>> Best regards.
>>
>

Re: Running tomcat maven plugin in a multi modules project

Posted by Thomas Broyer <t....@gmail.com>.
Tomcat Maven plugin has built-in support for reactors, so run it at root
rather than within the web submodule (possibly with "-pl web -am"). It will
automatically compile all (needed) submodules and launch Tomcat, and with
auto-deploy will automatically reload the webapp to pickup changes in any
submodule.

Le sam. 13 janv. 2018 03:33, Sigmond Hola <si...@gmail.com> a écrit :

> I have a multi-module project like this:
>
> ROOT:pom
>     --- web:war
>     --- domain:jar
>     --- service:jar
>     --- dao:jar
>
> And i configure tomcat7-maven-plugin in pom.xml of module *web *so that I
> can using tomcat:run to run this web application.
>
> But if I change something in other module, for example, add a new entity
> class in module domain, I have to install the ROOT to local repo first
> before I run tomcat:run within module web, otherwise a error: cannot find
> symbol will be reported if I run tomcat:run directly.
>
> So how can I install other modules first before I run tomcat:run within
> module web if I change something in other modules?
>
> Thanks in advance.
>
> Best regards.
>