You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Cartwright - NOAA Federal <jo...@noaa.gov> on 2014/01/21 06:26:11 UTC
running packed WAR files with embedded tomcat
Hello All,
I'm trying to create a very basic embeded tomcat 7 application to host a
packed WAR file. My code looks like:
Tomcat tomcat = new Tomcat()
tomcat.setPort(port)
tomcat.setBaseDir(".")
tomcat.addWebapp(pathToWarFile, contextName)
It seems to work, but I'm getting an exception on startup complaining about
the missing webapps directory:
SEVERE: Exception fixing docBase for context [/quickstart]
java.io.IOException: Application base [{1}] for host
[/private/tmp/./webapps] does not exist or is not a directory.
Can someone please direct me to a better way to do this? Is
Tomcat#addWebapp not appropriate if hosting a packed WAR file?
Thanks!
--john
Re: running packed WAR files with embedded tomcat
Posted by Valery Shyshkin <vn...@gmail.com>.
Tomcat 7 embedded doesn't need a war file to be unpacked. I have a Spring
based application packaged in war and it works.
Do you really use Tomcat embedded jars on the classpath or may be from
Tomcat installation?
2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
> Thanks for the example Valery. Even with your approach, I'm finding that
> unless I create a directory "webapps" in the directory from which I run the
> program, I get this exception:
>
> java.io.IOException: Application base [{1}] for host [/tmp/./webapps] does
> not exist or is not a directory.
>
> It seems to me that the WAR is still needing to be unpacked prior to
> running.
>
> --john
>
>
>
> On Wed, Jan 22, 2014 at 12:16 AM, Valery Shyshkin <vns.shyshkin@gmail.com
> >wrote:
>
> > The code below works fine on my Win 7 PC
> >
> > final Tomcat tomcat = new Tomcat();
> > tomcat.setPort(9191);
> > //File baseDir = new File(System.getProperty("java.io.tmpdir"));
> > File baseDir = new File(".");
> > tomcat.addContext("", baseDir.getAbsolutePath());
> > tomcat.addWebapp("/WebApplication2",
> >
> "D:\\VnsTestApps\\Nb74Jetty\\WebApplication2\\dist\\WebApplication2.war");
> >
> > tomcat.start();
> > tomcat.getServer().await();
> >
> >
> >
> > 2014/1/22 Valery Shyshkin <vn...@gmail.com>
> >
> > > By the way it's not a suggestion it's a signature of the addWebApp
> > > method.
> > > I'll try to find my working code and send it.
> > >
> > >
> > > 2014/1/22 Valery Shyshkin <vn...@gmail.com>
> > >
> > >> Try:
> > >>
> > >> File baseDir = new File(System.getProperty("java.io.tmpdir"));
> > >> tomcat.addContext("", baseDir.getAbsolutePath());
> > >>
> > >>
> > >>
> > >>
> > >> 2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
> > >>
> > >>> Thanks for the suggestion Valery, but swapping the arguments doesn't
> > >>> work.
> > >>>
> > >>> --john
> > >>>
> > >>>
> > >>>
> > >>> On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <
> > vns.shyshkin@gmail.com
> > >>> >wrote:
> > >>>
> > >>> > May be tomcat.addWebapp(contextName,pathToWarFile) instead of
> > >>> > tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
> > >>> >
> > >>> >
> > >>> > 2014/1/21 John Cartwright - NOAA Federal <
> john.c.cartwright@noaa.gov
> > >
> > >>> >
> > >>> > > Hello All,
> > >>> > >
> > >>> > > I'm trying to create a very basic embeded tomcat 7 application to
> > >>> host a
> > >>> > > packed WAR file. My code looks like:
> > >>> > >
> > >>> > > Tomcat tomcat = new Tomcat()
> > >>> > > tomcat.setPort(port)
> > >>> > > tomcat.setBaseDir(".")
> > >>> > > tomcat.addWebapp(pathToWarFile, contextName)
> > >>> > >
> > >>> > > It seems to work, but I'm getting an exception on startup
> > complaining
> > >>> > about
> > >>> > > the missing webapps directory:
> > >>> > >
> > >>> > > SEVERE: Exception fixing docBase for context [/quickstart]
> > >>> > > java.io.IOException: Application base [{1}] for host
> > >>> > > [/private/tmp/./webapps] does not exist or is not a directory.
> > >>> > >
> > >>> > > Can someone please direct me to a better way to do this? Is
> > >>> > > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
> > >>> > >
> > >>> > > Thanks!
> > >>> > >
> > >>> > > --john
> > >>> > >
> > >>> >
> > >>>
> > >>
> > >>
> > >
> >
>
Re: running packed WAR files with embedded tomcat
Posted by John Cartwright - NOAA Federal <jo...@noaa.gov>.
Thanks for the example Valery. Even with your approach, I'm finding that
unless I create a directory "webapps" in the directory from which I run the
program, I get this exception:
java.io.IOException: Application base [{1}] for host [/tmp/./webapps] does
not exist or is not a directory.
It seems to me that the WAR is still needing to be unpacked prior to
running.
--john
On Wed, Jan 22, 2014 at 12:16 AM, Valery Shyshkin <vn...@gmail.com>wrote:
> The code below works fine on my Win 7 PC
>
> final Tomcat tomcat = new Tomcat();
> tomcat.setPort(9191);
> //File baseDir = new File(System.getProperty("java.io.tmpdir"));
> File baseDir = new File(".");
> tomcat.addContext("", baseDir.getAbsolutePath());
> tomcat.addWebapp("/WebApplication2",
> "D:\\VnsTestApps\\Nb74Jetty\\WebApplication2\\dist\\WebApplication2.war");
>
> tomcat.start();
> tomcat.getServer().await();
>
>
>
> 2014/1/22 Valery Shyshkin <vn...@gmail.com>
>
> > By the way it's not a suggestion it's a signature of the addWebApp
> > method.
> > I'll try to find my working code and send it.
> >
> >
> > 2014/1/22 Valery Shyshkin <vn...@gmail.com>
> >
> >> Try:
> >>
> >> File baseDir = new File(System.getProperty("java.io.tmpdir"));
> >> tomcat.addContext("", baseDir.getAbsolutePath());
> >>
> >>
> >>
> >>
> >> 2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
> >>
> >>> Thanks for the suggestion Valery, but swapping the arguments doesn't
> >>> work.
> >>>
> >>> --john
> >>>
> >>>
> >>>
> >>> On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <
> vns.shyshkin@gmail.com
> >>> >wrote:
> >>>
> >>> > May be tomcat.addWebapp(contextName,pathToWarFile) instead of
> >>> > tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
> >>> >
> >>> >
> >>> > 2014/1/21 John Cartwright - NOAA Federal <john.c.cartwright@noaa.gov
> >
> >>> >
> >>> > > Hello All,
> >>> > >
> >>> > > I'm trying to create a very basic embeded tomcat 7 application to
> >>> host a
> >>> > > packed WAR file. My code looks like:
> >>> > >
> >>> > > Tomcat tomcat = new Tomcat()
> >>> > > tomcat.setPort(port)
> >>> > > tomcat.setBaseDir(".")
> >>> > > tomcat.addWebapp(pathToWarFile, contextName)
> >>> > >
> >>> > > It seems to work, but I'm getting an exception on startup
> complaining
> >>> > about
> >>> > > the missing webapps directory:
> >>> > >
> >>> > > SEVERE: Exception fixing docBase for context [/quickstart]
> >>> > > java.io.IOException: Application base [{1}] for host
> >>> > > [/private/tmp/./webapps] does not exist or is not a directory.
> >>> > >
> >>> > > Can someone please direct me to a better way to do this? Is
> >>> > > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
> >>> > >
> >>> > > Thanks!
> >>> > >
> >>> > > --john
> >>> > >
> >>> >
> >>>
> >>
> >>
> >
>
Re: running packed WAR files with embedded tomcat
Posted by Valery Shyshkin <vn...@gmail.com>.
The code below works fine on my Win 7 PC
final Tomcat tomcat = new Tomcat();
tomcat.setPort(9191);
//File baseDir = new File(System.getProperty("java.io.tmpdir"));
File baseDir = new File(".");
tomcat.addContext("", baseDir.getAbsolutePath());
tomcat.addWebapp("/WebApplication2",
"D:\\VnsTestApps\\Nb74Jetty\\WebApplication2\\dist\\WebApplication2.war");
tomcat.start();
tomcat.getServer().await();
2014/1/22 Valery Shyshkin <vn...@gmail.com>
> By the way it's not a suggestion it's a signature of the addWebApp
> method.
> I'll try to find my working code and send it.
>
>
> 2014/1/22 Valery Shyshkin <vn...@gmail.com>
>
>> Try:
>>
>> File baseDir = new File(System.getProperty("java.io.tmpdir"));
>> tomcat.addContext("", baseDir.getAbsolutePath());
>>
>>
>>
>>
>> 2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
>>
>>> Thanks for the suggestion Valery, but swapping the arguments doesn't
>>> work.
>>>
>>> --john
>>>
>>>
>>>
>>> On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <vns.shyshkin@gmail.com
>>> >wrote:
>>>
>>> > May be tomcat.addWebapp(contextName,pathToWarFile) instead of
>>> > tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
>>> >
>>> >
>>> > 2014/1/21 John Cartwright - NOAA Federal <jo...@noaa.gov>
>>> >
>>> > > Hello All,
>>> > >
>>> > > I'm trying to create a very basic embeded tomcat 7 application to
>>> host a
>>> > > packed WAR file. My code looks like:
>>> > >
>>> > > Tomcat tomcat = new Tomcat()
>>> > > tomcat.setPort(port)
>>> > > tomcat.setBaseDir(".")
>>> > > tomcat.addWebapp(pathToWarFile, contextName)
>>> > >
>>> > > It seems to work, but I'm getting an exception on startup complaining
>>> > about
>>> > > the missing webapps directory:
>>> > >
>>> > > SEVERE: Exception fixing docBase for context [/quickstart]
>>> > > java.io.IOException: Application base [{1}] for host
>>> > > [/private/tmp/./webapps] does not exist or is not a directory.
>>> > >
>>> > > Can someone please direct me to a better way to do this? Is
>>> > > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
>>> > >
>>> > > Thanks!
>>> > >
>>> > > --john
>>> > >
>>> >
>>>
>>
>>
>
Re: running packed WAR files with embedded tomcat
Posted by Valery Shyshkin <vn...@gmail.com>.
By the way it's not a suggestion it's a signature of the addWebApp method.
I'll try to find my working code and send it.
2014/1/22 Valery Shyshkin <vn...@gmail.com>
> Try:
>
> File baseDir = new File(System.getProperty("java.io.tmpdir"));
> tomcat.addContext("", baseDir.getAbsolutePath());
>
>
>
>
> 2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
>
>> Thanks for the suggestion Valery, but swapping the arguments doesn't work.
>>
>> --john
>>
>>
>>
>> On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <vns.shyshkin@gmail.com
>> >wrote:
>>
>> > May be tomcat.addWebapp(contextName,pathToWarFile) instead of
>> > tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
>> >
>> >
>> > 2014/1/21 John Cartwright - NOAA Federal <jo...@noaa.gov>
>> >
>> > > Hello All,
>> > >
>> > > I'm trying to create a very basic embeded tomcat 7 application to
>> host a
>> > > packed WAR file. My code looks like:
>> > >
>> > > Tomcat tomcat = new Tomcat()
>> > > tomcat.setPort(port)
>> > > tomcat.setBaseDir(".")
>> > > tomcat.addWebapp(pathToWarFile, contextName)
>> > >
>> > > It seems to work, but I'm getting an exception on startup complaining
>> > about
>> > > the missing webapps directory:
>> > >
>> > > SEVERE: Exception fixing docBase for context [/quickstart]
>> > > java.io.IOException: Application base [{1}] for host
>> > > [/private/tmp/./webapps] does not exist or is not a directory.
>> > >
>> > > Can someone please direct me to a better way to do this? Is
>> > > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
>> > >
>> > > Thanks!
>> > >
>> > > --john
>> > >
>> >
>>
>
>
Re: running packed WAR files with embedded tomcat
Posted by Valery Shyshkin <vn...@gmail.com>.
Try:
File baseDir = new File(System.getProperty("java.io.tmpdir"));
tomcat.addContext("", baseDir.getAbsolutePath());
2014/1/22 John Cartwright - NOAA Federal <jo...@noaa.gov>
> Thanks for the suggestion Valery, but swapping the arguments doesn't work.
>
> --john
>
>
>
> On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <vns.shyshkin@gmail.com
> >wrote:
>
> > May be tomcat.addWebapp(contextName,pathToWarFile) instead of
> > tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
> >
> >
> > 2014/1/21 John Cartwright - NOAA Federal <jo...@noaa.gov>
> >
> > > Hello All,
> > >
> > > I'm trying to create a very basic embeded tomcat 7 application to host
> a
> > > packed WAR file. My code looks like:
> > >
> > > Tomcat tomcat = new Tomcat()
> > > tomcat.setPort(port)
> > > tomcat.setBaseDir(".")
> > > tomcat.addWebapp(pathToWarFile, contextName)
> > >
> > > It seems to work, but I'm getting an exception on startup complaining
> > about
> > > the missing webapps directory:
> > >
> > > SEVERE: Exception fixing docBase for context [/quickstart]
> > > java.io.IOException: Application base [{1}] for host
> > > [/private/tmp/./webapps] does not exist or is not a directory.
> > >
> > > Can someone please direct me to a better way to do this? Is
> > > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
> > >
> > > Thanks!
> > >
> > > --john
> > >
> >
>
Re: running packed WAR files with embedded tomcat
Posted by John Cartwright - NOAA Federal <jo...@noaa.gov>.
Thanks for the suggestion Valery, but swapping the arguments doesn't work.
--john
On Tue, Jan 21, 2014 at 8:12 AM, Valery Shyshkin <vn...@gmail.com>wrote:
> May be tomcat.addWebapp(contextName,pathToWarFile) instead of
> tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
>
>
> 2014/1/21 John Cartwright - NOAA Federal <jo...@noaa.gov>
>
> > Hello All,
> >
> > I'm trying to create a very basic embeded tomcat 7 application to host a
> > packed WAR file. My code looks like:
> >
> > Tomcat tomcat = new Tomcat()
> > tomcat.setPort(port)
> > tomcat.setBaseDir(".")
> > tomcat.addWebapp(pathToWarFile, contextName)
> >
> > It seems to work, but I'm getting an exception on startup complaining
> about
> > the missing webapps directory:
> >
> > SEVERE: Exception fixing docBase for context [/quickstart]
> > java.io.IOException: Application base [{1}] for host
> > [/private/tmp/./webapps] does not exist or is not a directory.
> >
> > Can someone please direct me to a better way to do this? Is
> > Tomcat#addWebapp not appropriate if hosting a packed WAR file?
> >
> > Thanks!
> >
> > --john
> >
>
Re: running packed WAR files with embedded tomcat
Posted by Valery Shyshkin <vn...@gmail.com>.
May be tomcat.addWebapp(contextName,pathToWarFile) instead of
tomcat.addWebapp(pathToWarFile, contextName) will help yoo.
2014/1/21 John Cartwright - NOAA Federal <jo...@noaa.gov>
> Hello All,
>
> I'm trying to create a very basic embeded tomcat 7 application to host a
> packed WAR file. My code looks like:
>
> Tomcat tomcat = new Tomcat()
> tomcat.setPort(port)
> tomcat.setBaseDir(".")
> tomcat.addWebapp(pathToWarFile, contextName)
>
> It seems to work, but I'm getting an exception on startup complaining about
> the missing webapps directory:
>
> SEVERE: Exception fixing docBase for context [/quickstart]
> java.io.IOException: Application base [{1}] for host
> [/private/tmp/./webapps] does not exist or is not a directory.
>
> Can someone please direct me to a better way to do this? Is
> Tomcat#addWebapp not appropriate if hosting a packed WAR file?
>
> Thanks!
>
> --john
>