You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Greg Amerson <gr...@liferay.com> on 2013/09/09 05:18:50 UTC

Deploying war from dependency with tomcat7-maven-plugin

Hello all,

I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
tomcat7:run* command.

However, in my case I have two requirements that are different than the
documentation provides for and I'm wondering if it is possible with the
current tomcat7-maven-plugin.

1. need to deploy several jars to the global tomcat classpath (i.e. same as
copying them into <tomcat.home>/lib/ext/ folder in a standalone install).
2. need to deploy a war to the ROOT context but instead of packaging the
current project from source, I just need to point to an existing WAR as a
dependency.

So in my project there will be no webapp source.  I simply want to run a
tomcat with some extra jars in /lib/ext/ directory and also deploy a war
that is obtained via a <dependency> with war type instead of packaged from
source.

Thanks in advance for any help!

-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

Re: Deploying war from dependency with tomcat7-maven-plugin

Posted by Greg Amerson <gr...@liferay.com>.
Thanks Olivier,

I was able to use your examples and specifying the dependencies manually
and got it work nicely.  So I just put Liferay portal web war package into
my webapps section and also enumerated all the dependencies that need to be
available to Embedded tomcat and it worked!  For anyone interested here it
is: https://gist.github.com/gamerson/6510740

G



On Tue, Sep 10, 2013 at 2:19 PM, Olivier Lamy <ol...@apache.org> wrote:

> for 1) your jars must be in the plugin dependencies section (see jdbc
> driver here
> http://tomcat.apache.org/maven-plugin-trunk/run-mojo-features.html
> )
> for 2) I understand you simply want to run a war (and maybe run unit
> tests) so unpacking with the dependency looks to be the solution.
>
> HTH
>
> Olivier
>
> On 9 September 2013 13:18, Greg Amerson <gr...@liferay.com>
> wrote:
> > Hello all,
> >
> > I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
> > tomcat7:run* command.
> >
> > However, in my case I have two requirements that are different than the
> > documentation provides for and I'm wondering if it is possible with the
> > current tomcat7-maven-plugin.
> >
> > 1. need to deploy several jars to the global tomcat classpath (i.e. same
> as
> > copying them into <tomcat.home>/lib/ext/ folder in a standalone install).
> > 2. need to deploy a war to the ROOT context but instead of packaging the
> > current project from source, I just need to point to an existing WAR as a
> > dependency.
> >
> > So in my project there will be no webapp source.  I simply want to run a
> > tomcat with some extra jars in /lib/ext/ directory and also deploy a war
> > that is obtained via a <dependency> with war type instead of packaged
> from
> > source.
> >
> > Thanks in advance for any help!
> >
> > --
> > Greg Amerson
> > Liferay Developer Tools
> > Liferay, Inc. www.liferay.com
>
>
>
> --
> Olivier Lamy
> Ecetera: http://ecetera.com.au
> http://twitter.com/olamy | http://linkedin.com/in/olamy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

Re: Deploying war from dependency with tomcat7-maven-plugin

Posted by Olivier Lamy <ol...@apache.org>.
for 1) your jars must be in the plugin dependencies section (see jdbc
driver here http://tomcat.apache.org/maven-plugin-trunk/run-mojo-features.html
)
for 2) I understand you simply want to run a war (and maybe run unit
tests) so unpacking with the dependency looks to be the solution.

HTH

Olivier

On 9 September 2013 13:18, Greg Amerson <gr...@liferay.com> wrote:
> Hello all,
>
> I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
> tomcat7:run* command.
>
> However, in my case I have two requirements that are different than the
> documentation provides for and I'm wondering if it is possible with the
> current tomcat7-maven-plugin.
>
> 1. need to deploy several jars to the global tomcat classpath (i.e. same as
> copying them into <tomcat.home>/lib/ext/ folder in a standalone install).
> 2. need to deploy a war to the ROOT context but instead of packaging the
> current project from source, I just need to point to an existing WAR as a
> dependency.
>
> So in my project there will be no webapp source.  I simply want to run a
> tomcat with some extra jars in /lib/ext/ directory and also deploy a war
> that is obtained via a <dependency> with war type instead of packaged from
> source.
>
> Thanks in advance for any help!
>
> --
> Greg Amerson
> Liferay Developer Tools
> Liferay, Inc. www.liferay.com



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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Deploying war from dependency with tomcat7-maven-plugin

Posted by Mak Pandian <ma...@gmail.com>.
Hi Greg,

Your requirement is quite interesting and I am looking forward some fine
recommendation from our users.


On Mon, Sep 9, 2013 at 8:48 AM, Greg Amerson <gr...@liferay.com>wrote:

> Hello all,
>
> I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
> tomcat7:run* command.
>
> However, in my case I have two requirements that are different than the
> documentation provides for and I'm wondering if it is possible with the
> current tomcat7-maven-plugin.
>
> 1. need to deploy several jars to the global tomcat classpath (i.e. same as
> copying them into <tomcat.home>/lib/ext/ folder in a standalone install).
> 2. need to deploy a war to the ROOT context but instead of packaging the
> current project from source, I just need to point to an existing WAR as a
> dependency.
>
> So in my project there will be no webapp source.  I simply want to run a
> tomcat with some extra jars in /lib/ext/ directory and also deploy a war
> that is obtained via a <dependency> with war type instead of packaged from
> source.
>
> Thanks in advance for any help!
>
> --
> Greg Amerson
> Liferay Developer Tools
> Liferay, Inc. www.liferay.com
>



