• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

problem on loading a XML file using Class.class.getResourceAsStream method

I'm trying to create an InputStream for reading data from a XML file using the following statement :
InputStream in = Class.class.getResourceAsStream(XML_FILE);
This is being done within a static synchronized method.

I am getting the following exception message :-

[19/04/04 14:12:04:391 BST] 6f9fd8e7 WebGroup      E SRVE0026E: [Servlet Error]-[Generic Application Error: RemoteException occurred in server thread&#59; nested exception is:
      java.rmi.RemoteException: &#59; nested exception is:
      java.lang.ExceptionInInitializerError]: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.RemoteException: ; nested exception is:
      java.lang.ExceptionInInitializerError
java.rmi.RemoteException: ; nested exception is:
      java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError: java.lang.IllegalArgumentException: InputStream cannot be null
rethrown as test.intranet.exception.ApplicationError: Generic Application Error: RemoteException occurred in server thread; nested exception is:
      java.rmi.RemoteException: ; nested exception is:
      java.lang.ExceptionInInitializerError

I have used the this.getClass().getResourceAsStream(XML_FILE) statement within another class (not in a static method) and this worked fine.  

I wonder if anyone could shed light on my problem ?
0
papillon2
Asked:
papillon2
  • 3
1 Solution
 
CEHJCommented:
You don't want the Class class. You want the main class class, i.e. getClass().getResourceAsStream
0
 
CEHJCommented:
i.e. if your main class is called 'X' then you need

X.class.getResourceAsStream
0
 
CEHJCommented:
8-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now