Skip to main content

runtime exception

3 replies [Last post]
sridhery
Offline
Joined: 2007-11-22
Points: 0

I am getting this error in my project I am new to xml kindly any one can help. Thanks in adavance. The crimson.jar is present in my lib folder and classpath

Caused by: java.lang.IllegalArgumentException: No attributes are implemented
at org.apache.crimson.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:93)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joehw
Offline
Joined: 2004-12-15
Points: 0

Are you involved in old projects that used Crimson parser or are you just trying some xml samples (since you mentioned you're new to xml)? I would suggest using the current JAXP or the latest jdk which includes jaxp 1.4 if you're just trying to get started with xml. JAXP has replaced the Crimson parser since version 1.3. Refer to the 1.3 release notes https://jaxp.dev.java.net/1.3/ReleaseNotes.html.

sridhery
Offline
Joined: 2007-11-22
Points: 0

I am never involved in old project that used Crimson parser and i am not just trying some xml sample. Iam working in an existing project. I am using jdk 1.5 . The following is the program please check it.

package com.gracenote.sonybmg;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class XPathQuery {

private static final DocumentBuilderFactory dbfact = DocumentBuilderFactory.newInstance();

static {
dbfact.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
}

public static final String SONY_TRACK_PARENT_XPATH = "/Catalog/Action/Product/Track/MetaData/PhysicalProduct/ReferenceID";
public static final String SONY_MEDIA_CODE_XPATH = "/Catalog/Action/Product/MetaData/PhysicalProduct/ProductID";
public static final String SONY_MEDIA_CODE_XPATH_ALT = "/Catalog/Action/Product/Track/MetaData/PhysicalProduct/ProductID";

public static String getParentIdFromTrackXml(SonyFile nextTrackFile)
throws ParserConfigurationException, FileNotFoundException, SAXException, IOException, XPathExpressionException {

DocumentBuilder builder = dbfact.newDocumentBuilder();
InputSource ins = nextTrackFile.getInputSource();
org.w3c.dom.Document doc = builder.parse(ins);

XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String parentId = xpath.evaluate(SONY_TRACK_PARENT_XPATH, doc);
return parentId;
}

public static String getCustomerMediaCode(SonyFile album)
throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {

String parentId = null;
try{

DocumentBuilder builder = dbfact.newDocumentBuilder();
InputSource ins = album.getInputSource();
org.w3c.dom.Document doc = builder.parse(ins);

XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
parentId= xpath.evaluate(SONY_MEDIA_CODE_XPATH, doc);

if(parentId==null)
parentId= xpath.evaluate(SONY_MEDIA_CODE_XPATH_ALT, doc);

}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
throw new XPathExpressionException(e.toString());
}
return parentId;

}
}

joehw
Offline
Joined: 2004-12-15
Points: 0

In that case, you may want to try again without Crimson, e.g. removing it from your path and lib. JDK 1.5 includes jaxp 1.3 which uses Apatch Xerces parsers. If it still doesn't work, please make a runable test (please remove any sensitive content). Thanks.