-- 
*Thanks & Regards*
* *
*Pandian*
*(Living @ Virtual World)*

Re: Deploying war from dependency with tomcat7-maven-plugin

Posted by Cédric Couralet <ce...@gmail.com>.
2013/9/9 Greg Amerson <gr...@liferay.com>:
> Hello all,
>
> I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
> tomcat7:run* command.
>
> However, in my case I have two requirements that are different than the
> documentation provides for and I'm wondering if it is possible with the
> current tomcat7-maven-plugin.
>
> 1. need to deploy several jars to the global tomcat classpath (i.e. same as
> copying them into <tomcat.home>/lib/ext/ folder in a standalone install).
> 2. need to deploy a war to the ROOT context but instead of packaging the
> current project from source, I just need to point to an existing WAR as a
> dependency.
>
> So in my project there will be no webapp source.  I simply want to run a
> tomcat with some extra jars in /lib/ext/ directory and also deploy a war
> that is obtained via a <dependency> with war type instead of packaged from
> source.
>
> Thanks in advance for any help!
>

Hi,

I don't know if it could answer your question but I think I do
something similar for integration testing.

First to add jar to embedded tomcat used by by the plugin, Ideclare
those Jar as dependencies for the plugin.

Then to add a different war I use the dependency plugin to unzip the
war in the current project build directory and then use the tomcat
plugin to launch it :
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>unzip-webapp</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>

<artifactId>${artifact-to-import}</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                </artifactItem>
                            </artifactItems>

<outputDirectory>${project.build.directory}/webapp</outputDirectory>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>tomcat-run</id>
                        <goals>
                            <goal>run-war-only</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <path>/</path>
                            <port>8080</port>
                            <uriEncoding>UTF-8</uriEncoding>

<warDirectory>${project.build.directory}/webapp/</warDirectory>
                            <fork>true</fork>
                            <ignorePackaging>true</ignorePackaging>

<contextFile>${project.build.directory}/webapp/META-INF/context.xml</contextFile>

                        </configuration>
                    </execution>
                    <execution>
                        <id>tomcat-shutdown</id>
                        <goals>
                            <goal>shutdown</goal>
                        </goals>
                        <phase>post-integration-test</phase>
                    </execution>
                </executions>
            </plugin>

.
Cédric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Deploying war from dependency with tomcat7-maven-plugin

Posted by Martin Gainty <mg...@hotmail.com>.
 Oliver wrote this plugin so I will reference his doc 



> From: gregory.amerson@liferay.com
> Date: Mon, 9 Sep 2013 11:18:50 +0800
> Subject: Deploying war from dependency with tomcat7-maven-plugin
> To: users@tomcat.apache.org
> 
> Hello all,
> 
> I'm trying to use the tomcat7-maven-plugin, specifically running the *mvn
> tomcat7:run* command.
MG>
<project>
  <packaging>war</packaging>
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0-beta-1</version>
        <executions>
          <execution>
            <id>tomcat-run</id>
            <goals>
              <goal>exec-war-only</goal>
            </goals>
            <phase>package</phase>
            <configuration>

     <!-- assume ROOT --->

               <path>/</path>
       <!-- extra dependencies to add jdbc driver mail jars -->
              <extraDependencies>
                <extraDependency>

> However, in my case I have two requirements that are different than the
> documentation provides for and I'm wondering if it is possible with the
> current tomcat7-maven-plugin.
> 
> 1. need to deploy several jars to the global tomcat classpath (i.e. same as
> copying them into <tomcat.home>/lib/ext/ folder in a standalone install).

MG>COPY RESOURCES


MG>http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
MG>as with tomcat7-maven-plugin bind to package phase

> 2. need to deploy a war to the ROOT context
MG>see ROOT above
 >but instead of packaging the current project from source, I just need to point to an existing WAR as a dependency.
MG>maven dependency implies required sub-artifact of current artifact you are processing
MG>can i assume you want to replace an 'already deployed war'?
MG>then you will want mvn package tomcat7:redeploy
MG>http://tomcat.apache.org/maven-plugin-2.0-beta-1/context-goals.html#aRedeploying_a_WAR_project
> 
> So in my project there will be no webapp source. I simply want to run a
> tomcat with some extra jars in /lib/ext/ directory
MG>see COPY RESOURCES above
 
> and also deploy a war
> that is obtained via a <dependency> with war type instead of packaged from
> source
MG><packaging>war</packaging>
MG>http://tomcat.apache.org/maven-plugin-2.0-beta-1/executable-war-jar.html
> 
> Thanks in advance for any help!
> 
> -- 
> Greg Amerson
> Liferay Developer Tools
> Liferay, Inc. www.liferay.com

MG>Oliver please check accuracy