Solved

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

Posted on 2004-04-19
3
617 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
  • 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 255 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
commonTwo  challenge 63 98
Issues installing SSL certificate into Apache Tomcat 3 70
countX 22 70
Java and GPO 11 46
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now