• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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]
java.io.IOException: Unable to create the directory
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:115)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:619)
at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:752)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:308)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:144)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase. (ContainerBase.java:701)

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

Posts: 20832
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 mousetech.com). 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!