This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to deploy the web-app without appbase attribute using embedded tomcat 8 ?

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set the following attribute  for embedded tomcat 8

this.embedded = new TomcatImpl();
((StandardHost) this.embedded.getHost()).setUnpackWARs(true);   If  I set the value to true
//this.embedded.getHost().setAppBase(getPath());              I did not set this value as I have to deploy using context docbase attribue

Context rootContext = this.embedded.addWebapp("", getPath() + dirchar + "ROOT");

Context appContext = this.embedded.addWebapp("M", getPath() + dirchar + "ROOT");

After setting the above attribute i  deploy the war as

               Context context = this.embedded.addWebapp(this.embedded.getHost(), contextPath, absolutePath);

Everything works fine but i got the below error message

Exception fixing docBase for context [/service] Unable to create the directory
at org.apache.catalina.startup.ExpandWar.expand(
at org.apache.catalina.startup.ContextConfig.fixDocBase(
at org.apache.catalina.startup.ContextConfig.beforeStart(
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(
at org.apache.catalina.util.LifecycleBase.setStateInternal(
at org.apache.catalina.util.LifecycleBase.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase. (

to remove this error

I set the  below value

b]((StandardHost) this.embedded.getHost()).setUnpackWARs(false)[/b];   If I change the value false from true

I did not get any error

but migration guide of tomcat says that

says that we should not set this value as  false due to security reason

Please suggest me best approach for tomcat 8 for context docbase deployment without this error

Saloon Keeper
Posts: 21127
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Security is not the main issue when determining whether to unpack WARs or not. If you properly secure your system, I doubt it will even make a difference. On the other hand, the latest javadocs indicate that allowing Tomcat to unpack a WAR can result in significant speedup in deployment. Whether you find that important depends on your work environments and viewpoint. I've never felt it to be a problem.

If you do decide to unpack WARs, however, you need to tell Tomcat where to unpack the WARs to. That is, you must have a destination directory similar to the TOMCAT_HOME/webapps directory that will serve as the parent directory for the unzipped WAR files.

Your problem is that you're telling Tomcat to unzip into a directory that does not exist - /var/opt/mediation/MMStorage/Online/etc/tomcat/webapps/webapps/service - and since you don't show how the variable absolutePath is being set, it's hard to tell exactly what you did wrong in creating that name.

So much for your actual problem. Here's some info that you might find useful.

First, on Unix/Linux depoyment, the directory path /var/opt/mediation is a bit wonky. Typically you'd either use /opt/mediation (or something like /opt/com/mousetech/mediation is what I use, since I'm OR you'd use /var/lib/mediation. You have an odd combination of both. Not exactly wrong, just weird since it conforms to none of the accepted usages.

The other thing has to do with filesystem paths and context paths. Instead of:

Context rootContext = this.embedded.addWebapp("", getPath() + dirchar + "ROOT");

you might prefer this:

Why you're deploying 2 different instances of the same webapp I don't know, but that's your business. Do note that a webapp context path should be absolute, so simply deploying under "" and "M" shouldn't work. If it does, well OK. But it's not how the convention works elsewhere.
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!