Errors reading directory on JBoss 5 due to vfszip protocol

1.2k Views Asked by At

I need to parse a number of files in my web application.

The files are sitting in a directory (called "edms") at the top level of my .war file. When I try to get a handle on the directory for processing I get errors as the resource returned is of vfszip protocol type.

For example, when I use MyClass.class.getResource("/edms") I get back something like "vfszip:C:/jboss/server/default/deploy/MyWar.war/edms".

If I then use this URL with File objects it fails as it cannot find the underlying directory and the files it contains.

I've looked at using the Spring ResourceUtils class but can't seem to get them to give me what I was which is to be able to :-

  1. Get a handle on the directory (within my .war file)
  2. Loop round each file in the directory - reading and parsing it's contents

Any ideas?

Thanks

Sarah

2

There are 2 best solutions below

0
On

There are a few possible solution to this:

  • for one thing, upgrade to Spring 3+ should automatically solve this issue (use Spring 3.0.3+ for JBoss AS6 or higher;
  • If you are stuck with Spring 2.5, then you can use Snowdrop (http://www.jboss.org/snowdrop), and more specifically the VfsXmlWebApplicationContext (read this for details.

Hope this helps, Marius

2
On

As a hack, what happens if you just substring the protocol part of what MyClass.class.getResource("/edms") returns away, and use the rest of it in a new File(...) statement?