3

I am facing an issue related to file access over HTTP in Wildfly(JBoss). I am running an application on Wildlfy-9.0.1.Final

In my application there is a link on click, it supposed to open respective file and display its content. But when I click on link it gives me 404-Not found error.

I could see that file exist on same path as given in href in anchor tag. I don't understand what it makes to give 404 Error.

Is there any other settings that I need to enabled in Wildfly to access files over HTTP. If so, please advice.

EDIT:

My path in <handlers> looks like this

path="/usr/local/jboss/server/default/deploy/"

This directory structure is not yet complete as there will be more path appended dynamically at run-time using java code where actual file will reside.

For ex: path="/usr/local/jboss/server/default/deploy/demo/1/filename"

of which /usr/local/jboss/server/default/deploy/ is static path and demo/1/filename is dynamic.

Also in /directory-listing-uri in location some path is dynamic generated at tun time.

For ex: Assume below is directory-listing-uri

http://[wildfly host]:[port]/{static}/{dynamic}/{dynamic}/{dynamicFileName}.iif

So I am not sure how wildfly will serve my purpose of displaying files.

Please correct if I am incorrect.

Sevan
  • 669
  • 1
  • 5
  • 18
mahendra kawde
  • 855
  • 4
  • 25
  • 44
  • @Rémi Can you please help me on this? Please have look at my latest edit in question – mahendra kawde Dec 18 '15 at 09:49
  • Hi, in your previous question version, you said that you wanted to create and download files, with "dynamic paths" from directories outside your application. So I've answered to this. Now your question has changed as you want to expose files which are located inside your EAR (Why don't you put these files in a WAR directory packaged within your EAR for this?) I propose you revert your last question changes (as question is really not the same now), put back the previous version I answered, close it (if u think it answers correctly to external folder file listing), and ask a new one. – Rémi Bantos Dec 18 '15 at 10:12
  • And i would add that, to my view, it's not a good thing to create files inside your exploded EAR, you'd better create them in an external location if possible. – Rémi Bantos Dec 18 '15 at 10:17
  • Yes your answer is correct to external folder file listing. I have just reverted changes and will initiate new thread on my current question – mahendra kawde Dec 18 '15 at 10:18
  • @Rémi here is my new thread http://stackoverflow.com/questions/34353346/access-files-from-within-exploded-war-wildlfy – mahendra kawde Dec 18 '15 at 10:24

1 Answers1

7

To expose a directory for file listing (and download), you could add two configuration elements in your standalone.xml configuration (if you run wildfly as standalone server) like this:

<subsystem xmlns="urn:jboss:domain:undertow:2.0">
     ...
     <server name="default-server">
         ...
         <host name="default-host" alias="localhost">
             ...
             <location name="/directory-listing-uri" handler="directory-listing-handler"/>
             ...
         </host>
         ...
     </server>
     ...
     <handlers>
         ...
         <file name="directory-listing-handler" path="/home/example/..." directory-listing="true"/>
     </handlers>
     ...
</subsystem>

Note: For jboss-cli configuration, you can take a look at this answer

You will then get a nice Directory Listing GUI at this location:

http://[wildfly host]:[port]/directory-listing-uri

Community
  • 1
  • 1
Rémi Bantos
  • 1,899
  • 14
  • 27
  • Hey I tried what you mentioned above. But I am still stuck as more of part in my `path` and `directory-listing-uri` is dynamic. So can you please see my edit in the question and advice me on same? Thanks for your time. :) – mahendra kawde Dec 17 '15 at 05:05
  • With directory-listing=true all files and folder created dynamically in this location are available. So I guess you have to provide these dynamic paths from your back-end to your front-end or compute them. – Rémi Bantos Dec 17 '15 at 08:34
  • Hey Remi scenario i explained earlier was wrong. sorry for that. But now thing is I am referring some files from exploded war running in deployments folder and still not able to access files over http. Please see my latest edit. Thanks – mahendra kawde Dec 18 '15 at 09:39
  • I've implemented the above answer and its working fine. So what if I want data from multiple directories. Any suggestions. – Ashutosh Sagar Apr 30 '19 at 04:13