• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

An exception in java-XML --kindly clarify-urgent

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have built a project in JBuilder. I am using XML4j.jar for parsing xml. As soon as I receive a xml as input, I get the following exception. But there is no error in parsing the xml. Everything works fine. I don't see any "com.ibm.xml.internal.msg.Message" class in the jar file.
Can't find resource for base name com.ibm.xml.internal.msg.Message, locale en_US
at com.ibm.xml.framework.XMLParser.parse(XMLParser.java)
at com.ibm.xml.parsers.NonValidatingDOMParser.parse(NonValidatingDOMParser.java)
Can anyone help me explain why i get this exception. It is urgent.
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you post your XML file,i don't think so one would be able to help you much. By the way you could use xerces(originally XML4J of IBM, IBM had donated this to APACHE.) from apache. It nearly confines to the XML standards.
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardon me for raining the parade.
Your name "madhava g" does not comply with the JavaRanch naming policy. Please spare a moment and re-register with a name that meets the requirements. We will take care of deleting your current login.
Please note that without a name that complies with the Javaranch naming policy, you will not qualify for any giveaways. So I guess changing it is worth the trouble
aarthy kasi
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing the code where I get the exception. The exception occurs in makeDatGroup(). I have given a "e.printStacktrace" in the catch block of makeDataGroup(). To be more exact I think the error comes when we execute the "parser.parse(insource);" statement of the above said method.
import java.io.*;
import com.ibm.xml.parser.*;
import org.w3c.dom.*;
import org.xml.sax.InputSource; // Required by DOM Parser
import com.ibm.xml.parsers.DOMParser;
import com.ibm.xml.parsers.NonValidatingDOMParser; // XML DOM Parser
/** class XMLDataGroupFactory
* @see makeDataGroup(String buffer)
* @see putLine(String line)
* @see makeDataGroup()
* @since JDK 1.3
public class XMLDataGroupFactory {
public XMLDataGroupFactory() {
buffer=new StringBuffer(200);
/** Add some information to the current buffer */
public boolean putLine(String line) {
// If we don't know the doc name yet, establish the name
if (docName==null && line!=null && line.length()>2) {
// Use a newline so we can see breaks in the source data for multi-line fields
// and also so we can return the line number for errors
/** Checks if this is the end of the document for an XML block and
if so it returns true. */
String trimmedline = line.trim();
return ( trimmedline.equals("</") | | trimmedline.equals(endOfDocName) );
/** Erase the current buffer and start over. Clears the last error. */
public void reset() {
/** Set the buffer directly, then parse the XML document in the buffer, and generate either
a DataGroup or an exception.
public DataGroup makeDataGroup(String buffer) throws Exception {
return makeDataGroup();

/** Parse the XML document in the buffer, and generate either a DataGroup or an exception. */
public DataGroup makeDataGroup() throws Exception {
// Copy off the data and clear the buffer we're in a clean state if we get an exception
String xmlData=new String(buffer);
// New IBM XML Parser from here ....
DOMParser parser = new DOMParser();
StringReader xmlSR = new StringReader(xmlData);
try {
InputSource insource = new InputSource(xmlSR); // Set input source to the StringReader
parser.parse(insource); // Parse it
catch (Exception e) {
Document doc = null;
doc = parser.getDocument(); // Results are a document
// .... to here New IBM XML Parser
xmlSR.close(); // Note that this could throw an IOException
if (doc==null | | doc.getDocumentElement()==null) {
String errorInfo;
if (status==null)
errorInfo=" "+status.getValue("message");
throw new Exception("Invalid XML document");
return parseNode(doc.getDocumentElement());
// Parse a node, and produce a dataGroup to represent that node
// old private static DataGroup parseNode(Node parentNode) {
private static DataGroup parseNode(Node node) {
// New IBM XML Parser here ....
DataGroup datagroup = new DataGroup(node.getNodeName());
NodeList children = node.getChildNodes();
if (children != null) {
int len = children.getLength();
for (int i = 0; i < len; i++) { // loop thru all children
if ( children.item(i).getNodeType() == Node.ELEMENT_NODE ) {
if (hasElementChildren(children.item(i))==true) { // if has children
datagroup.addDataGroup(parseNode(children.item(i))); // parse the child into a datagroup
else {
if ( children.item(i).hasChildNodes() == true ) { // Make sure there is data for this tag
// The above is with the assumption that the last child is a text node.
// If dante ever starts accepting other node types ( like comments ). This will have to be
// restructered
return datagroup;
// .... to here New IBM XML Parser
// Any node that has text will return true for hasChildren. This method tells you
// whether a node has any Element children.
private static boolean hasElementChildren(Node node) {
boolean hasChildren=false;
for (Node n = node.getFirstChild(); n != null; n = n.getNextSibling()) {
int type=n.getNodeType();
if (type==node.ELEMENT_NODE) { // Skip the text elements
return hasChildren;

public DataGroup makeDataGroup(BufferedReader in) throws Exception {
String line;
boolean beginTagFound = false;
String beginTag = null;
while (true) {
line = null;
if (line == null)
if (beginTagFound == false)
return null;
if( !beginTagFound ) {
int index = line.indexOf('<');
if( index != -1 ) {
int endIndex = line.indexOf('>',index);
if( endIndex != -1 && endIndex>index+1 ) {
beginTag = line.substring(index+1, endIndex);
beginTagFound = true;
//if (line.startsWith("</")) break;
if (line.equals("</") | | line.indexOf("</"+beginTag+">") != -1)
return makeDataGroup();
/** Returns information about the last parsing error.
Returns null if there is no last error to report.
Note that the reset() method clears the last error. */
public DataGroup getLastError() {
return status;
private void setLastError(DataGroup err) {
// Inner class for error handling
class ErrorHandler implements ErrorListener {
public ErrorHandler(XMLDataGroupFactory parent) {
public int error(String fileName, int lineNo, int charOffset, Object key, String msg) {
DataGroup err=new DataGroup("ParserError");
//Don't return line-- it always will be one because of the way we concatenate
//everything into a single line
return 1;
private XMLDataGroupFactory parent;
} // ErrorHandler inner class
private String endOfDocName=null;
private String docName=null;
private DataGroup status;
private StringBuffer buffer;

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!