Xerces SAX parser don`t initialize a characters array
Xerces SAX parser don`t initialize a characters array from characters() method in DefaultHandler.
I use jdk 1.5.12.
For value "22-11-2009" variables start=1991, length=9.
Result: "22-11-200"
My handler:
package com.epam.xmltask.parsers;
import com.epam.xmltask.model.Category;
import com.epam.xmltask.model.Goods;
import com.epam.xmltask.model.Products;
import com.epam.xmltask.model.Subcategory;
import com.epam.xmltask.utils.Constants;
import com.epam.xmltask.utils.DateConverter;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
public class SAXProductsParser extends DefaultHandler implements IProductsParser {
private Logger logger = null;
private SAXParser parser = null;
private ErrorHandler errorHandler = null;
private Products products = null;
private Category category = null;
private Subcategory subcategory = null;
private Goods goods = null;
private String currentField = Constants.EMPTY_STRING;
protected Logger getLogger() {
if (logger == null) {
logger = Logger.getLogger(SAXProductsParser.class.getName());
return logger;
protected SAXParser getParser() throws Exception {
if (parser == null) {
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
parserFactory.setValidating(true);
parser = parserFactory.newSAXParser();
parser.setProperty(Constants.SCHEMA_LANGUAGE, Constants.XML_SCHEMA);
} catch (Exception ex) {
getLogger().log(Level.SEVERE, null, ex);
throw ex;
return parser;
public ErrorHandler getErrorHandler() {
if (errorHandler == null) {
errorHandler = new ProductsErrorHandler();
return errorHandler;
public Products getProducts(String uri) throws Exception {
try {
products = new Products();
getParser().parse(uri, this);
return products;
} catch (Exception ex) {
getLogger().log(Level.SEVERE, null, ex);
throw ex;
@Override
public void startElement(String uri, String localName,
String qName, Attributes attributes) {
if (Constants.CATEGORY.equals(qName)) {
String name = attributes.getValue(Constants.NAME);
category = new Category(name);
} else if (Constants.SUBCATEGORY.equals(qName)) {
String name = attributes.getValue(Constants.NAME);
subcategory = new Subcategory(name);
} else if (Constants.GOODS.equals(qName)) {
String name = attributes.getValue(Constants.NAME);
goods = new Goods(name);
} else if (Constants.NOT_IN_STOCK.equals(qName)) {
goods.setIsInStock(false);
} else {
currentField = qName;
@Override
public void endElement(String uri, String localName, String qName) {
if (Constants.CATEGORY.equals(qName)) {
products.addCategory(category);
category = null;
} else if (Constants.SUBCATEGORY.equals(qName)) {
category.addSubcategory(subcategory);
subcategory = null;
} else if (Constants.GOODS.equals(qName)) {
subcategory.addGoods(goods);
goods = null;
} else {
currentField = Constants.EMPTY_STRING;
@Override
public void characters(char[] chars, int start, int length) throws SAXException {
String field = new String(chars, start, length).trim();
if (goods != null) {
if (Constants.PRODUSER.equals(currentField)) {
goods.setProducer(field);
} else if (Constants.MODEL.equals(currentField)) {
goods.setModel(field);
} else if (Constants.DATE_OF_ISSUE.equals(currentField)) {
Date date = null;
try {
date = DateConverter.getConvertedDate(field);
} catch (ParseException ex) {
getLogger().log(Level.SEVERE, null, ex);
throw new SAXException(ex);
goods.setDateOfIssue(date);
} else if (Constants.COLOR.equals(currentField)) {
goods.setColor(field);
} else if (Constants.PRICE.equals(currentField)) {
Float price = Float.valueOf(field);
goods.setPrice(price);
@Override
public void error(SAXParseException ex) throws SAXException {
getErrorHandler().error(ex);
@Override
public void fatalError(SAXParseException ex) throws SAXException {
getErrorHandler().fatalError(ex);
@Override
public void warning(SAXParseException ex) throws SAXException {
getErrorHandler().warning(ex);
}
Similar Messages
-
I'm trying to read a XML file in an EJB using a SAX parser.
I tried the following statement to create the reader
XMLReader xr = XMLReaderFactory.createXMLReader("oracle.xml.parser.v2.SAXParser");
but I obtain the following exception:
java.lang.ClassNotFoundException: oracle.xml.parser.v2.SAXParser
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:118)
The same works correctly from a command line application outside OC4J.
Is there another SAX Parser I can use in OC4J?
Andrea MattioliI'm also seeing the a similar problem trying to get my EJB to parse SAX using the Xerces parser. If I do
XMLReader myReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
and place xerces.jar into $(OC4J_INSTALL_ROOT)\j2ee\home\lib then at runtime I get
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
This is despite the fact that calling Class.forName() on the same class name works fine. Setting the system property org.xml.sax.driver and calling createXMLReader with no parameters results in the same error.
I can force use of the Xerces SAX parser by bypassing the factory and just calling
XMLReader myReader = new org.apache.xerces.parsers.SAXParser();
but that seems a tad hacky and I don't want to hardwire SAX parser implementation choice into my code.
Is this a known bug?
Also which parser is getting used by default in OC4J i.e. if I don't set org.xml.sax.driver and use the no parameters variant of createXMLReader()?
Thanks
Alan -
Characters method in SAX parser
Hi
I have a SAX Parser Appln where in I am trying to run it in English Locale But the xml file contains Arabic Characters.
The method characters looks like this
public void characters(char buf[], int offset, int len) throws SAXException
if (recognisedTopElementStarted && storyStarted && recognisedElementStarted )
buffer.append ( new String(buf,offset,len) ) ;
//buffer.append ( new String(buf,offset,len,"UTF-16") ) ;
In this method I want to convert the char array to byte array so as to specify the encoding for constructing a String object(Arabic characters) with correct encoding as specified in the commented statement.
How to do it so as to get the arabic characters
Thanks
RajHi Raj,
I don't have Arabic support on my machine, so I tried with Greek, which has a significant Unicode code page.
To get a byte array, I did this:
byte[] ba = new String(buf, offset, len).getBytes("utf-16");To double check, I saved the byte array in a file output stream and validated the encoding in XML Spy.
So it works for Greek, let's hope it will work for our friends across the Mediterranean sea ;-)
Regards,
David -
SAX Parser is dropping characters
Hello,
We have noticed that the BEA implementation of the SAX parser appears
to drop characters from the start of an attribute's value.
For example:
<attribute-value>au.com.bonline.bean.SomeClass</attribute-value>
becomes
online.bean.SomeClass
after parsing.
Has anyone seen this behaviour before ?
Previously we were running the application under tomcat and did not have
this issue with the implementation of the SAX parser that comes with
tomcat.
Are there changes we have to make to the way we code against the
SAX parser that we might have missed moving from tomcat to BEA ?
Thankyou,
Brian Gorrie
Programmer/Analyst
B DigitalHi Brian,
I just tried this simple program with the output below; it worked OK
using WLS 8.1
What WLS version and can you provide a test case?
Thanks,
Bruce
C:\stephens\CRs\crXML>type attr.xml
<?foo version="1.0" ?>
<A>
<attribute-value>au.com.bonline.bean.SomeClass</attribute-value>
</A>
C:\stephens\CRs\crXML>java -classpath .;%CLASSPATH% sax attr.xml
Start document
Processing Instruction:
target: foo
data: version="1.0"
Start element: A
Characters: "\n"
Start element: attribute-value
Characters: "au.com.bonline.bean.SomeClass"
End element: attribute-value
Characters: " \n"
End element: A
End document
Brian Gorrie wrote:
>
Hello,
We have noticed that the BEA implementation of the SAX parser appears
to drop characters from the start of an attribute's value.
For example:
<attribute-value>au.com.bonline.bean.SomeClass</attribute-value>
becomes
online.bean.SomeClass
after parsing.
Has anyone seen this behaviour before ?
Previously we were running the application under tomcat and did not have
this issue with the implementation of the SAX parser that comes with
tomcat.
Are there changes we have to make to the way we code against the
SAX parser that we might have missed moving from tomcat to BEA ?
Thankyou,
Brian Gorrie
Programmer/Analyst
B Digital[sax.java] -
Xerces Sax not parsing a Unicode char
My SaxParser (xerces) is failing when parsing, complaining about Unicode: 0x1d.
I am reading from a file (InputSource), and have set the encoding to UTF-8.
Is there any way to not parse data in specified xml elements? Without explicitly escaping the illegal character....
Thanks,
KarenHaving performed some research, I discovered that this is a control character and while it is an acceptable Unicode character, it is not a valid UTF-8 character.
Control characters are in the range U+0000....U+001F, and most of them are written out as '?'. 0x1d(Group Separator), however, is not escaped and therefore Xerces cannot parse it.
I have written a util class that escapes control chars in Unicode.
Thanks. -
Getting characters in a particular xml tag type during Sax parsing.
How do I get the text within a certain XML tag using the parser. I can use the parser which will get me all the text in all the tags, but how do I get the ones I need only.
For example:
<channel id="south-east.bbc1.bbc.co.uk">
<display-name lang="en">BBC1</display-name>
<display-name>1</display-name>
</channel>
<programme start="20040217233500" stop="20040218000500 +0000" channel="south-east.bbc1.bbc.co.uk">
<title lang="en">Film 2004 with Jonathan Ross</title>
</programme>how do I get the text 'Film 2004 with Jonathan Ross' without getting the others?Well, the SAX parser just gives you the start/end tag
information to a handler, right? So if you just use
the SAX parser to get one item, then you could do it
by running thru the entire XML file to get that item
then get another item. Clearly this isn't the best
way to do it.... The handler should put the data for
the whole document into some data structure, or use
DocumentBuilder to get a Document object. I see. Yes, that is not the way to use SAX. It's kind of an inside out way of doing things. If you using SAX you should know everything that you want before parsing and grab all of them in one fell swoop.
If you want to get an in memory representation, the JDOM package is a whole lot eaiser to use than DOM. -
Why are all the events in the XML SAX parser not activated?
Hi everyone,
I have written a mini server that parses XML files into SQL queries.
Below is a segment of my code;
try {
Class.forName( JDBC_DRIVER );
myConnection = DriverManager.getConnection( DATABASE_URL, "username", "password");
EventXMLParser myEXP = new EventXMLParser(directory, myConnection);
File[] xmlFiles = directory.listFiles();
for (File xmlFile : xmlFiles) {
myEXP.XMLtoDB(xmlFile);
outWriter.println("File:" + xmlFile.getName() + " DONE");
} catch (SQLException e) {
System.err.println("SQLException for establishing connection");
e.printStackTrace();
} catch (ClassNotFoundException e) {
System.err.println("CLASS NOT FOUND EXCEPTION HERE");
e.printStackTrace();
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
finally {
outWriter.println("PARSING COMPLETED");
outWriter.close();
}Where the constructor EventXMLParser constructs the following:
public EventXMLParser(File path, Connection connection) {
super();
try {
this.XMLpath = path;
this.db_connection = connection;
this.xr = XMLReaderFactory.createXMLReader();
this.XMLSAXhandler = new DefaultHandler(); //create a new own handler
this.xr.setContentHandler(XMLSAXhandler);
this.xr.setErrorHandler(XMLSAXhandler);
//System.out.println("DEBUG: db_connection is " + db_connection.toString());
catch (Exception e) {
System.out.println("Constructor Error!");
e.printStackTrace();
}Below are all my helper methods within EventXMLParser.java
public void XMLtoDB(String XMLpath) throws Exception {
try {
//Input
System.out.println("XMLpath is : " + XMLpath);
/*FileReader r = new FileReader(XMLpath); debug
InputSource in = new InputSource(r);
xr.parse(in);
xr.parse(XMLpath);
/* Note that while parsing, the end of each event, </event>
* will trigger sendSQL to execute the query on the database
catch (Exception e) {
throw new Exception("Error with XMLtoDB!! Exception: " + e);
public void sendSQL(Event event, Connection sql_connection) throws SQLException {
//JDBC part
try {
System.err.println("DEBUG sendSQL");
Statement sql_statement = sql_connection.createStatement();
ResultSet resultSet = sql_statement.executeQuery( event.toSQL() );
catch (SQLException e) {
e.printStackTrace();
/* Parsing XML
* From here onwards it's all designed for the SAX Parsing with different event calling methods
public void startDocument() {
System.err.println("Start Document");
public void endDocument() {
System.err.println("End Document");
public void startElement(String uri, String name, String qName, Attributes atts) {
CurrentElement= name;
System.out.println("This is parsing");
public void characters(char ch[], int start, int length) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
StringBuffer sb = new StringBuffer();
for (int i = start; i < start + length; i++)
sb.append(ch);
String content = sb.toString();
if (CurrentElement.equals("eid"))
temp.setEventID( (Integer.valueOf(content)).intValue() ) ;
else if (CurrentElement.equals("sd"))
temp.setShort_description(content);
else if (CurrentElement.equals("ld"))
temp.setLong_description(content);
else if ( (CurrentElement.equals("dt")))
temp.setDate_Time( formatter.parse(content, new ParsePosition(0)) );
else if (CurrentElement.equals("repeat"))
temp.setRepeat_pattern( (Integer.valueOf(content)).intValue() );
else if (CurrentElement.equals("valid"))
temp.setValid_period(content);
else if (CurrentElement.equals("status")) {
temp.setStatus( (Integer.valueOf(content)).intValue() );
else {}
public void endElement(String uri, String name, String qName) {
System.err.println("DEBUG" + temp.toString()); /*debug*/
if (name.equals("event")) {
try {
/*debug*/ temp.setUserID(1);
/*debug*/ System.err.println("DEBUG: " + temp.toString());
sendSQL(temp, db_connection);
//temp = new Event();
catch (SQLException e) {
System.err.println(e);
}//end catch
}//end try
Where event is a public class Event {
//fields
private int userID = 1; // = 1 only applies for testing
private int eventID;
private String short_description;
private String long_description;
private Date date_time = null;
private int repeat_pattern;
private String valid_period;
private int status; //1 for new, 0 for modification and -1 for delete
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//Constructors
//every event requires the following: userID eventID and short_Description
public Event(int uID, int eID, String shortDescrp) {
setUserID(uID);
setEventID(eID);
setShort_description(shortDescrp);
public Event(int uid, int eid, String sd,
String ld, Date d_t, int r_p, String v_p, int s) {
setUserID(uid);
setEventID(eid);
setShort_description(sd);
setLong_description(ld);
setDate_Time(d_t);
setRepeat_pattern(r_p);
setValid_period(v_p);
setStatus(s);
//set
public void setUserID (int x) { this.userID = x ;}
public void setEventID (int x) { this.eventID = x ;}
public void setShort_description (String x) { this.short_description = x ;}
public void setLong_description (String x) { this.long_description = x ;}
public void setDate_Time(Date x) { this.date_time = x ;}
public void setRepeat_pattern (int x) { this.repeat_pattern = x ;}
public void setValid_period (String x) { this.valid_period = x ;}
public void setStatus (int x) { this.status = x; }
//get
public int getUserID() { return this.userID;}
public int getEventID() { return this.eventID;}
public String getShort_description() { return this.short_description;}
public String getLong_description() { return this.long_description;}
public Date getDate_Time() { return this.date_time;}
public int getRepeat_pattern() { return this.repeat_pattern;}
public String getValid_period() { return this.valid_period;}
public int getStatus() { return this.status; }
//Event to SQL statements;
public String toSQL() {
StringBuffer sb = new StringBuffer();
///if ( status == 1) {
sb.append( "INSERT INTO events SET" );
sb.append( " userID = " + userID + ", ");
sb.append( "eventID = " + eventID + ", " );
sb.append( "short_description = " + "\'" + short_description + "\'" + ", "); //String
sb.append( "long_description = " + "\'" + long_description + "\'" + ", "); //String
sb.append( "date_time = " + "\'" + formatter.format(date_time) + "\'" + ", ");
sb.append( "repeat_pattern = " + repeat_pattern + ", " );
sb.append( "valid_period = " + "\'" + valid_period + "\'" ); //String
sb.append( ";");
//} else if ( status == 2) {
System.err.println(sb.toString());
return sb.toString();
} My question is: I have taken my SQL query generated by toSQL() method in events and it worked.
Here is the funny thing:
Everything is correct syntax wise: No complaints what soever
The mysql part works: Tested separately.
So I tend to think that the problem lies within the SAX parser. I have written SAX2 parsers on this machine before and they have worked too. I tried inserting println statements all over startElement endElement etc etc only to find out that the SAX parser did not call any of the methods that I overided!! Why is that so?
Can you guys spot where my SAX parser fails?I see.
I try to correct this problem by removing super();
so right now my code looks like this:
static Event temp = new Event(0, 0, "null", "null", new Date(), 0, "null", 0);
static String CurrentElement = null;
static File XMLpath;
static Connection db_connection;
static XMLReader xr;
static DefaultHandler XMLSAXhandler;
//Constructor, Build the SAX Parser
public EventXMLParser(File path, Connection connection) {
try {
this.XMLpath = path;
this.db_connection = connection;
this.xr = XMLReaderFactory.createXMLReader();
this.XMLSAXhandler = new DefaultHandler(); //create a new own handler
this.xr.setContentHandler(XMLSAXhandler);
this.xr.setErrorHandler(XMLSAXhandler);
//System.out.println("DEBUG: db_connection is " + db_connection.toString());
catch (Exception e) {
System.out.println("Constructor Error!");
e.printStackTrace();
}This time, I created a new instance of default handler() which can be referenced by as the objects's XMLSAXhandler. However, that did not solve the problem, why does the problem still persist?
Right now, there is only one instance of a default handler created. So why does all my parsing event functions still get ignored? -
I am using the sax parser provided by the package javax.xml.parsers to parse an XML file. It works fine as long as I have an XML file which has English characters. When I use it for parsing a file which has Korean characters in it, the parser fails to recognize them.
It used to throw an error "Line too long" on reading the Korean characters. Then I added an XML directive encoding="EUC-KR" and now it reads the file but does not recognize the characters correctly. It reads all the korean characters as question marks ('??').
Any pointers on what can be done to fix this problem.
Thanks,
RahulJHi,
We've got a very similar problem. I'm parsing with SAX and DOM but the MS special characters keep appearing as ? or ??.
If the encoding is not specified in the XML file there are Parser Exceptions. If I set the encoding to "JISAutoDetect", "JIS", "MS932", "Cp1250 to Cp1258" or "ISO8859-1" then there are no exceptions but the stray characters still appear as ?s.
I managed to display the left and the right quotation marks in a servlet by setting the response Content Type to "text/html; charset=Shift_JIS" and the encoding="Cp1252" in the XML file. But I still have problems with the rest of the characters.
What kind of output do you use? Do you display in a web page or you just write to a file?
Thanks,
Ross -
How to get a specific tag value from SAX parser
I am using the SAX method to parse my xml file.
My Question is how to get the returning characters parsed after calling?
esp the value of <body> tag?
Here is my xml file, and i want to get the parsed <body> value after call sax parser.
<?xml version="1.0" encoding="UTF-8"?>
<article>
<content>
<title>floraaaaa</title>
<date>2004-03-19</date>
<body>
Details of an article, and i want to get the article details
</body>
</content>
</article>here is the parser code I am using:
import java.io.*;
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
public class test2 {
public String m_xmlDetail;
public void readDetail(String url) {
System.out.println("Parsing XML File: " + url + "\n\n");
try {
XMLReader parser = new SAXParser();
ContentHandler contentHandler = new MyContentHandler();
parser.setContentHandler(contentHandler);
parser.parse(url);
} //try ends here
catch (IOException e) {
System.out.println("Error reading URI: " + e.getMessage());
} //catch ends here
catch (SAXException e) {
System.out.println("Error in parsing: " + e.getMessage());
} //catch ends here
} //function
}//close class
public class MyContentHandler implements ContentHandler {
private Locator locator;
//public String m_bodyDetail=new String();
public void setDocumentLocator(Locator locator) {
System.out.println(" * setDocumentLocator() called");
this.locator = locator;
public void startDocument() throws SAXException {
System.out.println("Parsing begins...");
public void endDocument() throws SAXException {
System.out.println("...Parsing ends.");
public void processingInstruction(String target, String data)throws SAXException {
System.out.println("PI: Target:" + target + " and Data:" + data);
public void startPrefixMapping(String prefix, String uri) {
System.out.println("Mapping starts for prefix " + prefix + " mapped to URI " + uri);
public void endPrefixMapping(String prefix) {
System.out.println("Mapping ends for prefix " + prefix);
public void startElement(String namespaceURI, String localName,String rawName, Attributes atts)throws SAXException {
System.out.print("startElement: " + localName);
if (!namespaceURI.equals("")) {
System.out.println(" in namespace " + namespaceURI + " (" + rawName + ")");
else {
System.out.println(" has no associated namespace");
for (int i=0; i<atts.getLength(); i++)
System.out.println(" Attribute: " + atts.getLocalName(i) +"=" + atts.getValue(i));
public void endElement(String namespaceURI, String localName, String rawName) throws SAXException {
System.out.println("endElement: " + localName + "\n");
public void characters(char[] ch, int start, int end) throws SAXException {
String s = new String(ch, start, end);
System.out.println("characters: " + s);
public void ignorableWhitespace(char[] ch, int start, int end)throws SAXException {
String s = new String(ch, start, end);
System.out.println("ignorableWhitespace: [" + s + "]");
public void skippedEntity(String name) throws SAXException {
System.out.println("Skipping entity " + name);
} //close class -
Guidance on the issue described below would be appreciated.
Product Oracle Containers for J2EE Product Version 10.0.3
Platform Microsoft Windows
HOW TO OVERRIDE PARSER IN 10.0.3 OAS 10G PREVIEW 2
### Provide the full build number for the OC4J version that you are running: ###
Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer
Preview (build 040227.1923)
### Which type of OC4J installation are you running? ###
standalone OC4J installation (from zip file)
### If this OC4J instance is 'standalone', where was it installed? ###
it's own dedicated ORACLE_HOME
### Provide the exact text and location for any error seen in a log file: ###
java
-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
-Djavax.xml.parsers.TransformerFactory=org.apache.xalan.processor.TransformerFac
toryImpl
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerF
actoryImpl -Dorg.dom4j.verbose=true -DCRN_ROOT=f:\cognos\crn -jar oc4j.jar
04/03/23 10:51:25 Node started with id=68984609063434
04/03/23 10:51:44 log4j:WARN LogFileWatchdog: shutDownHierarchy
04/03/23 10:51:44 log4j:WARN LogIPFControl - Unknown error during initialize
04/03/23 10:51:44 log4j: Setting IPF internal debugging to true
04/03/23 10:51:45 log4j:WARN No appenders could be found for logger
(Audit.RTUsage.CAM.CRP.jcam).
04/03/23 10:51:45 log4j:WARN Please initialize the log4j system properly.
04/03/23 10:51:46 log4j: Log Server Port is: 9362
04/03/23 10:51:46 log4j: Encoding set to: false
04/03/23 10:51:46 log4j: Number of Server Worker Threads is: 10
04/03/23 10:51:46 log4j: Encoding set to: false
04/03/23 10:51:46 log4j: Relative file path set to:
F:/cognos/crn/logs/crnserver.log
04/03/23 10:51:46 log4j: Exception encountered while trying to convert
configuration document into W3C Document.
04/03/23 10:51:46 log4j:ERROR null
04/03/23 10:51:47 Warning: Caught exception attempting to use JAXP to load a
SAX XMLReader
04/03/23 10:51:47 Warning: Exception was: java.lang.ClassCastException
04/03/23 10:51:47 Warning: I will print the stack trace then carry on using the
default SAX parser
04/03/23 10:51:47 java.lang.ClassCastException
04/03/23 10:51:47 at
javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
04/03/23 10:51:47 at
org.dom4j.io.JAXPHelper.createXMLReader(JAXPHelper.java:34)
04/03/23 10:51:47 at
org.dom4j.io.SAXHelper.createXMLReaderViaJAXP(SAXHelper.java:80)
04/03/23 10:51:47 at
org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:49)
04/03/23 10:51:47 at
org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:528)
04/03/23 10:51:47 at
org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:411)
04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:277)
04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:201)
04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:190)
04/03/23 10:51:47 at
com.cognos.cclcfgapi.CCLStartupConfiguration.getConfigDoc
(CCLStartupConfiguration.java:253)
04/03/23 10:51:47 at
com.cognos.cclcfgapi.CCLStartupConfiguration.getStartupConfigurationDocumen
t(CCLStartupConfiguration.java:136)
04/03/23 10:51:47 at
com.cognos.cclcfgapi.CCLStartupConfiguration.getStartupConfigurationDocument
(CCLStartupConfiguration.java:112)
04/03/23 10:51:47 at
com.cognos.cclcfgapi.CCLConfiguration.init(CCLConfiguration.java:209)
04/03/23 10:51:47 at
com.cognos.pogo.config.ConfigurationImpl.reconfigure(ConfigurationImpl.java:43)
04/03/23 10:51:47 at
com.cognos.pogo.services.DispatcherServices.startInititalServices(DispatcherServ
ices.java:394)
04/03/23 10:51:47 at
com.cognos.pogo.transport.PogoServlet$PogoStartup.run(PogoServlet.java:499)
04/03/23 10:51:47 at java.lang.Thread.run(Unknown Source)
04/03/23 10:51:48 Oracle Application Server Containers for J2EE 10g
(10.0.3.0.0) - Developer Preview initialized
### Describe in detail the problem you are having: ###
Trying to override the parser used by our application and getting the error
above in the console. I also have <web-app-class-loader
search-local-classes-first="true" include-war-manifest-class-path="true" />
set in the orion-web.xml for our application.
I've tried various options on the command line, this seems to get the furthest
but our app doesn't start.Thanks, I did try that as well.....
E:\o10g\j2ee\home>java -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dorg.xml.sax.driver=
org.apache.xerces.parsers.SAXParser -Djavax.xml.parsers.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl -Xbootclasspath/a:e:\o10g\dom4j-1.
4\dom4f-1.4\lib\tool\xerces.jar -DCRN_ROOT=f:\cognos\crn -jar oc4j.jar
04/03/25 07:50:28 Node started with id=68984609063434
04/03/25 07:50:35 setting transaction-timeout to:30000
04/03/25 07:50:48 log4j:WARN LogFileWatchdog: shutDownHierarchy
04/03/25 07:50:48 log4j:WARN LogIPFControl - Unknown error during initialize
04/03/25 07:50:48 log4j: Setting IPF internal debugging to true
04/03/25 07:50:49 log4j:WARN No appenders could be found for logger (Audit.RTUsage.CAM.CRP.jcam).
04/03/25 07:50:49 log4j:WARN Please initialize the log4j system properly.
04/03/25 07:50:50 log4j: Log Server Port is: 9362
04/03/25 07:50:50 log4j: Encoding set to: false
04/03/25 07:50:50 log4j: Number of Server Worker Threads is: 10
04/03/25 07:50:50 log4j: Encoding set to: false
04/03/25 07:50:50 log4j: Relative file path set to: F:/cognos/crn/logs/crnserver.log
04/03/25 07:50:50 log4j: Exception encountered while trying to convert configuration document into W3C Document.
04/03/25 07:50:50 log4j:ERROR null
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-7 JVM used memory: 8699568
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-8 JVM used memory: 8837624
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-9 JVM used memory: 8838480
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-10 JVM used memory: 8839536
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-11 JVM used memory: 8840392
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-12 JVM used memory: 8841248
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-13 JVM used memory: 8842304
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-14 JVM used memory: 8843160
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-15 JVM used memory: 8844016
04/03/25 07:50:50 log4j: ***** Thread begin: Thread-16 JVM used memory: 8845072
04/03/25 07:50:51 Warning: Error occurred using JAXP to load a SAXParser. Will use Aelfred instead
04/03/25 07:50:52 Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview initialized -
SAX Parser error when installing Oracle CCG 5.5.1
I am trying to install Oracle CCG on Windows 2008. I already have my PeopleSoft system installed on the same box, running weblogic and jdk1.7.0_03.
After setting the required environment variables, when I run the command "install.bat -f ccg-551-install.apf" from ccg_install folder, I get the following error:
Starting Oracle Installation Engine 1.2.1
Running from working directory C:\CCG\ccg_stage\
ORACLE_HOME is C:\app\Administrator\product\11.2.0\dbhome_1
JAVA_HOME is C:\Program Files\Java\jdk1.7.0_03
LAUNCH_CLASSPATH is C:\app\Administrator\product\11.2.0\dbhome_1\jdbc\lib\classe
s12.jar;C:\CCG\ccg_stage\install.jar;"C:\app\Administrator\product\11.2.0\dbhome
_1\lib";C:\Program Files\Java\jdk1.7.0_03\lib;C:\app\Administrator\product\11.2.
0\dbhome_1\lib;%CLASSPATH%
Oracle CCG Installer -- Version 1.2.1 Build(installer12-Maint-1.2.1.2)
Copyright 2009 Oracle. All rights reserved.
Initializing. Please wait...
FileParser: Parse error occurred: Could not load default SAX parser: org.apache.
xerces.parsers.SAXParser: SAX2 driver class org.apache.xerces.parsers.SAXParser
not found: org.apache.xerces.parsers.SAXParser
Could not load default SAX parser: org.apache.xerces.parsers.SAXParser: SAX2 dri
ver class org.apache.xerces.parsers.SAXParser not found: org.apache.xerces.parse
rs.SAXParser
I have tried downloading xerces.jar file and placed in the CLASSPATH folder but it did not help either. I do not have much knowledge about java and need help from someone who has installed CCG on windows.
Thank you in advanceSeveral things I would recommend here:
1. Use JDK 1.5 instead of 1.7, I'm pretty sure 1.7 isn't supported (Don't ask why) - [http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html|http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html]
2. Make sure to exit out all DOS command windows, then open a new one then go through setting all the environment variables, and using the same DOS command run the install command, otherwise all environment variables will be lost.
I hope that helps. -
Sax parse xml bug , I can't figure it out!
(1) orginal xml file as followings:
<row>
<field name="productBundleId">22456</field>
<field name="localPath">/products/01092008/RealArcade/STD_StonesOfKhufu_NOK6030_EN_v1_0_12.jar</field>
<field name="description">/products/01092008/RealArcade/STD_StonesOfKhufu_NOK6030_EN_v1_0_12.jad</field>
</row>
(2) task parsing the above and and retrieve the value and set it to a javabean:
(3) Using the SAX as the xml file is very big , about 1M
* @author mertef
public class XerseHandlerImp extends DefaultHandler implements MF_CONSTANTS
List m_data = new ArrayList();
private CompareSimpleBean m_csb = null;
private String m_tmpVal = "";
private boolean m_id = false;
private boolean m_jar = false;
private boolean m_jad = false;
private String m_whitespace = "";
private boolean m_character = false;
@Override
public void characters(char[] ch, int start, int length) throws SAXException
* // System.out.println(new String(ch,start,length));*
m_tmpVal = new String(ch, start, length);*
if (jad) System.out.println(tmpVal);*
@Override
public void endElement(String uri, String localName, String name) throws SAXException
m_character = false;
if (name.equals(MOVAYA_ROW))
m_data.add(m_csb);
if (name.equals(MOVAYA_FIELD))
if (m_id)
m_csb.setId(m_tmpVal);
m_id = false;
m_jar = false;
m_jad = false;
else if (m_jar)
m_csb.setJarPath(m_tmpVal);
m_id = false;
m_jar = false;
m_jad = false;
else if (m_jad)
m_csb.setJadPath(m_tmpVal);
m_id = false;
m_jar = false;
m_jad = false;
@Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
m_whitespace = new String(ch, start, length);
(4) please pay attention to the bold area , the method:
character()
I declare a variable "m_character" to decide if the parser don't read content of
an item in above xml file ,such as
/products/01092008/RealArcade/STD_StonesOfKhufu_NOK6030_EN_v1_0_12.jar
(5)error:
but some time it only reads part of the character contents:
eg:
/products/01092008/RealAr
cade/STD_StonesOfKhufu_UnitedStates_LGCU515_EN_v1_0_12.jad
It means that they parser comes across some character when parsing,
but in fact it doesn't.
You can use println() to monitor the outputs.
So I need to declare some boolean variable to decide whether all the content of one item has read fully.
(6)
May be its a bug, my xml file don't include any special charactor.The problem is that the character data might be delivered in multiple chunks, this means that the characters method might be called more than once for the same element.
One way around this is to create a StringBuilder or something similar in the startElement() method, and fill it with the characters in the characters() method and read it in the endElement() method.
For more information: http://forum.java.sun.com/thread.jspa?threadID=5255925 -
OBIEE Writeback error Sax parser Expected entity name with ampersand gt/lt
Hi,
I've enabled OBIEE 10.1.3.3.2 on Suse Linux 9.x writeback successfully for an OBIEE report, however if any of the fields contain XML special characters like ampersand, less than, greater than symbols etc when I save I get error:
An error occurred while writing to the server. Please check to make sure you have entered appropriate values. If the problem persists, contact your system administrator.
Sax parser returned an exception. Message: Expected entity name for reference, Entity publicId: , Entity systemId: , Line number: 1, Column number: 795
Error Details
Error Codes: UH6MBRBC:E6MUPJPH
Xml parsed: <writeBack template="entry"><record action="update"><value columnID="c10">C</value><value columnID="c2">Jun-08</value><value columnID="c5">0001</value><value columnID="c1">NET RESULT</value><value columnID="c7">T000</value><value columnID="c3">Total X & X</value>...
I don't really want to have to use replace function on all the fields in the report to remove special characters + train users not to enter them in editable field.
Anyone got any ideas how to get around this?
Thanks,
GarethHi
I am getting this error in writeback while submitting
An error occurred while writing to the server. Please check to make sure you have entered appropriate values. If the problem persists, contact your system administrator.
Sax parser returned an exception. Message: Unterminated entity reference, 'M', Entity publicId: , Entity systemId: , Line number: 1, Column number: 85
Error Details
Error Codes: UH6MBRBC:E6MUPJPH
Xml parsed: <writeBack template="CPE_writeback"><record action="update"><value columnID="c0">H&M SWEDEN</value><value columnID="c1">7/5/2010</value><value columnID="c2">8/26/2010</value><value columnID="c11">Administrator</value><value columnID="c7">BOOKED</value><value columnID="c10"> y</value><value columnID="c9">H&M SWEDEN ;7/5/2010 ;8/26/2010 ;BOOKED</value></record></writeBack>
I think the problem is with '&' or might be with something else, if i choose other options form dropdowns its does not give me any error. only fot this customer "H&M SWEDEN"
can any one please tell me what workaround i can do.. the obi version is 10.1.3.2 -
SAX Parser method charaters trouble
Hi,
I am using a sax parser for loading an xml file of size over 1gb. The problem whats happening is that the content gets truncated at random.
And this truncation happens in the characters method of the sax parser. This am sure as I logged the content I get from characters method before starting my processing. for ex:
<content>signal1,signal960</content>
<content>signal1,signal970</content>
On parsing the above snippet, the first content "signal1,signal960"
gets extracted completely, however the next one is truncated, and the truncation is random. This happens for some tags, and then the extraction resumes normally. And this truncation starts occuring again after it has extracted a few tags.
Also the first truncation started occuring only after parsing around 200 mb of the 1gb file.
Could anyone tell if there is some limitation with XERCES or CRIMSON.
or if any other one that I can use???
Regards,
R.To quote from the Documentation of ContentHandler.characters:
-- start quote --
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.
-- end quote --
So providing the content in two seperate calls is perfectly valid and must be handled by your code. It's probably a result of the internal workings of the XML parser and allowing that in the Parser specification probably allowed some optimizations that would otherwise be impossible (a constant buffer size, for example). -
SAX Parser throws NullPointerException
Hi.
I'm using WLS6.1 SP1 built-in XML SAX parser. The code is like,
SAXParserFactory factory = SAXParserFactory.newInstance();
XMLReader parser = factory.newSAXParser().getXMLReader();
// Add a error handler
eh = new MyErrorHandler();
parser.setErrorHandler(eh);
parser.setContentHandler(this);
// Enable namespace
parser.setFeature("http://xml.org/sax/features/namespaces", true);
// Enable validation
parser.setFeature("http://xml.org/sax/features/validation", false);
parser.parse(new InputSource(in));
The NullPointerException is thrown at -
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:965)
after the end element of (</eb:MessageHeader>) before the start element of <SOAP-ENV:Header>.
The XML file is attached.
=====================================
However, I tried to parse this document on xerces parser 131.
It worked fine.
=====================================
Did I miss any thing? It seems like a bug to me.
Thanks!
[header.xml]SAX should mask the fact that some content is specified inside of a CDATA section.. It is just characters.
The safest way to process characters is to setup a StringBuffer or equivalent in the startElement method. There is a variation of the StringBuffer append method that has the same three parameters (char[], int, int) as the characters signature. The characters method may be called many times before you are given all of the content of the string. How it decides when to call you depends on the parser and is subject to change over time. But, if you accumulate the contents in each call of characters and do the toString() in the endElement method you are going to get the right content. Lots of people over the last year or so that I've been involved in this forum have had other ways they thought were better than this, but most of them have eventually tried and accepted this way because it works and their "better" way did not.
It looks like you got the content for the CDATA section (Please refer...).I'm not sure what your problem is.
Dave Patterson
Maybe you are looking for
-
Acrobat Plug In Container Crashes After Update to Acrobat Pro 10.1.3
After the 10.1.3 update was applied to Acrobat Pro X for Windows (on Windows 7 64-bit), the Acrobat Plug-In for Firefox crashes intermittently. A dialog box will appear within the Firefox environment reporting the crash. Firefox continues running w
-
Netui: anchor tag with target attribute.
I am using the netui:anchor tag inside an iframe to post to an action. But the resulting page is displayed within the iframe. Will the target attribute of the netui:anchor tag help solve the problem. What is a valid value of the target attribute. tha
-
How do I Add Authentication to the WSDL generated?
Hi Experts, I am creating web service in CAF to get All task assigned to a user using BPM API. The WSDL generated while testing from wsnavigator is picking up as a guest user even if I am entering the user details in invocation parameters. Can some o
-
Can't pair Logitech FreePulse Bluetooth headset
It refuses point blank to work. I can put the headset into "discoverable" mode with the red/blue flashing. I can set up the Bluetooth device and pair it with the 0000 passkey. It WILL NOT connect. I CAN'T choose it from the Sound devices in system pr
-
IOS Incorrect Password when I put in the correct password?
I have had problems with all four iOS devices on my network for three days. It started Thursday (2/12/15) evening, and has been happening ever since. It has to be a relatively global problem because I have a friend in IT who says all of the 40+ iPads