?
Solved

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

Posted on 2004-04-19
3
Medium Priority
?
663 Views
Last Modified: 2012-08-14
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
Comment
Question by:papillon2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10859695
You don't want the Class class. You want the main class class, i.e. getClass().getResourceAsStream
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 765 total points
ID: 10859706
i.e. if your main class is called 'X' then you need

X.class.getResourceAsStream
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10860182
8-)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question