2

In production I have setup an external folder to upload and display images from by editing server.xml:

<Service name="Catalina">

   <Connector port="80" protocol="HTTP/1.1"
             connectionTimeout="20000"
             URIEncoding="UTF-8"
             redirectPort="443" />

   <Engine name="Catalina" defaultHost="localhost">

     <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
        resourceName="UserDatabase"/>

     <Host name="localhost"  appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

       <Context docBase="/opt/winmail_storage/imgs" path="/imgs"/>

     </Host>
   </Engine>
 </Service>

I am trying to do the same thing in development by editing _Events.groovy :

eventConfigureTomcat = {tomcat ->
       def ctx = tomcat.addContext("/imgs" , "/tmp/images")
}

I also tried

eventConfigureTomcat = {tomcat ->
       def ctx = tomcat.addContext("/appName/imgs" , "/tmp/images")
}

this is not working, the imgs directory is not accessible via : http://host/appName/imgs any idea how I can do this correctly?

oberfreak
  • 1,799
  • 13
  • 20
Jason
  • 406
  • 1
  • 5
  • 16

1 Answers1

4

finally got it thanks to the grails mailing list:

eventConfigureTomcat = {tomcat ->

def context = tomcat.addWebapp('/acrm/imgs' , '/tmp/images')
def loader = new WebappLoader(tomcat.class.classLoader)
loader.addRepository(new File('/home/mohadib/workspace/acrm/lib').toURI().toURL().toString())
loader.container = context
context.loader = loader
}
Jason
  • 406
  • 1
  • 5
  • 16