Search code examples
xmlrestglassfish

Accessing file outside of Glassfish


I've created an xml file using a REST web service (which isn't located in glassfish) and I then need a php file located within quercus inside of glassfish to be able to access this file to modify it. However I can't copy the file into glassfish because it's protected and I can't seem to access any files outside of glassfish from within.

There's a lot of talk about using alternate document roots (eg. this answer or this document) but I can't find how to implement this. They all say to find either a sun-web.xml file or glassfish-web.xml file and edit that but I have neither of those in my glassfish server. I've also tried doing it through the web interface like this website but that doesnt' work either.

Does anyone else know what I could try?


Solution

  • The glassfish-web.xml (previously known as sun-web.xml) should be placed into WEB-INF/glassfish-web.xml of your web-application's .war file. That is why you can't locate it when browsing the server directories.

    Configuring alternate docroots enables your application to serve files from other locations.

    Ill add an example of the file just in case, but this part you probably already know

    <glassfish-web-app ...>
        ...
        <property name="alternatedocroot_1" value="from=/my.jpg dir=/srv/images/jpg"/>
        <property name="alternatedocroot_2" value="from=*.jpg dir=/srv/images/jpg"/>
        <property name="alternatedocroot_3" value="from=/jpg/* dir=/src/images"/>
    </glassfish-web-app>
    

    Look into the extended doc: http://docs.oracle.com/cd/E18930_01/html/821-2418/beaft.html#geqpl