1

I get a FileNotFoundException when trying to access a file from an object contained in a servlet. The file is in the WEB-INF/classes directory. The war file has been deployed to JBOSS 6.3.

I have tried various ways to access the file:

1) InputStream path = new FileInputStream();

2) ClassLoader cLoader = this.getClass().getClassLoader(); InputStream path = cLoader.getResourceAsStream();

Do I need to list the filename or class names in any of the JBOSS configuration files?

When I run 1) above, I get the FileNotFoundException.

When I run 2) above, I get a ClassNotFoundException. From the servlet I can find the class, but not from the class itself.

Thanks for any help you can give.

1 Answers1

-1

I would start by checking where your default path is pointing to using the ServletContext object.

String realContextPath = getServletContext().getRealPath("");
System.out.println("REAL CONTEXT PATH: " + realContextPath);

Then make sure your path that your constructing is actually the correct path, my setup already includes the /WEB-INF directory.

File file = new File(realContextPath+"/js/login.js");
xer21
  • 284
  • 1
  • 11