Reputation: 370
I want to map external directory as resource to application deployed on tomcat 7.
I have already gone through thread here and tried several approaches:
I added _Events.groovy and it works perfectly fine on my dev machine(windows 7), but when I deploy same on production server, it doesn't map external folder to the context root.
import org.apache.catalina.*
import org.apache.catalina.connector.*
import org.apache.catalina.loader.WebappLoader
eventConfigureTomcat = {tomcat ->
println "changing tomcat setting..."
String imageDir = '/usr/imgs';
if (System.properties['os.name']?.toLowerCase()?.contains('windows')) {
imageDir = 'c:/usr/imgs';
}
println "product image dir:"+imageDir;
def context = tomcat?.addWebapp('/imgs' , imageDir)
def loader = new WebappLoader(tomcat.class.classLoader)
loader.addRepository(new File(imageDir).toURI().toURL().toString())
loader.container = context
context.loader = loader
}
My context root name is rie, and I tried adding the following context in Server.xml, even this did not work for me.
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
.
.
.
<Context path="/rie" docBase="/usr/imgs" reloadable="true" crossContext="true" />
<Context path="" docBase="/usr/imgs" reloadable="true" crossContext="true" />
.
.
.
</Host>
Tried alises as well as its available with tomcat 7, that too didn't work.
I am trying this out since from 2 days, referred all the thread and tutorials but its not working.,
Am I doing something wrong?
Upvotes: 0
Views: 410
Reputation: 443
Do you have the correct rights to this folder for tomcat?
Try to login to the system like su - tomcat
(or whichever other username you have started tomcat under which) and access /usr/imgs
.
Then change that permissions recursively, through chmod -R
.
Upvotes: 1