Thinking about this problem a little further, how about trying to use a slightly different technique to get at the file?
Rather than use the getResourceAsStream() method directly how about trying the following; Firstly, call the getResource() method on the ClassLoader (or even use the static ClassLoader.getSystemResource() method). This (well, both) will return a URL object that encapsulates information about - in this case - the Excel workbook. With this object in hand, you have a number of options. The most obvious is to call the URL object's openStream() method which should open a InputStream onto the file which could be wrapped into a FileInputStream and then passed to the constructor. The other alternative would be to assemble the complete path to the file by calling the necessary methods on the URL object again; getFile(), getPath(), etc. This should allow you to create a String that encapsulates the path to and the name of the Excel workbook and which you could then use to create an InputStream connected to the file. Finally, you could always use the String constructed above to instantaite a URI and then progress as you have done below. Might be worth looking into just to see if either approach resolves the problem you are facing; that could allow you to progress the application. Yours Mark B anjsag wrote: > > The excel file is a normal excel created in MS office 2007. The error is > caused when read using > inputStream = ClassPathResource.class.getResourceAsStream(filePath); In > this case the file is located in classpath. > > But if I give an absolute path to the file and try reading like this, > java.net.URI uri = new URI(filePath); > File file = new File(uri); > inputStream = new FileInputStream(file); In this case I don't get any > exception. > > The wonderign part is that it works with a tomcat & fails in one jboss > server. > Can I know When is this particular error supposed to be thrown... > > > > MSB wrote: >> >> Have you tried to open the file directly - creating a simplt >> FileInputStream attached directly to the file for example - to see >> whether POI responds in the same way or if it opens the file? What is the >> source of the file - was it generated by Excel or some other piece of >> software? >> > > -- View this message in context: http://old.nabble.com/exception-when-inputstream-is-read-from-getClass%28%29.getClassLoader%28%29.getResourceAsStream%28%22file.xls%22%29-tp26406348p29170106.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org