• RELEVANCY SCORE 5.00

    DB:5.00:Stax: Xmloutputfactory.Newinstance() Returns An Xmlinputfactory? 11






    The following method is from the javax.xml.stream.XMLOutputFactory class. Does
    anyone have any idea why it would return an XMLInputFactory object?

    static XMLInputFactory newInstance(java.lang.String factoryId, java.lang.ClassLoader
    classLoader)

    Also, a side question... The no-param version of that method returns an XMLOutputFactory,
    which I assume is the correct behavior, but when I call it using BEA's implementation,
    I get the following error message. Does BEA's implementation have to be run under
    WebLogic, or what?

    javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase
    not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    ...

    DB:5.00:Stax: Xmloutputfactory.Newinstance() Returns An Xmlinputfactory? 11


    "Jeff Davis" jeff_a_davis@dell.com wrote:

    The following method is from the javax.xml.stream.XMLOutputFactory class.
    Does
    anyone have any idea why it would return an XMLInputFactory object?

    static XMLInputFactory newInstance(java.lang.String factoryId, java.lang.ClassLoader
    classLoader)

    Also, a side question... The no-param version of that method returns
    an XMLOutputFactory,
    which I assume is the correct behavior, but when I call it using BEA's
    implementation,
    I get the following error message. Does BEA's implementation have to
    be run under
    WebLogic, or what?

    javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase
    not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    ...First ,XMLOutputFactory.newInstance() return an XMLOutputFactory,there may me
    some error in your process.

    Second,about the questiong"BEA's implementation have to be run under WebLogic,
    or what?",I think BEA's implementation can run separatelly without Welbogic.JSR
    has it's own implementation in JSR_173.jar.

    Third,the question"javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase
    not found" must due to that you don't set the jar in your CLASSPATH.

  • RELEVANCY SCORE 3.03

    DB:3.03:Stax Read Write Unicode Behavior s7





    Hi All

    I use the stax event api...

    I read an input.xml file and write the content to an output.xml file.

    import java.io.*;
    import javax.xml.stream.*;

    public class Main {

    private static XMLInputFactory inputfactory = XMLInputFactory.newInstance();
    private static XMLOutputFactory outputfactory = XMLOutputFactory.newInstance();

    public static void main(String[] args) throws Exception {

    File inputFile = new File("d:/input.xml");
    File outputFile = new File("d:/output.xml");

    XMLEventReader reader = inputfactory.createXMLEventReader(new FileInputStream(inputFile), "UTF-8");
    XMLEventWriter writer = outputfactory.createXMLEventWriter(new FileOutputStream(outputFile), "UTF-8");

    writer.add(reader);

    writer.flush();
    writer.close();

    }
    }The input.xml contains japanese characters...

    ?xml version="1.0" encoding="UTF-8"?resultData
    value#x88fd;#x54c1;#x756a;/value
    /resultData

    The output.xml contains those japanese characters in an encoded format... (like #x....;#x....;#x....;)

    Can somebody plz explain me that?

    Thanx.
    Michi

  • RELEVANCY SCORE 2.84

    DB:2.84:Java.Lang.Stackoverflowerror 9s





    Hello,

    After 4 months working perfectly, my application is starting to throw the following error:

    java.lang.StackOverflowError
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanName(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    (...) hundreds of lines of "next" ( ...)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl.findNextEvent(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl.next(Unknown Source)

    It seems an infinite recursion when working with StAX (on "next" method). Searching at Google, I've found the following bug ID = 6440214, which says that there are problems using IS_COALESING = true with StAX. It can provoke infinite recursion:

    REPRODUCIBILITY :
    This bug can be reproduced always.

    ---------- BEGIN SOURCE ----------
    XMLInputFactory xif = XMLInputFactory.newInstance();
    xif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
    ...
    XMLStreamReader in = ....;
    ...
    String txt = in.getElementText();
    ---------- END SOURCE ----------

    CUSTOMER SUBMITTED WORKAROUND :
    XMLInputFactory xif = XMLInputFactory.newInstance();
    // bad for performance
    xif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
    Posted Date : 2006-06-19 08:21:35.0

    Work Around N/A

    Evaluation bug is reproducible and is being accepted.
    Posted Date : 2006-06-20 18:20:25.0

    deep within the Xerces scanner, recursion occurs under certain circumstances. the provided test file with coalescing = true causes massive recursion. this is a core design of the Xerces scanner and requires significant re-factoring. this re-factoring is too risky for the Mustang timeframe so CR is being targeted for jaxp.next.
    Posted Date : 2006-07-26 00:06:21.0

    But this bug is from 2006.

    I'm currently working with java 6 update 17, 64 bits, on Windows 2003 Server, with Tomcat 6.1.18. As I said, everything worked perfectly for 4 months and now, without changing anycode, I have this error.

    Is this a known problem with StAX? Any help would be very very appreciated.

    Thanks in advance,

    Joan.

    DB:2.84:Java.Lang.Stackoverflowerror 9s

    Hello,

    I don't know if this is an interesting question for this forum, and I don't know if more people found this problem. The only thing I can do is set isCoalescing to false, and execute an stress test to check if the performace is so poor as the bug says. After doing this, my stress test shows that there is no performance difference between coalescing true or false after parsing 1000 times a 1Mb. document with 15.000 CDATA sections.

    Then, I'll try to set isCoalescing to false and check if the error disappears.

    Thanks,

    Joan.

  • RELEVANCY SCORE 2.71

    DB:2.71:Newinstance() s8


    here is a snippet.....
    Class.forName("your_game_class_file").newInstance() i visited the API for class Class.

    It says...

    static Class forName(String className)
    Returns the Class object associated with the class or interface with the given string name.

    there is no newInstance(). then whare is newInstance() ?

    DB:2.71:Newinstance() s8

    Hi

    thank you. Its clear now. Your explanation is very nice . I have understood it .
    thanks.

  • RELEVANCY SCORE 2.64

    DB:2.64:The Difference Between The Newinstance() And The Constructor fd


    Hi all experts,
    Could you advice about the difference between the newInstance() method and the constructor when creating a new instance from a class?

    Thanks a lot!

    Michael

    DB:2.64:The Difference Between The Newinstance() And The Constructor fd

    Hi all experts,
    Could you advice about the difference between the
    newInstance() method and the constructor when creating
    a new instance from a class?

    Thanks a lot!

    MichaelThe idea of a factory method is to provide your application with a level of control over object creation. A few hours reading of the Creational Patterns section of the classic book "Design Patterns" would be a great place to start to understand why the factory method is used at all.

    A good case in point is where you wish to maintain a list (cache) of all newly created objects of the type without forcing that management drudgery onto the client code.

    /k1

  • RELEVANCY SCORE 2.61

    DB:2.61:Generated Output Using Stax za


    I am using an fileoutput Stream in STAX to write an XML . But the generated output comes in a single line.

    An example of the output:

    employeename = "abc"/number = "123"name = "bcd" /number="345"/employee

    How can I format this file for spacing?? Any help!

    DB:2.61:Generated Output Using Stax za

    I am using an fileoutput Stream in STAX to write an XML . But the generated output comes in a single line.

    An example of the output:

    employeename = "abc"/number = "123"name = "bcd" /number="345"/employee

    How can I format this file for spacing?? Any help!

  • RELEVANCY SCORE 2.51

    DB:2.51:Resultset In Mysql Returns 399 Rows Only 99


    I am using the org.gjt.mm.mysql.Driver for MySQL.
    Loading the driver and connecting all works fine. The only problem is that if the table has more than 399 rows the remaining rows are not selected into the ResultSet.
    The application is a jdbc connection script running on the server. It is not running via the web. It seems that MySQL does not like ResultSets larger than 399 rows through the org.gjt.mm.mysql.Driver Driver. Any help would be appreciated. Code follows:

    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection mysql = DriverManager.getConnection("jdbc:mysql://host:port/database?user=userpassword=password");
    Statement stmt2 = mysql.createStatement();
    ResultSet rs2 = stmt2.executeQuery("select * from table");
    }
    ..
    ..

    DB:2.51:Resultset In Mysql Returns 399 Rows Only 99

    it may have to do with the Statement's max rows default setting. You can check to see what the maximum rows returned is and set the max rows returned to unlimited by
    System.out.println("max rows returned: "+stmt.getMaxRows());
    //set max rows to unlimited
    stmt.setMaxRows(0);Jamie

  • RELEVANCY SCORE 2.50

    DB:2.50:What Does Stax Stand For? fs


    I googled about StAX.Some websites told that StAX stands for "Standard API for XML" and some told that "Streaming API for XML Processing"

    What is this right one?

  • RELEVANCY SCORE 2.49

    DB:2.49:Re: Stax 98


    so must I use another stream reader? I really need one, is there any other XMLReader that has it?

    DB:2.49:Re: Stax 98

    Encephalopathic wrote:
    England lost. Get over it. But that's no reason not to help a fellow programmer in need.Yes, you're right. Just wasn't up to googling for the technical stuff.

    Winston

    .

  • RELEVANCY SCORE 2.43

    DB:2.43:Xmlencoder Illegalaccessexception k1


    On a server side program I have the following code:

    private void locateAll(HttpServletResponse response) throws IOException {
    ModelerOperations[] m = ModelerFactory.getInstance().locateAll();
    XMLEncoder enc = new XMLEncoder(response.getOutputStream());
    enc.writeObject(new Integer(m.length));
    for (int i = 0; i m.length; i++) {
    enc.writeObject(m.getInstanceName());//returns a String
    enc.writeObject(m[i].getVersion()); //returns a String
    enc.writeObject(m[i].getStartTime()); //returns a java.util.Date
    enc.writeObject(m[i].getStatus()); //returns a String
    enc.writeObject(m[i].getInfo()); //returns a java.util.Properties
    }
    enc.close();
    }

    On the client side, when I try and read the first integer with the code:
    XMLDecoder dec = new XMLDecoder(connection.getInputStream());
    int length = ((Integer) dec.readObject()).intValue();
    I get a ClassCastException at the second line.

    In the tomcat window, the following errors appear:
    java.lang.IllegalAccessException: Can not call newInstance() on the Class for java.lang.Class
    Continuing ...
    java.lang.Exception: discarding statement XMLEncoder0.writeObject(Integer0);
    Continuing ...
    java.lang.IllegalAccessException: Can not call newInstance() on the Class for java.lang.Class
    Continuing ...
    java.lang.Exception: discarding statement XMLEncoder0.writeObject(Date0);
    Continuing ...
    java.lang.IllegalAccessException: Can not call newInstance() on the Class for java.lang.Class
    Continuing ...
    java.lang.Exception: discarding statement XMLEncoder0.writeObject(Properties0);
    Continuing ...

    Any ides as to what's going on?

    DB:2.43:Xmlencoder Illegalaccessexception k1

    I think there's a bug in your ModelerFactory or ModelerOperations.

  • RELEVANCY SCORE 2.39

    DB:2.39:Finding Type Of Primitive At Runtime Using Reflection !! c1


    Hi,

    Is there any way to get the type of primitive using reflection.
    Consider the scenario :

    String classType = "java.lang.Integer";
    String paramValue = "10";

    Class classObj = Class.forName( classType );

    Object obj = classObj.getConstructor( new Class[] {String.class } ).
    newInstance(new Object[] { paramValue }) ) ;

    java.lang.Integer defines a variable called TYPE which returns the type, but in the above line newInstance returns an Object and not Integer

    Is there a way to find the type of primitive from the above code
    considering that the classType variable can change?

    Any help is greatly appreciated .

    Regards,
    Harsha

    DB:2.39:Finding Type Of Primitive At Runtime Using Reflection !! c1

    Your scenario is wrong, you are creating an instance of Integer which is not primitive.
    You need to create a scenario like this..

    When querying a class for a Field then you can determine if the Field is primitive
    Class clazz = obj; //** Where obj is any object
    Field f = clazz.getDeclaredField( "field" );
    Class fieldType = f.getType();
    if( f.getType().isPrimitive() ) {
    if( fieldType.equals( Byte.TYPE ) {
    System.out.println( "Field: field is byte primitive" );
    }
    //** repeat for each type
    }
    //** get the value of the field for obj and print it out
    System.out.println( "Field value = " + f.getValue( obj ) );Obviously this is not really useful when you want to do something sensible with the value of the field.
    You need to expand on what it is you are trying to achieve.

  • RELEVANCY SCORE 2.38

    DB:2.38:Override Tostring() Using Stax xf


    I need to save some objects and I chose to save them in an XML format due to quantity and size. I'm using StAX for the reading and writing, however instead of writing to an XML file, I'd rather have StAX format a string and just return it, then I'll write it to a file later on. Anyone have any ideas?

    Thanks.

    DB:2.38:Override Tostring() Using Stax xf

    Did u solve this problem already? If u did can u please explain how u solved it.

  • RELEVANCY SCORE 2.37

    DB:2.37:Bug In Stax Ri Implementation s8


    I have three way of parsing :
    - stax with bea impl
    - xpp (http://www.extreme.indiana.edu/xgws/xsoap/xpp/)
    - sax (xerces)
    With the sample code below :

    import java.io.StringReader;

    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.stream.XMLInputFactory;
    import javax.xml.stream.XMLStreamConstants;
    import javax.xml.stream.XMLStreamReader;

    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xmlpull.v1.XmlPullParser;
    import org.xmlpull.v1.XmlPullParserFactory;

    import com.bea.xml.stream.MXParserFactory;

    public class MyTest {

    private static String xml = "rootelemtiti #233; zorro #233; #233;/elem/root";

    private static String realElemVal = "titi zorro ";

    private static String elemName = "elem";

    public void testparsewithbeastream() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XMLInputFactory stream = MXParserFactory.newInstance();
    XMLStreamReader streamReader = stream.createXMLStreamReader(new StringReader(xml));
    while(streamReader.hasNext()) {
    switch (streamReader.getEventType()) {
    case XMLStreamConstants.START_ELEMENT :
    if (streamReader.getLocalName().equals(elemName)) {
    elempar = true;
    }
    break;
    case XMLStreamConstants.END_ELEMENT :
    if (streamReader.getLocalName().equals(elemName)) {
    elempar = false;
    }
    break;
    case XMLStreamConstants.CHARACTERS :
    if (elempar) {
    elemVal.append(streamReader.getText());
    }
    break;
    default :

    }

    streamReader.next();
    }
    System.out.println(" elemVal : " + elemVal);
    System.out.println("longueur equals with bea stream : " + (elemVal.length()== realElemVal.length()));
    } catch (Exception e) {
    e.printStackTrace();

    }
    }

    public void testwithxpp() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
    xpp.setInput(new StringReader(xml));
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
    switch (eventType) {
    case XmlPullParser.START_TAG :
    if (xpp.getName().equals(elemName)) {
    elempar = true;
    }
    break;
    case XmlPullParser.END_TAG :
    if (xpp.getName().equals(elemName)) {
    elempar = false;
    }
    case XmlPullParser.TEXT :
    if (elempar) {
    elemVal.append(xpp.getText());
    }
    break;
    default :

    }
    eventType = xpp.next();
    }
    System.out.println(" elemVal : " + elemVal);
    System.out.println("longueur equals with xpp : " + (elemVal.length()== realElemVal.length()));
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public void testwithsax() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
    Myhandler h = new Myhandler();
    reader.setContentHandler(h);
    reader.parse(new InputSource(new StringReader(xml)));
    System.out.println(" elemVal : " + h.getVal());
    System.out.println("longueur equals with sax: " + (h.getVal().length()== h.getVal().length()));
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    private static class Myhandler extends DefaultHandler {
    StringBuffer valele = new StringBuffer();
    boolean elempar = false;

    public String getVal() {
    return this.valele.toString();
    }

    public void characters(final char[] buf, final int offset, final int len)
    throws SAXException {
    if (elempar) {
    valele.append(new String(buf, offset, len));
    }
    }

    public void endElement(String arg0, String name, String qname)
    throws SAXException {
    if (qname.equals(elemName)) {
    elempar = false;
    }
    }

    public void startElement(String arg0, String name, String qname,
    Attributes arg3) throws SAXException {
    if (qname.equals(elemName)) {
    elempar = true;
    }
    }
    }

    public static void main(String[] args) throws Exception {
    MyTest t = new MyTest();
    t.testparsewithbeastream();
    t.testwithxpp();
    t.testwithsax();
    }
    }

    Look at the result, it's a bug ???
    change
    private static String xml = "rootelemtiti #233; zorro #233; #233;/elem/root";

    with private static String xml = "rootelemtiti #233; zorro #233; #233; /elem/root";
    and it's better.

    DB:2.37:Bug In Stax Ri Implementation s8

    I have three way of parsing :
    - stax with bea impl
    - xpp (http://www.extreme.indiana.edu/xgws/xsoap/xpp/)
    - sax (xerces)
    With the sample code below :

    import java.io.StringReader;

    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.stream.XMLInputFactory;
    import javax.xml.stream.XMLStreamConstants;
    import javax.xml.stream.XMLStreamReader;

    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xmlpull.v1.XmlPullParser;
    import org.xmlpull.v1.XmlPullParserFactory;

    import com.bea.xml.stream.MXParserFactory;

    public class MyTest {

    private static String xml = "rootelemtiti #233; zorro #233; #233;/elem/root";

    private static String realElemVal = "titi zorro ";

    private static String elemName = "elem";

    public void testparsewithbeastream() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XMLInputFactory stream = MXParserFactory.newInstance();
    XMLStreamReader streamReader = stream.createXMLStreamReader(new StringReader(xml));
    while(streamReader.hasNext()) {
    switch (streamReader.getEventType()) {
    case XMLStreamConstants.START_ELEMENT :
    if (streamReader.getLocalName().equals(elemName)) {
    elempar = true;
    }
    break;
    case XMLStreamConstants.END_ELEMENT :
    if (streamReader.getLocalName().equals(elemName)) {
    elempar = false;
    }
    break;
    case XMLStreamConstants.CHARACTERS :
    if (elempar) {
    elemVal.append(streamReader.getText());
    }
    break;
    default :

    }

    streamReader.next();
    }
    System.out.println(" elemVal : " + elemVal);
    System.out.println("longueur equals with bea stream : " + (elemVal.length()== realElemVal.length()));
    } catch (Exception e) {
    e.printStackTrace();

    }
    }

    public void testwithxpp() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
    xpp.setInput(new StringReader(xml));
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
    switch (eventType) {
    case XmlPullParser.START_TAG :
    if (xpp.getName().equals(elemName)) {
    elempar = true;
    }
    break;
    case XmlPullParser.END_TAG :
    if (xpp.getName().equals(elemName)) {
    elempar = false;
    }
    case XmlPullParser.TEXT :
    if (elempar) {
    elemVal.append(xpp.getText());
    }
    break;
    default :

    }
    eventType = xpp.next();
    }
    System.out.println(" elemVal : " + elemVal);
    System.out.println("longueur equals with xpp : " + (elemVal.length()== realElemVal.length()));
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public void testwithsax() throws Exception {
    try {
    StringBuffer elemVal = new StringBuffer();
    boolean elempar = false;
    XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
    Myhandler h = new Myhandler();
    reader.setContentHandler(h);
    reader.parse(new InputSource(new StringReader(xml)));
    System.out.println(" elemVal : " + h.getVal());
    System.out.println("longueur equals with sax: " + (h.getVal().length()== h.getVal().length()));
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    private static class Myhandler extends DefaultHandler {
    StringBuffer valele = new StringBuffer();
    boolean elempar = false;

    public String getVal() {
    return this.valele.toString();
    }

    public void characters(final char[] buf, final int offset, final int len)
    throws SAXException {
    if (elempar) {
    valele.append(new String(buf, offset, len));
    }
    }

    public void endElement(String arg0, String name, String qname)
    throws SAXException {
    if (qname.equals(elemName)) {
    elempar = false;
    }
    }

    public void startElement(String arg0, String name, String qname,
    Attributes arg3) throws SAXException {
    if (qname.equals(elemName)) {
    elempar = true;
    }
    }
    }

    public static void main(String[] args) throws Exception {
    MyTest t = new MyTest();
    t.testparsewithbeastream();
    t.testwithxpp();
    t.testwithsax();
    }
    }

    Look at the result, it's a bug ???
    change
    private static String xml = "rootelemtiti #233; zorro #233; #233;/elem/root";

    with private static String xml = "rootelemtiti #233; zorro #233; #233; /elem/root";
    and it's better.

  • RELEVANCY SCORE 2.35

    DB:2.35:Xmlstreamreader Cuts The Gettext()-String Off After " dx


    Hi there!

    I'm having a bit of a problem with parsing the following part of an XML-file:
    *elementtext "quotet text" more text/element*

    What I expected was that the parser returns:
    "*text "quotet text" more text*"
    but instead there is just:
    "*text* "
    so the String is cut right at the start of the first " or quot;.

    The code in a very simple way looks like:
    {code}
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader parser = factory.createXMLStreamReader(inputStream);

    while (parser.hasNext()) {
    switch (parser.getEventType()) {
    case XMLStreamConstants.CHARACTERS:
    if (!parser.isWhiteSpace())
    System.out.println(parser.getText());
    }
    }
    {code}

    Hopefully there is a way to get this right with XMLStreamReader since it is considered to be the fastest way to parse XML data and rewriting the whole parsing method using an alternative would of course be a lot of work.

    Thanks in advance for reading this and maybe providing help.

    Greetings
    JAVAnetic

    Edited by: JAVAnetic on May 12, 2010 10:43 AM

    DB:2.35:Xmlstreamreader Cuts The Gettext()-String Off After " dx

    It's a performance feature for the parser. The getElementText() method can require more resources than the getText() method, so the user has the option of not using it and dealing with parts of text nodes themselves.

  • RELEVANCY SCORE 2.34

    DB:2.34:Newinstance() And Compiler Warning In Java 1.5 88


    String name;...
    Service service = ((ClassService)Class.forName(name)).newInstance();

    this gives compiler warning in Java 1.5. Any way to avoid it?

    DB:2.34:Newinstance() And Compiler Warning In Java 1.5 88

    Unchecked code...
    ... =
    Service.class.cast(Class.forName(name).newInstance())...or, very similar:
    ... = Class.forName(name).asSubclass(Service.class).newInstance();

  • RELEVANCY SCORE 2.34

    DB:2.34:Start The Stax mk



    I download the versions available of STAF and STAX from the link mentions in the guide (STAF349-setup-winamd64 and STAXV353).While starting the run in the cmd, i put the command wich start STAX and i obtain this error: STAX Job Monitor V3.5.3 requires STAF V3.3.3 or later to be running.

    What i have to do???Which package should i use and from where download it???

    DB:2.34:Start The Stax mk


    Ah no STAF was installed, i allow stafproc from the firewall and i create a basic task also from the beginnig. I had this problem while starting the run.10xxx for the infos, i install it and it worked

  • RELEVANCY SCORE 2.34

    DB:2.34:Unitofwork Newinstance() Method 8f


    Hello,

    afaik returns the newInstance()-Method of UnitOfWork a cloneObject. Is there a way to get a reference to the cacheObject resulting in the creation?

    exmaple:
    --------

    private ArrayList dataList;

    public Object addRow(int rowIndex, Class dataClass) {

    UnitOfWork uow = databaseSession.acquireUnitOfWork();

    Object dataObject = uow.newInstance(dataClass);
    uow.assignSequenceNumber(dataObject);
    dataList.add(rowIndex, dataObject);

    return dataObject;
    }

    --------

    i don't know what happens when i commit the UnitOfWork, cos i added a reference to a clonedObject to my ArrayList. Any suggestions?

    Steffen

    DB:2.34:Unitofwork Newinstance() Method 8f

    At any point in time you should be able to get the cached (session) object and the equivalent cloned (UOW) object. If you want the session object, just do a session.readObject and if you want the clone for a given UOW, just do a uow.readObject... No matter what, you should always be able to get the cloned/cached object.

    New objects don't exist in the cache until the UOW commits, that's just a fact of logic, nothing I can do about that.

    - Don

  • RELEVANCY SCORE 2.24

    DB:2.24:Doubt About Stax md


    Hai
    I want to know whether it is possible to validate a document as it is being built
    using the stax api .We can validate a Document object before transforming it into an xml file using DOM.Is a similar approach possible in stax ?
    Thanks in advance

    DB:2.24:Doubt About Stax md

    Validating STAX parsers do exist. I just verified that with a 30-second Google search.

  • RELEVANCY SCORE 2.23

    DB:2.23:Arbitrary Number Of Parameters ds


    I try to call a method defined to accept an arbitrary number of parameters, in particular in the following piece of code:

    String catalogPath = "/path/to/catalog";
    Constructor constr = resolverClass.getConstructor(
    new Class[] {CatalogManager.class});
    Object obj = constr.newInstance(catalogPath);where the method newInstance (see java.lang.reflect.Constructor) is declared as follows:

    public T newInstance(Object... initargs)
    throws InstantiationException,
    IllegalAccessException,
    IllegalArgumentException,
    InvocationTargetExceptionHowever, this piece of code is rejected (method not applicable to String). Casting the String into an Object returns the same comment, now for Object. Putting the String into an array and passing that array as a parameter is compiled without any problems but then throws an IllegalArgumentException with the message "type mismatch".

    What am I doing wrong here? Or is that in fact a compiling problem? (I'm using Java SE 1.6.0_01).

    Dieter

    DB:2.23:Arbitrary Number Of Parameters ds

    Dear endasil,

    many thanks for your helpful comments! In fact, I was slightly confused about my own writing after reading your comment!-)

    What I really wanted to do was the following:

    CatalogManager mgr = new CatalogManager(path);
    CatalogResolver res = new CatalogResolver(mgr);In the meantime, I have found a way to avoid Reflection so the problem has gone for the moment. But I tried to rewrite the snippet above correctly, and - at least - there are no compiling problems any more:

    String catalogPath = "/Dieter/JAVA_Beispiele/XSLT/build";
    CatalogManager cm = new CatalogManager(catalogPath);
    //
    // get a CatalogResolver instance and preset its CatalogManager
    Class resolverClass = loader.loadClass(className);
    Constructor constr = resolverClass.getConstructor(
    new Class[] {CatalogManager.class});
    Object[] args = new Object[] {cm};
    Object obj = constr.newInstance(args);However, I have to explicitly use an array; just putting cm as a single argument instead of args is not accepted by the compiler!

    Many thanks for your (eye opening!) help!

    profos

  • RELEVANCY SCORE 2.23

    DB:2.23:A Weblogic Stax Xmlstreamexception jf



    I'm going to write a StAX Parser.During the analyse of Weblogic StAX RI,I find
    a problem below:
    I write a non-wellformed XML document:
    foo xmlns="http://www.megginson.com/ns/exp/poetry" book="abc"
    !--description-- content text
    ![CDATA[greetingHello/greeting]]
    other content
    /foo
    ?aaaaaaaaaaaaaa

    As we can see the last sentence violates the WFC,so we'll see Exception this place.But
    when I parse this document with Weblogic StAX Parser,I get this:
    javax.xml.stream.XMLStreamException: ' ' expected a valid beginning name character
    at weblogic.xml.stax.XMLStreamReaderBase.prime(XMLStreamReaderBase.java:69)
    at weblogic.xml.stax.XMLStreamReaderBase.setInput(XMLStreamReaderBase.java:82)
    at weblogic.xml.stax.XMLStreamInputFactory.createXMLStreamReader(XMLStreamInputFactory.java:228)
    at parse.main(parse.java:52)
    Exception in thread "main"

    What's confusing is that this Exception is thrown at the time we create the XMLStreamReader.

    Can you explain this to me? Whether or not,thanks a lot!

    DB:2.23:A Weblogic Stax Xmlstreamexception jf


    I'm going to write a StAX Parser.During the analyse of Weblogic StAX RI,I find
    a problem below:
    I write a non-wellformed XML document:
    foo xmlns="http://www.megginson.com/ns/exp/poetry" book="abc"
    !--description-- content text
    ![CDATA[greetingHello/greeting]]
    other content
    /foo
    ?aaaaaaaaaaaaaa

    As we can see the last sentence violates the WFC,so we'll see Exception this place.But
    when I parse this document with Weblogic StAX Parser,I get this:
    javax.xml.stream.XMLStreamException: ' ' expected a valid beginning name character
    at weblogic.xml.stax.XMLStreamReaderBase.prime(XMLStreamReaderBase.java:69)
    at weblogic.xml.stax.XMLStreamReaderBase.setInput(XMLStreamReaderBase.java:82)
    at weblogic.xml.stax.XMLStreamInputFactory.createXMLStreamReader(XMLStreamInputFactory.java:228)
    at parse.main(parse.java:52)
    Exception in thread "main"

    What's confusing is that this Exception is thrown at the time we create the XMLStreamReader.

    Can you explain this to me? Whether or not,thanks a lot!

  • RELEVANCY SCORE 2.23

    DB:2.23:How To Parse Values With Ampersand Using Sun Stax Parser ka


    I have a xml element with value as follows:

    NAMEAT T/NAME

    When I parse using Stax Cursor API

    XMLStreamReader xmlr = xmlif.createXMLStreamReader(new StringReader(xml));

    xmlr.getText() gives me AT as the value instead of AT T

    What should i do to get the correct value ?

    DB:2.23:How To Parse Values With Ampersand Using Sun Stax Parser ka

    DrClap, after reading a couple more threads on this forum I think you're right, although this is not mentioned in the documentation as far as I can see

  • RELEVANCY SCORE 2.22

    DB:2.22:Execute Stax Has An Error Message xj


    Hi VMmark user

    I face a problem.

    I configure VMmark workload and client completed.

    When I execute STAX, it shows "LIST JOBS requests failed with RC=2 Result=STAX".

    Does anyone have this problem?

    DB:2.22:Execute Stax Has An Error Message xj

    Find result by myself

    In STAF.cfg file, excute path should not erase.

  • RELEVANCY SCORE 2.21

    DB:2.21:Obfuscating Problems jm


    To handle the error :

    "java.lang.NoClassDefFoundError: javax/xml/stream/XMLInputFactory: Cannot create class in system package"

    I try to obfuscate my project in Eclipse to rename the 'javax' import files. But when try doing so, I get multiple warnings and it seems like nothing is changed after I click Continue. These are (a few) of the warnings:

    Warning: javax.xml.stream.XMLEventReader: can't find superclass or interface java.util.Iterator
    Warning: com.bea.xml.stream.util.ArrayIterator: can't find superclass or interface java.util.Iterator
    Warning: com.bea.xml.stream.util.CircularQueue: can't find superclass or interface java.util.AbstractCollection
    Warning: com.bea.xml.stream.test.BaseTestCase: can't find superclass or interface junit.framework.TestCase
    Warning: com.bea.xml.stream.util.EmptyIterator: can't find superclass or interface java.util.Iterator
    Warning: com.bea.xml.stream.test.AllTests$1: can't find superclass or interface junit.extensions.TestSetup
    Warning: com.bea.xml.stream.util.CircularQueue$1: can't find superclass or interface java.util.Iterator
    Warning: com.bea.xml.stream.util.Stack: can't find superclass or interface java.util.AbstractCollection
    Warning: javax.xml.namespace.QName: can't find superclass or interface java.io.Serializable
    Warning: com.bea.xml.stream.reader.XmlReader: can't find referenced method 'boolean isWhitespace(char)' in class java.lang.Character
    Warning: javax.xml.stream.FactoryFinder$ClassLoaderFinderConcrete: can't find referenced method 'java.lang.ClassLoader getContextClassLoader()' in class java.lang.Thread
    Warning: com.bea.xml.stream.samples.EventWrite: can't find referenced method 'java.lang.String setProperty(java.lang.String,java.lang.String)' in class java.lang.System
    Warning: javax.xml.stream.util.EventReaderDelegate: can't find referenced method 'java.lang.Object next()' in class javax.xml.stream.XMLEventReader
    Warning: javax.xml.stream.util.EventReaderDelegate: can't find referenced method 'void remove()' in class javax.xml.stream.XMLEventReader
    .....

    it seems he needs non-J2ME files that's really weird because this package (StaX) should also be runnable in a J2ME environment!

    DB:2.21:Obfuscating Problems jm

    ok thx, it's getting a lot more clear for me now.

    And there are plenty of xml parsers available for J2ME btw. A little google search gives allready plenty of options.

  • RELEVANCY SCORE 2.19

    DB:2.19:How To Stop Staf(Stax) Smoothly 9a



    When run vmmark, if I find the mailserver tesk pending over 10000, how can I stop all running scripts smoothly?

    DB:2.19:How To Stop Staf(Stax) Smoothly 9a

    Check the troubleshooting section in the VMmark Benchmarking Guide around page 126.

    Try the proceedure that talks about canceltest.sh

  • RELEVANCY SCORE 2.19

    DB:2.19:How To Maximum Release Memory In Stax? js


    Hi, i am learning the programming of StAX. I copied some code fragment from Internet, like:

    try {
    // First create a new XMLInputFactory
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    // Setup a new eventReader
    InputStream in = new FileInputStream(configFile);
    XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
    // Read the XML document
    ...
    // When reach the end of xml doc,
    // Closing what you have opened
    if(event.isEndDocument()) {
    //Close the reader to release memory
    eventReader.close();
    }

    After parsing a xml, I want to release all the memory that used by StAX . Above code release the eventReader, what else need to do? how to release the inputStream and XMLInputFactory?

    Thanks.

    Edited by: kingsz1 on Jul 13, 2010 5:27 AM

    DB:2.19:How To Maximum Release Memory In Stax? js

    Hi, i am learning the programming of StAX. I copied some code fragment from Internet, like:

    try {
    // First create a new XMLInputFactory
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    // Setup a new eventReader
    InputStream in = new FileInputStream(configFile);
    XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
    // Read the XML document
    ...
    // When reach the end of xml doc,
    // Closing what you have opened
    if(event.isEndDocument()) {
    //Close the reader to release memory
    eventReader.close();
    }

    After parsing a xml, I want to release all the memory that used by StAX . Above code release the eventReader, what else need to do? how to release the inputStream and XMLInputFactory?

    Thanks.

    Edited by: kingsz1 on Jul 13, 2010 5:27 AM

  • RELEVANCY SCORE 2.19

    DB:2.19:Javax.Xml.Stream.Xmlstreamexception Throws When Present '&Amp;' Character ma


    Hi
    I am writing a code using stax parser. But recently I got an error when "" or "" present in the xml document.
    This is the error I am getting
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[30,30]
    Message: The reference to entity "name" must end with the ';' delimiter.This is my xml
    url http://url?id=1name=aaa /url This is my code
    XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
    xmlInputFactory.setProperty(
    XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
    Boolean.TRUE);
    xmlInputFactory.setProperty(
    XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,
    Boolean.FALSE);
    xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);

    String xmlSource;
    XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(xmlSource.getBytes("UTF-8")));

    while (reader.hasNext())
    {
    ....
    reader.next(); // error throws in this line
    }Can someone please help me.

    DB:2.19:Javax.Xml.Stream.Xmlstreamexception Throws When Present '&Amp;' Character ma

    But the second time I am assigning the processed xml to a string and use this string as a input to the second xml processing.So don't do that. Keep it as a DOM tree.

  • RELEVANCY SCORE 2.19

    DB:2.19:Stax Support For Jdk 1.4 And J2ee 1.3 1d


    Hi there,
    I am using JDK 1.4 and J2EE 1.3 in production. I would like to use StAX for parsing XML documents. But StAX introduced in java 6. Will JDK 1.4 and J2EE 1.3 supports StAX?

    Regards,
    A.

    DB:2.19:Stax Support For Jdk 1.4 And J2ee 1.3 1d

    Hi there,
    I am using JDK 1.4 and J2EE 1.3 in production. I would like to use StAX for parsing XML documents. But StAX introduced in java 6. Will JDK 1.4 and J2EE 1.3 supports StAX?

    Regards,
    A.

  • RELEVANCY SCORE 2.18

    DB:2.18:Stax And Large Xmls 8z


    Hi everyone,

    I want to use StAX for parsing an XML file that is about 20 MB large. Within this XML, a binary file is embedded which is located under a specific XML element.

    I thought that it would be a good idea to use StAX in that situation, because I want to make use of streaming technology. One goal was to avoid that I have the entire content of the embedded file in memory, but only single characters, which I can put into another stream.

    I am now facing the problem, that the StAX implementations (I tested the BEA implementation and the reference implementation) do not support the "getTextCharacters" method, which would be the most essential method for retrieving characters from a stream during a "CHARACTER" event.

    Currently, the only possibility to read out characters is calling the "getText" method, but in that case, I have the entire file in memory (really bad!).

    Does anyone has experience using StAX and especially streaming large XML elements to a file?

    I see no benefit of a StAX implementation which does not allow calling this method:

    getTextCharacters(int sourceStart,char[] target,int targetStart, int length)

    In my opinion, that would be the actual heart of a real streaming API.

    Does anyone know a good StAX implementation that supports that operation?

    Best regards,
    Martin

    DB:2.18:Stax And Large Xmls 8z

    Hi everyone,

    I want to use StAX for parsing an XML file that is about 20 MB large. Within this XML, a binary file is embedded which is located under a specific XML element.

    I thought that it would be a good idea to use StAX in that situation, because I want to make use of streaming technology. One goal was to avoid that I have the entire content of the embedded file in memory, but only single characters, which I can put into another stream.

    I am now facing the problem, that the StAX implementations (I tested the BEA implementation and the reference implementation) do not support the "getTextCharacters" method, which would be the most essential method for retrieving characters from a stream during a "CHARACTER" event.

    Currently, the only possibility to read out characters is calling the "getText" method, but in that case, I have the entire file in memory (really bad!).

    Does anyone has experience using StAX and especially streaming large XML elements to a file?

    I see no benefit of a StAX implementation which does not allow calling this method:

    getTextCharacters(int sourceStart,char[] target,int targetStart, int length)

    In my opinion, that would be the actual heart of a real streaming API.

    Does anyone know a good StAX implementation that supports that operation?

    Best regards,
    Martin

  • RELEVANCY SCORE 2.17

    DB:2.17:Stax Error When Executing Vmmark2-Stax.Bat - Stax Service Not Registered c7



    Hi All,

    I'm hoping someone can help. I have finished configuring all the systems required to run VMmark 2.5. I have configured the primeclient and client0 on the same machine, Windows 2008 R2 x64 however when I run VMMark2-STAX.bat I get the following error:

    STAX Service Machine: local

    STAX Service Name: STAX

    WARNING: The STAX service is not registered on the specified machine.

    Verify the STAX Monitor's properties.

    However StafProc.exe appears to be running.

    I cannot find any logs that might might point me in the right direction and the only info I have found on the forum regarding this is the following post which didn't resolve my problem (https://communities.vmware.com/thread/449927?start=0tstart=0)

    Any help would be much appreciated.

    Thanks, Charlie

    DB:2.17:Stax Error When Executing Vmmark2-Stax.Bat - Stax Service Not Registered c7


    Sorry, I was being a complete idiot and had saved staf.cfg to c:\staf\ not c:\staf\bin\!! Once the correct config was in place it obviously sprang into life!

  • RELEVANCY SCORE 2.17

    DB:2.17:Newinstance() 9f


    What is the purpose of newInstance()? Can't I just call new?

    DB:2.17:Newinstance() 9f

    newInstance() is also useful if you have the full name of the class known only at runtime, then you can do something kinda like:

    Class loadClass = Class.forName(sClassName);
    Object obj = loadClass.newInstance();
    return(obj);

  • RELEVANCY SCORE 2.17

    DB:2.17:Diff B/W Class.Forname() And Newinstance() p3


    What is use of newInstance() in classname Class , even it's have ForName() ?

    DB:2.17:Diff B/W Class.Forname() And Newinstance() p3

    newInstance creates a new instance of the class that the "Class object" reprents. That is, if the class object represents the standard String class, calling newInstance() creates a new String object.

    the forName method in turn gives you a "Class object," that is, calling Class.forName("java.lang.String") returns you an object that represents standard String class.

    read the API documentation for further details, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html

  • RELEVANCY SCORE 2.17

    DB:2.17:Who's Right - Jdk 1.6 Stax Or Woodstox? mm


    Hi all...

    I have a serious problem with switching between aforementioned technologies and I'm confused which one works properly. My case is easy - I have XML that starts like this:
    ?xml version="1.0" encoding="UTF-8"?
    !DOCTYPE field-specification SYSTEM "http://xxx/dtd/field-specification.dtd"And I have following naive code:
    XMLInputFactory xmlif = XMLInputFactory.newInstance();
    XMLStreamReader reader = xmlif.createXMLStreamReader(sourceReader);Now using WoodStox it ends like:
    com.ctc.wstx.exc.WstxIOException: xxx
    at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:650)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1071)
    at sk.bgs.swift.XMLUtils.prepareXmlReader(XMLUtils.java:159)
    ...
    Caused by: java.net.UnknownHostException: xxxAnd I need following line to tell WoodStox "please, ignore that DTD":
    xmlif.setProperty(XMLInputFactory.SUPPORT_DTD, false);Now it works... if I switch to JDK 1.6, it works. If I drop Woodstox from classpath, using JDK 1.6 stax impl it stops to work with:
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,10]
    Message: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.So these versions are mutualy exclusive and I can't just compile it once. Not to mention that running the original example (usable with JDK 1.6 Stax Impl but with Woodstox in classpath) on 1.6 ends with stupid messages:
    java.lang.IllegalStateException: Can't overwrite cause
    at java.lang.Throwable.initCause(Throwable.java:320)
    at com.ctc.wstx.compat.Jdk14Impl.setInitCause(Jdk14Impl.java:70)This hardly tells you anything and it's also hard to claim that it is working like on JDK 1.5. ;-) However - here is final version of the code - that works in 1.5 with Woodstox and in 1.6 with both:
    XMLInputFactory xmlif = XMLInputFactory.newInstance();
    if (xmlif.getClass().getName().equals("com.ctc.wstx.stax.WstxInputFactory")) {
    xmlif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
    }
    XMLStreamReader reader = xmlif.createXMLStreamReader(sourceReader);Ok, this is first story... the second one is also interesting. I have line in XML like this:
    prim name="y"[-A-Z0-9.,()/='+:?!"%amp;*; ]/primNow Woodstox has really no problem with it while with JDK 1.6 implementation just doesn't want to eat those entities and I'm pretty out of options how to make THIS working in both implementations. Not to say that I'm not sure which one is right.

    But in this second case Woodstox is winner for me from logical point of view. Why is that interpreted? Why reader.getText() returns only string up to % and stops there? There is no exception in implementation - of course - just my logic stops to work.

    Have anyone run into similar problems?

    Thanks for any hints and tips how to make such a things work in both cases.

    Virgo47

    DB:2.17:Who's Right - Jdk 1.6 Stax Or Woodstox? mm

    As usual, DrClap is correct. Text nodes can be split. Note also that there's a factory property (javax.xml.stream.isCoalescing) that can be used to control that. In most cases, however, I suspect it is faster not to enable this feature.

  • RELEVANCY SCORE 2.16

    DB:2.16:Instantiating An Abstract Class fj


    Hi All,

    As we all know that an abstract class cannot be instantiated. Abstract classes like javax.xml.parsers.DocumentBuilderFactory provides a newInstance() method that returns an object of that class. But when we see the source code of this class, we see that there is no new DocumentBuilderFactory () .

    Can anybody tell me what's exactly happening there to create a new instance of that class. In other words what can be the other way of instantiating an abstract class.

    Thanks in advance.

    DB:2.16:Instantiating An Abstract Class fj

    Hi,

    It doesn't return a subclass. Yes it does.

    As per the Javadoc
    it returns an object of DocumentBuilderFactory.A subclass of X is an X.

  • RELEVANCY SCORE 2.15

    DB:2.15:Stax Problem aa


    Hi,
    I want to Use StAX with JDK1.2 and Onwards.

    So Can anybody tell me that whether I can Use StAX with JDK 1.2/1.3 or not ?

    Thanx in advance

    DB:2.15:Stax Problem aa

    Hi,
    I want to Use StAX with JDK1.2 and Onwards.

    So Can anybody tell me that whether I can Use StAX with JDK 1.2/1.3 or not ?

    Thanx in advance

  • RELEVANCY SCORE 2.14

    DB:2.14:Need Stax Parser For J2me j7


    hi,

    Can Anyone tell me that is there any StAX parser available for J2ME ??

    if yes then please tell me where can i find it's .jar file ?

    Thank You in Advanced.....

    ntimesc.

    DB:2.14:Need Stax Parser For J2me j7

    http://kxml.sourceforge.net/kxml3 may be a good place to start. There are other implementations on the web, free with source code.

  • RELEVANCY SCORE 2.14

    DB:2.14:Re: Classcastexception On Deployment In Weblogic 10.3 fj


    I had the same problem. I was able to resolve it by removing a jar file from my war.

    The CXF release we are using (cxf-2.2.3) comes with a number of other supporting jars. One of them was geronimo-stax-api_1.0_spec-1.0.1.jar. This jar provides the classes in the javax.xml.stream API. However some of the classes in this jar are now part of the java 1.6 jdk. The one causing the problems was XMLInputFactory. WstxInputFactory extends XMLInputFactory2 which extends XMLInputFactory. Apparently the XMLInputFactory provided by the geronimo jar file doesn't match the one that is part of the java 1.6 jdk. This caused the class cast exception.

    By removing the geronimo jar file the application was able to deploy without incident. Our webservice is now running in Weblogic 10.3/jdk 1.6

    DB:2.14:Re: Classcastexception On Deployment In Weblogic 10.3 fj

    Hi,

    As mentioned it worked. I struggled with this exception for more than two weeks and it worked finally with the solution provided.
    Sumary:
    1. Have the weblogic-application.xml instead of weblogic.xml at the web.xml location
    2. Provide the following entry in weblogic-application.xml
    ?xml version="1.0" encoding="UTF-8"?
    weblogic-application xmlns="http://www.bea.com/ns/weblogic/90"
    !-- prefer-application-packages --
    package-namejavax.xml.ws.*/package-name
    package-namejavax.xml.bind.*/package-name
    package-namejavax.jws.*/package-name
    package-namejavax.namespace.xml.*/package-name
    package-namejavax.xml.soap.*/package-name
    package-nameorg.apache.xerces.*/package-name
    package-nameorg.apache.commons.*/package-name
    package-namecom.sun.xml.*/package-name
    container-descriptor
    prefer-web-inf-classestrue/prefer-web-inf-classes
    /container-descriptor
    /weblogic-application

    Thanks a million for all the people who provided me the solution.

  • RELEVANCY SCORE 2.14

    DB:2.14:Java To Xml File Generator ca


    How to generate a nested XML file (I dont need to print it on a console rather wanna save in a file. studied some examples on Stax and DOM), as follows.

    ?xml version="1.0" encoding="UTF-8"?
    *employee*
    officeABC/office
    descriptionIT company/description
    type1/type
    *Clerk*
    nameMr.X/name
    age30/age
    employment2YR/employment
    /*Clerk*
    *Manager*
    nameMr.X/name
    age30/age
    employment12YR/employment
    *duty*/duty
    /*Manager*
    /*employee*

    The main problem is, I can generate it with stax, if there are not multiple tags with different names, that is as the following,

    package Development_input;
    import java.io.FileOutputStream;

    import javax.xml.stream.XMLEventFactory;
    import javax.xml.stream.XMLEventWriter;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.events.Characters;
    import javax.xml.stream.events.EndElement;
    import javax.xml.stream.events.StartDocument;
    import javax.xml.stream.events.StartElement;
    import javax.xml.stream.events.XMLEvent;

    public class StaxWriteruserinfo
    {
    private String configFile;

    public void setFile(String configFile)
    {
    this.configFile = configFile;
    }

    public void saveConfig(String [] info) throws Exception
    {
    // Create a XMLOutputFactory
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();

    // Create XMLEventWriter
    XMLEventWriter eventWriter = outputFactory
    .createXMLEventWriter(new FileOutputStream(configFile));

    // Create a EventFactory
    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    XMLEvent end = eventFactory.createDTD("\n");

    // Create and write Start Tag
    StartDocument startDocument = eventFactory.createStartDocument();
    eventWriter.add(startDocument);

    // Create config open tag
    StartElement configStartElement = eventFactory.createStartElement("",
    "", "User");
    eventWriter.add(configStartElement);
    eventWriter.add(end);
    // Write the different nodes
    createNode(eventWriter, "fullname", info[0]);
    createNode(eventWriter, "username", info[1]);
    createNode(eventWriter, "password", info[2]);
    createNode(eventWriter, "email", info[3]);
    createNode(eventWriter, "mobile", info[4]);
    createNode(eventWriter, "description", info[5]);

    eventWriter.add(eventFactory.createEndElement("", "", "User"));
    eventWriter.add(end);
    eventWriter.add(eventFactory.createEndDocument());
    eventWriter.close();
    }

    private void createNode(XMLEventWriter eventWriter, String name,
    String value) throws XMLStreamException {

    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    XMLEvent end = eventFactory.createDTD("\n");
    XMLEvent tab = eventFactory.createDTD("\t");
    // Create Start node
    StartElement sElement = eventFactory.createStartElement("", "", name);
    eventWriter.add(tab);
    eventWriter.add(sElement);
    // Create Content
    Characters characters = eventFactory.createCharacters(value);
    eventWriter.add(characters);
    // Create End node
    EndElement eElement = eventFactory.createEndElement("", "", name);
    eventWriter.add(eElement);
    eventWriter.add(end);
    }

    DB:2.14:Java To Xml File Generator ca

    I found the solution, made some mistake in looping. so no more answers needed.

    Thanks.

  • RELEVANCY SCORE 2.14

    DB:2.14:Readobject - Newinstance Of Unknown Object's 1k


    I have a Client/Server connection over sockets.

    The server returns different types of Objects. I run the readObject method then, how can I instantiate the received class object ?

    Seems to work fine when the Object is a String class but I receive the following error for java.io.file class:

    java.lang.InstantiationException: java.io.File
    at java.lang.Class.newInstance0(Class.java:293)
    at java.lang.Class.newInstance(Class.java:261)Code Example:

    try {
    Object o = connectionRef.readObject();
    try {
    Class c = Class.forName( new ro.util.string.GetWord(o.getClass().toString(),1).toString() );
    Object co = c.newInstance();

    System.err.println("Built Instance of Class=" + co.getClass().toString() );
    } catch ( Exception e) {
    e.printStackTrace();
    System.exit(1);
    }
    } catch ( Exception e ) {
    e.printStackTrace();
    }Message was edited by:
    RobOsborne

    DB:2.14:Readobject - Newinstance Of Unknown Object's 1k

    I run the readObject method then, how can I instantiate the received class object ?The readObject() method has already done that. You don't have to do anything more.

  • RELEVANCY SCORE 2.14

    DB:2.14:Stax Parser Problems z7


    Hi,

    I am using code(StaX) like so:

    StringBuilder sb = new StringBuilder();
    int attribCount = 0;
    int i;

    try {
    for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next())
    {
    switch (event) {
    case XMLStreamConstants.START_ELEMENT:

    sb.append("" + parser.getLocalName() + " ");
    //read all attributes and append to string
    attribCount = parser.getAttributeCount();
    for(i = 0; i attribCount; i++)
    {
    sb.append(parser.getAttributeName(i).toString() + "= \"" + parser.getAttributeValue(i).toString() + "\" ");
    }

    sb.append("");

    break;
    case XMLStreamConstants.END_ELEMENT:

    //add the ending tag
    sb.append("/" + parser.getLocalName() + "");

    if(parser.getLocalName().equals("param"))
    {
    sb.append("\n");
    }
    if(parser.getLocalName().equals("bindings"))
    return sb.toString();

    break;
    case XMLStreamConstants.CHARACTERS:
    System.out.println("in tag " + parser.getLocalName());
    //if(parser.isCharacters())
    {
    sb.append("~" + parser.getText() + "~");
    System.out.println("chars");
    }

    break;
    case XMLStreamConstants.CDATA:

    break;
    }
    }

    }catch(Exception e)
    {
    JOptionPane.showMessageDialog(null, e.getMessage());
    }

    return sb.toString();

    What this basically does is reconstructs the XML between 2 tags and returns as string.
    As an example, this is the input XML

    bindings
    param name="value"
    value0/value
    /param
    /bindings

    PROBLEM:
    entire XML is reconstructed properly, EXCEPT, the data in between tags, i.e CHARACTERS never show up.
    Also, that particular CASE is never executed.
    What is wrong here?

    Cheers,
    Earlence

    DB:2.14:Stax Parser Problems z7

    If you had posted your code inside the CODE tags, it would be possible to read it, instead of difficult to impossible and requiring guesswork. However I would start by putting something into your case statement which is executed when all of the coded possibilities don't apply. I suspect you'll find that something will be called, so find out what's up with that. What's the value of "event" and so on.

  • RELEVANCY SCORE 2.13

    DB:2.13:Stax Parser With Xpath sd


    Hi,

    I want to use the XPath to get the particular data from XML files.
    The below code i've used to get the data.
    DocumentBuilderFactory domFactory = DocumentBuilderFactory
    .newInstance();
    domFactory.setNamespaceAware(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document doc = builder.parse("persons.xml");
    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression expr = xpath.compile("/information/person");
    Object result = expr.evaluate(doc, XPathConstants.NODESET);
    NodeList nodes = (NodeList) result;
    It is using the DOM parser, but i want to use the StAX parser.
    can you please suggest me how to use StAX parser with XPath?

    Sunrays9

    DB:2.13:Stax Parser With Xpath sd

    jzhang2006 wrote:
    You may want to investigate vtd-xml as the underlying representation for XPath evaluation
    [http://vtd-xml.sf.net|http://vtd-xml.sf.net/]@zhang2006 - please stop flooding the forum with references to vtd-xml. Your responses are getting to be close to being spam. We get the idea that it is the best thing for XML since sliced bread so lay off.

  • RELEVANCY SCORE 2.13

    DB:2.13:Overwriting An Object's Method 39


    I'm trying to overwrite the paint() function of BasicTreeUI, but I don't want to just extend the class, because when I call jtree.getUI() it returns some subclass of BasicTreeUI, for example WindowsTreeUI. What's the best way to do this? I kind of want to do something like this:

    jtree.setUI(jtree.getUI().getClass().newInstance(){
    public void paint(...){
    ...
    }
    });Anyway, the only way I can think of is to extend BasicTreeUI, but delegate every other function call back to the original TreeUI from jtree.getUI(). But I can't really guarantee that I have caught and forwarded all the calls. Is there a better way to do this?

    Thanks in advance.

  • RELEVANCY SCORE 2.13

    DB:2.13:[Playlist] Stax-Volt: The Complete Singles 1959-1968 p7



    All 9Stax-Volt: The Complete Singles 1959-1968disks compiled into one playlist that you can subscribe to! I hope you enjoy. Please take the time to Check out my other playlists as well!

    DB:2.13:[Playlist] Stax-Volt: The Complete Singles 1959-1968 p7


    All 9Stax-Volt: The Complete Singles 1959-1968disks compiled into one playlist that you can subscribe to! I hope you enjoy. Please take the time to Check out my other playlists as well!

  • RELEVANCY SCORE 2.13

    DB:2.13:Stax Parser Misinteprets Xml sx


    I am trying to make a StAX parser to replace the JAXB tree previously used as it used a lot of memory. But unfortunately the new parser seems to fail every time it tries to read a certain of input.

    I have tried to compile a simple piece of code that shows my problem.

    import java.io.*;
    import javax.xml.stream.*;
    import javax.xml.stream.events.*;

    public class XMLReader
    {
    public static void main(String... args)
    {
    try
    {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLEventReader reader = factory.createXMLEventReader(new FileInputStream("stax.xml"));

    while(reader.hasNext())
    {
    XMLEvent event = reader.nextEvent();
    if(event.isStartElement())
    {
    StartElement startElement = event.asStartElement();
    System.out.println(startElement.getName().getLocalPart());
    }
    }
    }
    catch(FileNotFoundException fnfe)
    {
    fnfe.printStackTrace();
    }
    catch(XMLStreamException xmlse)
    {
    xmlse.printStackTrace();
    }
    }
    }The file stax.xml looks like this:
    ?xml version="1.0" encoding="ISO-8859-1"?
    main
    arrlist
    arr
    id4177752/id
    stedK-I-B, Kulturhuset Islands Brygge/sted
    adresseIslands Brygge 18/adresse
    postnr2300/postnr
    postbyKbenhavn S/postby
    datod. 3/12/dato
    slutdato2009-12-03/slutdato
    tidkl. 20.30-23.55/tid
    overskriftLama Impro/overskrift
    beskrivelse/
    kategoriTeater: Anden forestilling/kategori
    logohttp://www.kultunaut.dk/perl/images/stedlogobig/w68h68_1181049.gif/logo
    stedurlhttp://www.kultunaut.dk/perl/sted/type-nynaut?StedNr=1181049/stedurl
    urlhttp://www.kultunaut.dk/perl/arrlist/type-nynaut?periode=Area=ArrNr=4177752/url
    /arr
    /arrlist
    /mainThe output from running the code looks like this:
    main
    arrlist
    arr
    id
    sted
    adresse
    postnr
    postby
    dato
    slutdato
    tid
    overskrift
    beskrivelse
    kategori
    logo
    stedurl
    url
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[18,71]
    Message: The reference to entity "Area" must end with the ';' delimiter.
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588)
    at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:85)
    at XMLReader.main(XMLReader.java:16)The problem is of course the XMLStreamException, but makes the code think that XMLEvent has ended in the middle of an element?

    The XML snippet is only part of larger file that is downloaded from a remote server prior to processing.

    DB:2.13:Stax Parser Misinteprets Xml sx

    Sorry for taking your time, you are absolutely right. And looking closer at the XML prior to download reveals that it is well-formed, the problem must have been masked by the fact that the old parser somehow ignored this.

  • RELEVANCY SCORE 2.13

    DB:2.13:Using Stax With Xslt Transformations In The Right Way? d3


    Hi!

    What do I need to enable the stax functionality to transformations, and which transformer implementations is supporting this? (or is the implementation irrelevant)

    I have made the following to create a StaxSource, but is it enought?
    ---8---
    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    ...
    InputStream xmlInputStream = xmlUrl.openStream();
    XMLStreamReader xmlStreamReader = inputFactory.createXMLStreamReader( xmlInputStream );
    Source xmlSource = new StAXSource( xmlStreamReader );
    ...
    transformer.transform(xmlSource, new StreamResult(writer));
    ---8---I'm using:
    org.apache.xalan.processor.TransformerFactoryImpland every thing seems to work very nice, but I'm not sure if I have done it in the right way and if it's something that I miss.

    If I understand it correct normal transformations is transforming the xml to a Dom-tree but with StAX it shouldn't and be more memory efficient.

    So anyone have any comments?

    /Per

    DB:2.13:Using Stax With Xslt Transformations In The Right Way? d3

    Reading that article once more give me the same impression.

    So, if I want to speedup or optimize my transformation I have to look for other transformation implementations.

    Thanks for your clarifications.

    /perty

  • RELEVANCY SCORE 2.13

    DB:2.13:Class.Forname("Com.Mysql.Jdbc.Driver").Newinstance(); zs


    Hello everybody,

    What does the following line do?

    Class.forName("com.mysql.jdbc.Driver").newInstance();

    Can any one explain me please?

    Thanks

    DB:2.13:Class.Forname("Com.Mysql.Jdbc.Driver").Newinstance(); zs

    You load database drives using Class.forName() to add them to the known drivers list of DriverManager. When you open a connection the known drivers (providing they were loaded by the same classloader as the caller) are each asked whether they accept the URL.

    The driver adds itself to the DriverManager in a static initializer, so the class becomes available as soon as it's initialized.

    Actually Class.forName (unlike ClassLoader.loadClass) does force the class to initialize imediately. So the newInstance() part is unecessary. Someone didn't understand this.

  • RELEVANCY SCORE 2.13

    DB:2.13:Output Encoding For Stax Writer z7


    Hi,

    Can handle StAX automatically the output encoding for the XML? Or must I manually define a PrintWriter with a choosen encoding and set the START DOCUMENT to a corresponding value?

    Thanks,
    Karsten

    DB:2.13:Output Encoding For Stax Writer z7

    Hi,

    Can handle StAX automatically the output encoding for the XML? Or must I manually define a PrintWriter with a choosen encoding and set the START DOCUMENT to a corresponding value?

    Thanks,
    Karsten

  • RELEVANCY SCORE 2.12

    DB:2.12:Java Mapping With Stream Api s1



    Hi,

    Can you please let me know when java mapping with STAX will be supported in Netweaver XI?

    Regards

    Sudhir

    DB:2.12:Java Mapping With Stream Api s1


    Hey Kiran,

    nice material. StAX sure seems a nice tool.

    It's true that PI 7.1 is being developed over Java EE 5. But is that the only request for StAX to be supported?

    Regards,

    Henrique.

  • RELEVANCY SCORE 2.12

    DB:2.12:Included Libraries Conflict -- Nosuchmethoderror 98



    Hi,

    I'm trying to deploy a simple web application to the AS. The application is a web project that I imported from a WAR. The WAR works well on Tomcat v6, i.e. I can deploy it and use the implemented functionality. Furthermore, I can deploy the web project through NWDS to the AS "successfully." However, when testing the functionality I run into the following error:

    #1.5.#003005A1903E003F00000003000009E80204786D9341F444#1207812241254#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#sap.com/Axis2EAR#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#Guest#205####1702a87006cf11ddced7003005a1903e#HTTP Worker [1]##0#0#Error##Plain###Processing HTTP request to servlet [AxisServlet] finished with error. The error is: java.lang.NoSuchMethodError: javax.xml.stream.XMLOutputFactory.newInstance(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljavax/xml/stream/XMLOutputFactory;

    at org.apache.axiom.om.util.StAXUtils.getXMLOutputFactory(StAXUtils.java:97)

    I have checked in several places that the XMLOutputFactory class defining the newInstance method with the above mentioned signature is available. That is, I have checked the "Web App Libraries" that are included in the project's build path and they do include a class with the above mentioned method in a JAR (stax-api-1.0.1.jar). Also, the Axis binaries (I'm using Axis2 v1.1 which corresponds to what the application I'm using to generate the WAR, Apache Muse, uses) that I'm referencing in my NWDS settings also include this JAR.

    Any hints as to how and where a different version of this class gets loaded?

    Cheers,

    Felix

    DB:2.12:Included Libraries Conflict -- Nosuchmethoderror 98


    I've found the old version of the class in a JAR that comes with the AS installation: jsr173_1.0_api.jar. This JAR includes the abstract class, while the implementation is in a JAR called sap.comtcjewebservices_libimpl.jar. How can I make sure that instead of these JARs, the WAR is packaged such that it uses the JARs that are in the project's build path?

    Thank you for your help in advance.

    Cheers,

    Felix

  • RELEVANCY SCORE 2.12

    DB:2.12:Xml Debatching In Bpel!! 1k


    hi all,

    if we use XML Debatching to handle large XML Documents with in BPEL,and stax parser.. wat will be the memory usage and impact on the system??

    regards,
    karthik

    DB:2.12:Xml Debatching In Bpel!! 1k

    The link provided earlier in the thread addresses this

    In 10.1.3.4 there is new features to manage GB of data when inputs and outputs are file/FTP

    http://download.oracle.com/docs/cd/E12524_01/relnotes.1013/e12523/adapters.htm#CHDHJGHG

    cheers
    James

  • RELEVANCY SCORE 2.12

    DB:2.12:Xmlstreamreader --≫ Inputstream Of Plain Xml m3


    Is there any code ready to use a StAX XMLStreamReader to produce plain XML?

    My case is that I have a StAX reader that I try to connect to legacy code which expects an InputStream with XML in it. I guess this would be easy to implement, if had code that used a StAX reader to copy an XML document to the output, as-is. I'm not experienced in StAX and not confident that I could write code that would work for any kind of XML.

    I searched the web for examples that do this, but found none. Most examples are just showing how to check for some specific events, or just read them and print them, but don't provide a mapping from the events back to xml.

    Any ideas or pointers? I was pretty confident that such a utility should exist somewhere out there...

    DB:2.12:Xmlstreamreader --≫ Inputstream Of Plain Xml m3

    Is there any code ready to use a StAX XMLStreamReader to produce plain XML?

    My case is that I have a StAX reader that I try to connect to legacy code which expects an InputStream with XML in it. I guess this would be easy to implement, if had code that used a StAX reader to copy an XML document to the output, as-is. I'm not experienced in StAX and not confident that I could write code that would work for any kind of XML.

    I searched the web for examples that do this, but found none. Most examples are just showing how to check for some specific events, or just read them and print them, but don't provide a mapping from the events back to xml.

    Any ideas or pointers? I was pretty confident that such a utility should exist somewhere out there...

  • RELEVANCY SCORE 2.12

    DB:2.12:Xml Element To String Conversion Returning Null d8


    Hi,

    When i try to convert XML Element to string using toString() API, it returns something like [device: null] where device is element tag.

    Code is as follows -

    Document xmlDoc;
    DOMParser parser = (DOMParser)Class.forName("org.apache.xerces.parsers.DOMParser").newInstance();
    parser.setFeature( "http://apache.org/xml/features/dom/defer-node-expansion", true );
    parser.parse(new InputSource(new StringReader(tableStr)));
    xmlDoc = parser.getDocument();

    Element root = xmlDoc.getDocumentElement();
    NodeList nodeList = root.getElementsByTagName("device");
    Element deviceNode = (Element)nodeList.item(nodeList.getLength()-1);
    System.out.println(deviceNode.toString()); //prints [device: null] ????
    System.out.println(deviceNode.getAttribute("ipAddress")); //prints correct ip address

    Any idea why i am getting [device: null] when trying to convert Element to String though attribute value is retrieved.

    Thanks,
    Deepak

    DB:2.12:Xml Element To String Conversion Returning Null d8

    Hello ,

    I want to get the root node (ZTOP60_XML_TAG_STRUCTURE
    ) of the following xml file .

    ?xml version="1.0" encoding="utf-8"?
    ZTOP60_XML_TAG_STRUCTURE
    MSGTYPENAPOBACK/MSGTYPE
    SNDPRN657393485/SNDPRN
    RECEIVER/
    RCVPRNGSOHUBDM1/RCVPRN
    PONUM/
    VENDCODE0020040266/VENDCODE
    VENDUNS002601768/VENDUNS
    PARTNERFUNC_WEWE/PARTNERFUNC_WE
    PARTNERNUM_WEC240/PARTNERNUM_WE
    LINE_ITEMS
    item
    ITEMNUM00687/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY7.000/GRQTY
    NETVAL339.65/NETVAL
    PLANTC240/PLANT
    MATNUMFE-26865-01/MATNUM
    MATDESCPTR, T632, LEXMARK 5-BIN MAILBOX/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00178/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY303.000/GRQTY
    NETVAL18.62/NETVAL
    PLANTC240/PLANT
    MATNUMFE-ZZYRG-01/MATNUM
    MATDESCFDD,FDI-PC,1.44MB,3.5 ,HH/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00157/ITEMNUM
    POQTY999999998.000/POQTY
    BOQTY24.000/BOQTY
    GRQTY303.000/GRQTY
    NETVAL26.25/NETVAL
    PLANTC240/PLANT
    MATNUMFE-25094-01/MATNUM
    MATDESCMOUSE,PC,3BUT,,INTELLIMOUSE,PS2/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00881/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY62.000/GRQTY
    NETVAL368.80/NETVAL
    PLANTC240/PLANT
    MATNUMFD-66515-01/MATNUM
    MATDESCITU MODULE ASM/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00223/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY377.000/GRQTY
    NETVAL459.28/NETVAL
    PLANTC240/PLANT
    MATNUMFD-65336-01/MATNUM
    MATDESCMAIN SYSTEM BOARD T23 (2647)/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00081/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY19.000/BOQTY
    GRQTY810.000/GRQTY
    NETVAL217.21/NETVAL
    PLANTC240/PLANT
    MATNUMFD-64199-01/MATNUM
    MATDESCQST- CADET 100/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00271/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY136.000/GRQTY
    NETVAL813.76/NETVAL
    PLANTC240/PLANT
    MATNUMFD-60065-01/MATNUM
    MATDESCSMART UPS 3000VA RM/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00791/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY3.000/GRQTY
    NETVAL201.73/NETVAL
    PLANTC240/PLANT
    MATNUM3X-PBXGG-AA/MATNUM
    MATDESCATI 7500 PCI GRAPHICS/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00173/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY32.000/GRQTY
    NETVAL7.50/NETVAL
    PLANTC240/PLANT
    MATNUM12-56178-01/MATNUM
    MATDESCCARD GUIDE,SNAP-IN,LOW PROFILE,2.5 INCHE/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00309/ITEMNUM
    POQTY999999998.000/POQTY
    BOQTY15.000/BOQTY
    GRQTY71.000/GRQTY
    NETVAL51.23/NETVAL
    PLANTC240/PLANT
    MATNUM30-51476-01/MATNUM
    MATDESCVHDI-CABLE WIDE 12 FT. DT-AB001-TQ/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    item
    ITEMNUM00194/ITEMNUM
    POQTY999999999.000/POQTY
    BOQTY1.000/BOQTY
    GRQTY147.000/GRQTY
    NETVAL345.48/NETVAL
    PLANTC240/PLANT
    MATNUM29-33689-01/MATNUM
    MATDESCPTR,IMP9,B/W,PAR/SER,110/240,R/MATDESC
    PONUMBER6500022388/PONUMBER
    EKGRPU17/EKGRP
    DISPON07/DISPO
    /item
    /LINE_ITEMS
    /ZTOP60_XML_TAG_STRUCTURE

    I wrote the following lines of code ..
    FTI .. String strMsg =((javax.jms.TextMessage)msg).getText();
    StrMsg is a string that represents an xml file .

    DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = docfactory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(new StringReader(strMsg)));
    Element root = doc.getDocumentElement();
    System.out.println("The root is " + root);
    String strFileName = root+".xml" ;
    System.out.println("The file name is " + strFileName);
    File f = new File (strFileName);
    FileOutputStream fos = new FileOutputStream( f );
    for ( int j =0 ; j strMsg.length(); j++)
    {

    char c = strMsg.charAt(j);

    fos.write((int)c);

    }

    I am getting the following error ...

    The root is [ZTOP60_XML_TAG_STRUCTURE: null]
    The file name is [ZTOP60_XML_TAG_STRUCTURE: null].xml

    Whey the file name or root is with special character [ ] and null ..

    I want just ZTOP60_XML_TAG_STRUCTURE.xml .

    Can anyone help me .

    thanks
    mahesh

  • RELEVANCY SCORE 2.12

    DB:2.12:Stax, Jboss5.1.0ga, Jdk6. 9s



    I deployed a war app that depends on StAX, but when I start the app I get no such method error:

    java.lang.NoSuchMethodError: javax.xml.stream.XMLInputFactory.newFactory()Ljavax/xml/stream/XMLInputFactory;

    Only changes I have made to JBoss5.1.0 is copying the 4 webservice jars from /client to /lib/endorsed like the manual says for use with java 6.

    How do I provide stax support for the app?

    DB:2.12:Stax, Jboss5.1.0ga, Jdk6. 9s


    To answer myself. The woodstox stax impl shipped with jboss5.1.0ga only supports the depricated XMLInputFactory.newInstance() but not the new XMPInpuFactory.newFactory(). I tried replacing wstx.jar with a newer v.4.0.8 but it does not add support for the new factory method either. So I changed my code to use the old newInstance(). The stax impl shipped with jdk 6 does support the new factory method.

  • RELEVANCY SCORE 2.12

    DB:2.12:This Forum Is More Popular ??? Xml Encoding In Sax &Amp; Stax cf


    http://forum.java.sun.com/thread.jspa?threadID=778345

    hello i want to change the

    ?xml version='1.0' encoding='ISO-8859-1'? in the xmlwriter ...

    does anybody know,???

    thx

    DB:2.12:This Forum Is More Popular ??? Xml Encoding In Sax &Amp; Stax cf

    It's not so much about popularity - it's more about hanging out where one's strengths are.

  • RELEVANCY SCORE 2.12

    DB:2.12:Re: How To Prevent Stax From Converting \R\N To \N 9p


    Thanks for the clarification.

    I didn't realize the 2.11 recommendation applied to CDATA.

    Is there a recommended way to include the characters \r followed by \n within CDATA, such that the parser returns \r\n?

    Similarly, is there a recommended way to include the character \r within CDATA, such that the parser returns \r?

    DB:2.12:Re: How To Prevent Stax From Converting \R\N To \N 9p

    Since the data does contain whitespace. and since XML CDATA is the required format, I'll go with choice 1.

    It still seems surprising that CDATA doesn't have a formal escape mechanism, particularly because white space is so common within character data. Even so, it's easy to add my own for this purpose.

    Thanks again for your help on this question.

  • RELEVANCY SCORE 2.11

    DB:2.11:Xml Encoding d8


    Hi

    i'm using
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
    XMLStreamWriter streamWriter = factory.createXMLStreamWriter(arrayOutputStream);to write my xml document.
    I have a problem on the character , i have an encoding exception like byte 1 of 1 is not UTF-8.
    How i can set the right encoding?
    Is better to set it on the xmlstream or on the string to write?
    I try some encoding but i still have the problem

    DB:2.11:Xml Encoding d8

    Hi guys!

    Thanks very much for your help!
    I specify the encoding as Gregory said and works fine.

    Thanks!

  • RELEVANCY SCORE 2.11

    DB:2.11:How To Escape Special Characters While Writing Xml With Stax a7


    I couldn't escape the special characters while writing xml with StAX. I am using BEA/Oracle implementation (com.bea.core.weblogic.stax_1.9.0.0.jar) on Weblogic10.3.5
    e.g. character

    public static void main(String[] args) throws XMLStreamException {
    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    XMLEventWriter writer = outputFactory.createXMLEventWriter(System.out);
    writer.add(eventFactory.createStartDocument());
    writer.add(eventFactory.createStartElement("", null, "test", null, null));
    writer.add(eventFactory.createCharacters("test special characters and "));
    writer.add(eventFactory.createEndElement("", null, "test"));
    writer.add(eventFactory.createEndDocument());
    writer.flush();
    }

    produces the below output
    ?xml version='1.0' encoding='UTF-8'?testtest special characters amp; and /test

    If I try escaping with apache StringEscapeUtils.escapeXml(), StAX XMLEventWriter double escapes the apache escaped amp;#228 to amp;amp;#228;
    ?xml version='1.0' encoding='UTF-8'?testtest special characters amp;amp;amp; and amp;amp;#228; /test

    I also tried disabling the default escaping of XMLEventWriter by setting the property javax.xml.stream.isEscapingCharacters; but setting this property has no effect.
    outputFactory .setProperty("javax.xml.stream.isEscapingCharacters", Boolean.FALSE);

    Please can anyone help me.

    Edited by: user8870888 on Feb 1, 2013 9:57 AM

    Edited by: user8870888 on Feb 1, 2013 9:59 AM

    DB:2.11:How To Escape Special Characters While Writing Xml With Stax a7

    I couldn't escape the special characters while writing xml with StAX. I am using BEA/Oracle implementation (com.bea.core.weblogic.stax_1.9.0.0.jar) on Weblogic10.3.5
    e.g. character

    public static void main(String[] args) throws XMLStreamException {
    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    XMLEventWriter writer = outputFactory.createXMLEventWriter(System.out);
    writer.add(eventFactory.createStartDocument());
    writer.add(eventFactory.createStartElement("", null, "test", null, null));
    writer.add(eventFactory.createCharacters("test special characters and "));
    writer.add(eventFactory.createEndElement("", null, "test"));
    writer.add(eventFactory.createEndDocument());
    writer.flush();
    }

    produces the below output
    ?xml version='1.0' encoding='UTF-8'?testtest special characters amp; and /test

    If I try escaping with apache StringEscapeUtils.escapeXml(), StAX XMLEventWriter double escapes the apache escaped amp;#228 to amp;amp;#228;
    ?xml version='1.0' encoding='UTF-8'?testtest special characters amp;amp;amp; and amp;amp;#228; /test

    I also tried disabling the default escaping of XMLEventWriter by setting the property javax.xml.stream.isEscapingCharacters; but setting this property has no effect.
    outputFactory .setProperty("javax.xml.stream.isEscapingCharacters", Boolean.FALSE);

    Please can anyone help me.

    Edited by: user8870888 on Feb 1, 2013 9:57 AM

    Edited by: user8870888 on Feb 1, 2013 9:59 AM

  • RELEVANCY SCORE 2.11

    DB:2.11:Field Variable Null After Instantiation Using Newinstance kp


    Hi, I'm instantiating an object using newInstance in the Constructor class. In the constructor, I'm setting a few field variables. But these values immediately become null again when I check it right after instantiation. The weird thing is, this only happens when the default value of these field variables is null (so '= null' but when I remove that, it remembers the new value). Let me show some code to illustrate:

    public class StateHandler extends Handler {
    protected byte[] data = null;
    public StateHandler(String bla) {
    // code here
    data = new byte[20];
    }

    public byte[] getData() {
    return data;
    }
    }When I create an instance of the above class, the data array is null again after creating it with newInstance. But when I remove the '= null' part, it somehow remembers the data. I.e., when I have it like the following, it works fine:

    public class StateHandler extends Handler {
    protected byte[] data;
    public StateHandler(String bla) {
    // code here
    data = new byte[20];
    }

    public byte[] getData() {
    return data;
    }
    }(now data still exists after instantiation). Does anyone know why this could be happening? This happens in several places and I'm wondering why the field variables become null again. The newInstance method returns an Object and I'm casting it to Handler. Then, I use the following check to see what data is:

    handler = (Handler) constructors.newInstance(args);
    if (handler instanceof StateHandler) {
    StateHandler test = (StateHandler) handler;
    System.out.println(test.getData() == null);
    }

    Thanks.

    DB:2.11:Field Variable Null After Instantiation Using Newinstance kp

    Have you ever tried calling the constructor the normal way? I've never heard of any newInstance() quirk that would cause this kind of problem. I suspect your parseData() method is relying on instance variables that haven't been set yet. If you set the variable in the superclass constructor, then call a method in the subclass that accesses that variable, that method won't see the newly-set value. If it's the parameter "bla" that you're parsing, try sending it to the parseData() method directly. You may not even need to store the string itself.

  • RELEVANCY SCORE 2.10

    DB:2.10:Stax Error When Executing Vmmark2-Stax.Bat - Stax Service Not Registered cd



    Hello,

    Is there anything I need to do to register the STAX service? I am running the prime client on Windows Server 2008 R2?

    - In the benchmark guide, the StaxEngine section was pretty short - it just had me copy a bunch of files to a service folder, but there were no steps to 'install' any components, so I am wondering if maybe something was left out there?

    I have followed the Benchmarking guide very closely, and rechecked the steps for the STAX install, but I am not seeing anything I missed. Here is where I am at:

    - I have the OLIODB/ WebClient/DS2DB/DS2Web workloads finished and online

    - I have the Client configured as Client0/ as well as a Prime Client with all components installed per the guide

    I did not get any errors during any of the installation steps, so everything should be set to get the first run going.

    I started the VMMark2-STAX.bat file

    - A splash screen for VMMark comes up - no errors there

    - Then, Stax starts up, and the first thing i get is an error message:

    - STAX Service Not Registered

    - STAX Service Machine: Local

    - STAX Service Name: STAX

    Warning: the STAX service is not registered on the specified machine.

    Verify the STAX monitors properties

    I am still able to get in and set the parameters for submitting the job, but it fails to run and I am assuming it is because of this first error. Is there anything special I need to do to register the STAX service?

    DB:2.10:Stax Error When Executing Vmmark2-Stax.Bat - Stax Service Not Registered cd


    Hey! I figured it out. The staf.cfg file was the culprit. I entered the modifications exactly as written in the guide. The issue was, in the guide they used slashes to break it down into multiple lines for readability. But it was erroring on that so I put it back to a single line and now it starts without any errors.

    Thanks for your help on this - if you had not pointed me to the config file in the first place, I wouldn't have known where to start

    -Don

  • RELEVANCY SCORE 2.10

    DB:2.10:Stax Service Not Registred 87



    I had a problem while opening the STAX wizard. I follow all the steps mentioned in the guide and i had this problem.What slhoud i do?? The error is in this pic

    DB:2.10:Stax Service Not Registred 87


    Answered in this thread

    http://communities.vmware.com/message/2060172#2060172

  • RELEVANCY SCORE 2.10

    DB:2.10:Re: Reading Xml File a8


    If i'm not wrong, JDOM's cpu and memory is not as efficient as SAX and StAX right? I need one that is efficient in cpu and memory.

    DB:2.10:Re: Reading Xml File a8


    http://www.c-sharpcorner.com/UploadFile/mahesh/Reading

    XmlFile11142005002137AM/ReadingXmlFile.aspxAny reason you're posting links to C# sites in reply
    to Java questions?... And a pretty sh?tty article at that.

  • RELEVANCY SCORE 2.10

    DB:2.10:Classloader c9


    I have extended the ClassLoader class and overwritten the findClass method, instantiated the new ClassLoader and called loadClass(name) on it
    This returns a class object and on this i call newInstance and I get hold of an Object reference

    Then I try to typecast to the runtime type and an NoClassDefFoundError is cast. Why is that? I was under the impression that the runtime class was loaded.

    Michel

    DB:2.10:Classloader c9

    Okay that is also what I thought, but is it not
    possible somehow to tell the system class loader to
    call my class loader. You already do that.

    A class is defined by the class name and the loader that loaded it. If the loaders are different then the class is different.

    So if the system loader loads it, it is a different class.

  • RELEVANCY SCORE 2.10

    DB:2.10:Can Class.Forname("Someclassname").Newinstance() Work In All Classes? ad


    I saw some classes don't have a method called "newInstance()".

    but I have seen some advices say that is better using "Class.forName().newInstance()" than using "Class.forName()".

    DB:2.10:Can Class.Forname("Someclassname").Newinstance() Work In All Classes? ad

    I saw some classes don't have a method called
    "newInstance()".If you have class Foo, and you do Class.forName("Foo").newInstance();you're not calling Foo's newInstance method. You're calling java.lang.Class' newInstance method. You have a Class object that represents the Foo class. You tell that Class object newInstance() which invokes the public no-arg constructor of class Foo (as if you had done new Foo()). If Foo doesn't have a public no-arg constructor, you'll get an exception.

    but I have seen some advices say that is better using
    "Class.forName().newInstance()" than using
    "Class.forName()".They do two completely different things, and Class.forName().newInstance() first does Class.forName() and then class newInstance() on what that returns.

    Class.forName("Foo") returns the Class object that is associated with class Foo. It also loads the class if it hasn't already been loaded. It returns an instance of java.lang.class

    newInstance() calls the public, no-arg ctor of that class, if that ctor exists. Otherwise it throws an exeption. If it succeeds, it returns an instance of Foo.

  • RELEVANCY SCORE 2.10

    DB:2.10:Createxmlstreamreader Does Not Throw Xmlstreamexception c7


    Hello,

    I'm trying to parse with StAX an xml document with a filter. When the xml document is correct, everything is OK.
    But when the xml document is not correct (for example, strDocument = "HELOOOOOOOOOOOOOOOO!!!!!"), the
    createXMLStreamReader does not throw a XmlStreamException.

    This is part of my code:
    public String parse(String strDocument, ErrorCodeFilter ecf) throws ProxyServletException
    {
    XMLInputFactory xif = null;
    XMLStreamReader xsr = null;

    try
    {
    xif = this.getXMLInputFactory();
    xsr = xif.createFilteredReader(xif.createXMLStreamReader(new StringReader(strDocument)), ecf);

    // Si hay un evento encontrado, es que hemos devuelto 'true' desde el 'filter'.
    return (ecf.getValue());
    }
    catch (XMLStreamException xse) { throw new ProxyServletException(GenericConstants.PARSER_PARSE, xse); }
    catch (ProxyServletException pse) { throw new ProxyServletException(GenericConstants.RESPONSE_IDENTIFICATION, pse); }
    finally
    {
    if (xif != null) this.parserStAX.offer(xif);
    if (xsr != null)
    {
    try { xsr.close(); xsr = null; } catch (XMLStreamException xse) {}
    }
    }
    }Looking at JDK code, I've seen the following:

    public XMLStreamFilterImpl(XMLStreamReader reader,StreamFilter filter){
    this.fStreamReader = reader;
    this.fStreamFilter = filter;
    fCachedAttributes = new ArrayList();
    fCachedNamespaceAttr = new ArrayList();
    try{
    if(!fStreamFilter.accept(fStreamReader)){
    next();
    cache();
    }

    }catch(XMLStreamException xs){
    System.err.println("Error while creating a stream Filter"+xs);
    }
    //fCachedEventType = fStreamReader.getEventType();
    fCurrentEventType = fStreamReader.getEventType();
    if(DEBUG)
    System.out.println("Cached Event"+fCachedEventType);
    }The XMLStreamFilterImpl constructor catch the XmlStreamException, but it does not throw it.

    Is this the expected behaviour, or it's a bug?

    My platform is Linux Red Hat ES 3, and java 1.6.0-b105.

    Thanks in advance,

    Joan.

    DB:2.10:Createxmlstreamreader Does Not Throw Xmlstreamexception c7

    Hello,

    No no ... I've been working with java many years ... I'm just wondering why the constructor caught and forgotten the exception. Yes, as you say the call to next() throws the exception. Perfect. I solved my problem, let me explain you why I was going crazy with XMLStreamReader.

    When you create the streamReader with the filter, automatically the filter 'accept' method is called (before any next() execution), and the event type is 'StartDocument'. But my filter always returns false unless it finds the element that it's looking for. Then, if I don't return true in 'StartDocument' event, and the document is not valid, no next() event is executed because the filter doesn't find the matching element. With this situation, a non valid xml document does not throw any exception.

    Just returning true in 'StartDocument' event solved my problem.

    Many thanks,

    Joan.

  • RELEVANCY SCORE 2.10

    DB:2.10:Jsr-173: Streaming Api For Xml (Stax) js



    http://www.jcp.org/en/jsr/detail?id=173

    "The Streaming API for XML (StAX) is a Java based API for pull-parsing XML."

    BEA is the spec lead.

    DB:2.10:Jsr-173: Streaming Api For Xml (Stax) js


    http://www.jcp.org/en/jsr/detail?id=173

    "The Streaming API for XML (StAX) is a Java based API for pull-parsing XML."

    BEA is the spec lead.

  • RELEVANCY SCORE 2.10

    DB:2.10:Declaring A Variable Using Class Object. 9d


    Say I use getClass() on a runtime-unknown object, and it returns me an Oojemaflip class. I can instantiate one of these with newInstance(), but as far as I can figure out I can only type it to Object, i.e., Object ooj = oojClass.newInstance(), when what I want is to say Oojemaflip ooj = oojClass.newInstance(), but obviously I need some other way of doing it.

    Does anyone know if it's possible to do this?

    Peace out.

    DB:2.10:Declaring A Variable Using Class Object. 9d

    Thanks guys. I did search first but I think it's a difficult topic to pick out keywords for, butthead.. or something/butthead. I was kind of expecting that I was attempting something bogus, and I'm sure it originates from a design prob.

    Cheers.

  • RELEVANCY SCORE 2.10

    DB:2.10:Stax Problem 9z



    I had a very strange issue, when i add the 2 lines to STAF.cfg i obtain the error : STAX Job Monitor v3.4.5 requires STAF v3.3.3 or later to be running and when i omit these lines the stax wizard appears but i return to a main problem: STAX Service Not Registred....

    Any Suggestions????????

    DB:2.10:Stax Problem 9z


    ok i review all config edited i found a mispelled word too...10xxx i run stax from cmd without this diagnostics and the job runs properly...Lara

  • RELEVANCY SCORE 2.09

    DB:2.09:Oc4j 10.1.2.0.2, Xfire, Stax And Jdk 1.4.2 9k


    Has anyone implemented Web Services using OC4J 10.1.2, xFire, StAX, and JDK 1.4.2.x? If so can you provide an outline of the steps or refer to a good example? What is the advantage of using StAX?

    DB:2.09:Oc4j 10.1.2.0.2, Xfire, Stax And Jdk 1.4.2 9k

    Has anyone implemented Web Services using OC4J 10.1.2, xFire, StAX, and JDK 1.4.2.x? If so can you provide an outline of the steps or refer to a good example? What is the advantage of using StAX?

  • RELEVANCY SCORE 2.09

    DB:2.09:Factory Pattern m9


    Hi All,

    I have one question:

    Factory pattern, is to create objects based on the class name passed.

    But, in DocumentBuilderFactory there is a method newInstance(), this returns the object of DocumentBuilder. This method doesn't take any arguments also.

    DocumentBuilder objDoc = DocumentBuilderFactory.newInstance();

    Question is:
    why is that, there is not a provision to instantiate directly the DocumentBuilder, when the above code is always going to give the object of DocumentBuilder.

    Kindly clarify...

    Thanks
    AMJ

    DB:2.09:Factory Pattern m9

    Hi All,

    Thanks for your response.

    The point i understood here is:
    DocumentBuilderFactory
    It's been designed to create objects from a single source.

    is that right?

    Thaks All.......

  • RELEVANCY SCORE 2.09

    DB:2.09:Error While Reading Clob From Oracle Using Weblogic Connection Pool, Works Fine With Out Using Pool fz


    PROBLEM DESCRIPTION :

    When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
    This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.

    IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.

    Below Please find the JAVA CODE for Both Working and NON Working .

    Created a Connection Pool as:

    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver

    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):

    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();

    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):

    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();

    ERROR MESSAGE:

    ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

    DB:2.09:Error While Reading Clob From Oracle Using Weblogic Connection Pool, Works Fine With Out Using Pool fz

    PROBLEM DESCRIPTION :

    When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
    This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.

    IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.

    Below Please find the JAVA CODE for Both Working and NON Working .

    Created a Connection Pool as:

    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver

    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):

    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();

    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):

    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();

    ERROR MESSAGE:

    ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

  • RELEVANCY SCORE 2.09

    DB:2.09:How To Check Resultset Returns No Rows? 19


    I got the following error when the query returns no row.

    javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Invalid cursor state

    Here is the code:(the query is a test query that returns 0 row).
    -------------------------------------------------------------------------------------------------
    %@page language="java" import="java.sql.*"%
    %@ include file="ar.jsp" %
    %
    Driver Driverrs = (Driver)Class.forName(MM_ar_DRIVER).newInstance();
    Connection Connrs = DriverManager.getConnection(MM_ar_STRING,MM_ar_USERNAME,MM_ar_PASSWORD);
    String sql ="select entry_id from ar_system where entry_id 0";
    PreparedStatement Statementrs = Connrs.prepareStatement(sql);
    ResultSet rs = Statementrs.executeQuery();
    %
    Entry ID is: %=rs.getString("entry_id")%
    %
    rs.close();
    Connrs.close();
    %
    ----------------------------------------------------

    Anybody has any clue? Thanks much in advance!

    DB:2.09:How To Check Resultset Returns No Rows? 19

    I change my code as below, still got error. Did you try your code on your system? Is there something wrong with what I am doing?

    org.apache.jasper.JasperException: Unable to compile class for JSPC:\jakarta-tomcat-3.2.1\work\localhost_8080%2Fbotao\_0002ftest_0002ejsptest_jsp_31.java:86: 'return' with value from void _jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
    return null;

    --------------------------------------------------------------------------------------------------------
    %@page language="java" import="java.sql.*"%
    %@ include file="ar.jsp" %
    %
    Driver Driverrs = (Driver)Class.forName(MM_ar_DRIVER).newInstance();
    Connection Connrs = DriverManager.getConnection(MM_ar_STRING,MM_ar_USERNAME,MM_ar_PASSWORD);
    String sql ="select entry_id from ar_system where entry_id 0";
    Statement Statementrs = Connrs.createStatement();
    ResultSet rs = Statementrs.executeQuery(sql);
    if (rs == null)
    {
    return null;
    }
    else
    {
    out.println(rs.getString("entry_id"));
    }
    rs.close();
    Connrs.close();
    %

  • RELEVANCY SCORE 2.09

    DB:2.09:Starting The Stax Monitor On The Prime Client kx



    Start the STAX Monitor on the prime client: " java -jar C:\STAF\services\stax\STAXMon.jar "

    On running the above command at the command prompt of the Prime Client, i am getting the below error..

    C:\STAF\services\staxjava -jar STAXMon.jar

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no JSTAF in java.libary.path

    at java.lang.ClassLoader.loadLibrary(Unknown Source)

    at java.lang.Runtime.loadLibrary0(Unknown Source)

    at java.lang.System.loadLibrary(Unknown Source)

    at com.ibm.staf.STAFHandle.clinit(STAFHandle.java:100)

    at com.ibm.staf.service.stax.STAXMonitorUtil.getNewSTAFHandle(STAXMorUtil.java:52)

    at com.ibm.staf.service.stax.STAXMonitor.init(STAXMonitor.java:502

    at com.ibm.staf.service.stax.STAXMonitor.main(STAXMonitor.java:5520)

    suggestions please ...

    DB:2.09:Starting The Stax Monitor On The Prime Client kx


    I have reinstalled the STAF.

    But still there is no 'lang' directory under STAF

    C:\STAF\data\STAF

    Also no 'log' under:

    C:\STAF\data\STAF\service

    Thanks,

    Sajal.

  • RELEVANCY SCORE 2.09

    DB:2.09:Xsl:Output Method="Text" Does Output Escaping When Using Stax And Xslt fd


    I am using Stax and XSLT for transforming a xml document to a sql file. The jave code for doing the same is given below. This code is based on what is given in the site http://javaboutique.internet.com/tutorials/staxxsl/index3.html. The xsl file I have uses xsl:output method = "text" /. The xml I have for transfromation has special characters like "" inside CDATA sections. In the output sql file (the result of transformation) these special characters are output escaped. They appear as "". Though the site http://www.w3.org/TR/xslt says "The text output method ignores the disable-output-escaping attribute, since it does not perform any output escaping", I can see that the special characters are output escaped. Please let me know what should I do so that these special characters appears as is (i.e. as "" only and not as "") in the output file. Is this a bug in the StaxSource/StaxResult API ?

    XMLInputFactory inputFactory=null;
    XMLOutputFactory outputFactory=null;
    XMLStreamReader streamReaderXSL=null;
    XMLStreamReader streamReaderXML=null;
    XMLStreamWriter streamWriter=null;
    BufferedWriter fileWriter=null;
    Writer out = null;
    Transformer transf=null;
    String xml = script.toXML();
    String xmlWithPrologue = "?xml version=\"1.0\" encoding=\"UTF-8\"?" + xml;
    System.out.println("xml generated is "+xmlWithPrologue);

    try{
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(xmlFileCompletePath));
    out = new OutputStreamWriter(bos, ApplicationConstants.UTF8_FILE_ENCODING);
    out.write(xmlWithPrologue);
    out.flush();
    //get an instance of the XMLInputFactory class
    inputFactory=XMLInputFactory.newInstance();

    //get an instance of the XMLOutputFactory class
    outputFactory=XMLOutputFactory.newInstance();

    //set three properties for the XMLInputFactory
    inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities",Boolean.TRUE);
    inputFactory.setProperty("javax.xml.stream.isNamespaceAware",Boolean.TRUE);
    inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences",Boolean.FALSE);

    //get the XMLEventReader objects
    FileInputStream xslFis = new FileInputStream(xsltemplateCompletePath);
    InputStreamReader xslIsr = new InputStreamReader(xslFis, ApplicationConstants.UTF8_FILE_ENCODING);
    streamReaderXSL=inputFactory.createXMLStreamReader(xsltemplatePath, xslIsr);
    FileInputStream xmlFis = new FileInputStream(xmlFileCompletePath);
    InputStreamReader xmlIsr = new InputStreamReader(xmlFis, ApplicationConstants.UTF8_FILE_ENCODING);
    streamReaderXML=inputFactory.createXMLStreamReader(xsltemplatePath, xmlIsr);
    File file = new File(xmlFileCompletePath);
    file.delete();
    }catch(java.io.FileNotFoundException e) {
    e.printStackTrace();
    }catch(javax.xml.stream.XMLStreamException e) {
    e.printStackTrace();
    }catch(java.io.IOException e) {
    e.printStackTrace();
    }

    //get a TransformerFactory object
    TransformerFactory transfFactory=TransformerFactory.newInstance();

    //define the Source object for the stylesheet
    Source XSL=new StAXSource(streamReaderXSL);

    //get a Transformer object
    try{
    transf=transfFactory.newTransformer(XSL);
    }catch(javax.xml.transform.TransformerConfigurationException e)
    {
    e.printStackTrace();
    }

    //define the Source object for the XML document
    Source XML=new StAXSource(streamReaderXML);

    //create an XMLStreamWriter object
    try {
    FileOutputStream fosScript = new FileOutputStream(generatedscriptCompletePath);
    //OutputStreamWriter outScript = new OutputStreamWriter(fosScript, ApplicationConstants.UTF8_FILE_ENCODING);
    streamWriter=outputFactory.createXMLStreamWriter(fosScript, ApplicationConstants.UTF8_FILE_ENCODING);
    //streamWriter=outputFactory.createXMLStreamWriter(outScript);
    } catch(java.io.IOException e) {
    e.printStackTrace();
    } catch(javax.xml.stream.XMLStreamException e) {
    e.printStackTrace();
    }

    //define the Result object
    Result XML_r=new StAXResult(streamWriter);

    //call the transform method
    try {
    transf.transform(XML,XML_r);
    } catch(javax.xml.transform.TransformerException e) {
    e.printStackTrace();
    }

    //clean up
    try {
    streamReaderXSL.close();
    streamReaderXML.close();
    streamWriter.close();
    out.close();
    } catch(javax.xml.stream.XMLStreamException e) {
    e.printStackTrace();
    } catch(java.io.IOException e) {
    e.printStackTrace();
    }

  • RELEVANCY SCORE 2.09

    DB:2.09:Start Staf Error fj



    Hi

    When I edit the staf.cfg follow the vmmark guide

    "

    service stax library JSTAF execute C:\STAF\services\stax\STAX.jar OPTION \

    DB:2.09:Start Staf Error fj


    Hi

    When I edit the staf.cfg follow the vmmark guide

    "

    service stax library JSTAF execute C:\STAF\services\stax\STAX.jar OPTION \

  • RELEVANCY SCORE 2.09

    DB:2.09:Vmmapping Error 38



    I had the following error attached in the pic while running STAX Job Monitor. The content of ClusterVMmapping.txt is :

    VMmark 2 PowerCLI : 1.11

    DB:2.09:Vmmapping Error 38


    My cluster was named New Datacenter but in VMmapping file it didnt takes the space into consideration and in the first result the name of the cluster was understood "New" and not "New Datacenter" so i had to rename it "NewDatacenter"

  • RELEVANCY SCORE 2.09

    DB:2.09:How To Avoid Type Cast When Using Newinstance() ? 13


    hello:

    I want to dynamically create an instance of a class based on the class name and call the methods on that instance, the simple code follows:

    public void doIt(String className)
    {
    Class aClass=Class.forName(className);

    aClass.newInstance().aMethod();
    /* this won't work because aClass.newInstance() returns a type of Object, I have to do some downcasting to call the methods of the created instance*/

    }

    Is there anyway to avoid the downcasting?

    Thanks for any help, your input is highly appreciated !

    DB:2.09:How To Avoid Type Cast When Using Newinstance() ? 13

    Thank you. Looks like reflection is the way I should go.

  • RELEVANCY SCORE 2.09

    DB:2.09:Class Literal fx


    Animal a = (Animal) Dog.class.newInstance();
    I can use an array to save Dog.class like this:
    String[] aa = {Dog.class, Cat.class}
    so the above becomes:
    Animal a = (Animal)aa[0].newInstance();
    If I retrieve Dog.class and Cat.class from database, these are String. How to use a String to represent Dog.class?
    Animal a = (Animal)"Dog".getClass().newInstance();//wrong
    "Dog".getClass() returns "java.lang.String"

    DB:2.09:Class Literal fx

    The OP wanted to instantiate class MyTest$Test1, but Class's newInstance()
    failed, which lead me to suspect it was failing because, although Test1
    may have defined what looked like a no-arg constructor:
    ...
    public Test1() {}
    ...what was happening was that Test1 was an inner class, and
    so instantiation required a reference to a MyTest object. In such
    a case, talking about a no-arg constructor misses the point. The point,
    in the end, was the difference in code demonstrated in my reply #4

  • RELEVANCY SCORE 2.09

    DB:2.09:Weblogic9.2 Upgradation To Java1.6 cz


    Hi,

    We have a requirement to upgrade from java1.5 to java1.6 for webogic9.2(64 bit) on solaris5.10 (version 10).
    Please can any one suggest Weblogic9.2 will support java1.6 ? (We are facing the Exception on startup : XMLInputFactory)

    DB:2.09:Weblogic9.2 Upgradation To Java1.6 cz

    http://download.oracle.com/docs/cd/E13196_01/platform/suppconfigs/configs92/92_over/overview.html#1122259 Here ion this Page Click On your Operating System Link....you will find the Next Page like this:

    http://download.oracle.com/docs/cd/E13196_01/platform/suppconfigs/configs/windows2003/win2003_92.html
    Please search for supported "JDK" in above link.

  • RELEVANCY SCORE 2.09

    DB:2.09:Creating Xml From A Pojo Using Stax cm


    Hi Experts,

    I have a POJO and now want to create an XML which has the elements as that of the POJO using StAX.

    Can anybody please help me out.

    Thanks in advance.

    DB:2.09:Creating Xml From A Pojo Using Stax cm

    swati_pekam wrote:
    Yes I totally agree with you, had initially used JAXB....however client needs StAX to be used.. :(What? Why?

    Do you mean "client" as in "client side program"?
    In that case, the requirement is bullshit, because the receiving end of the XML doesn't know which technology is used to create it.

    Do you mean "client" as in "the people who pay me to do that"?
    In that case, the requirement is bullshit, because they should not force you to use tools that are not fit for the task ..

    Please clarify this requirement. Why exactly do you think (or does the client think) that you need to use StAX?

  • RELEVANCY SCORE 2.09

    DB:2.09:Exclude Xmlsec And Xalan z8



    AS 7.1.1.

    I'm experiencing a version incompatibility between the XMLSEC (Santuario) and XALAN libraries used by Jboss. The error comes at the point where XMLSEC attempts to instatiate an XpathContext object. The XpathContext, in urn, has a private DTMManager which is being created by newInstance(). The newInstance returns an instance of org.apache.xml.dtm.ref.DTMManagerDefault which canot be cast to org.apache.xml.dtm.DTMManager. The XMLSecurityRuntimeException forgets to mention the original cause of ClassCastException.

    So, I'd rather use my own versions of XMLSEC and XALAN. I saw how JBoss uses it's own version of XMLSEC. It even replaces the version incorporated into the JDK. Here is the snippet from definition of javaee.api

    module name="org.apache.santuario.xmlsec" export="true"exportsinclude-setpath name="javax/xml/crypto"/path name="javax/xml/crypto/dom"/path name="javax/xml/crypto/dsig"/path name="javax/xml/crypto/dsig/dom"/path name="javax/xml/crypto/dsig/keyinfo"/path name="javax/xml/crypto/dsig/spec"//include-set
    /exports
    /module

    I read the advice given at https://community.jboss.org/message/637818

    So, I tried my hand. In jboss-deployment-structure.xml I excluded the XmlSec used by Jboss

    jboss-deployment-structure

    deployment

    exclusions

    module name="org.apache.xalan" /

    module name="org.apache.santuario.xmlsec"/

    /exclusions

    dependencies

    module name="javaee.api"

    imports

    exclude-set

    path name="org.apache.santuario.xmlsec"/

    /exclude-set

    /imports

    /module

    /dependencies

    /deployment

    /jboss-deployment-structure

    For some reason, it did not work. I can still see in the stack trace xmlsec.1.5.1 which is the JBoss version

    Regards,

    Andrew

    DB:2.09:Exclude Xmlsec And Xalan z8


    We had a similar issue, related to xmlsec and also tried the options described in https://community.jboss.org/message/637818.

    Did not work at first.

    The class that was causing the issue is loaded using "Thread.currentThread().getContextClassLoader()". It turns out that during startup of the JBoss server, the "Thread.currentThread().getContextClassLoader()" does not contain the application classloader but rather a classloader from another JBoss module. So the "jboss-deployment-structure.xml" did not help here, as it only influences the application classloader (AFAIK).

    At redeploy it does work as expected, the "Thread.currentThread().getContextClassLoader()" contains the application classloader. So redeploying our application after startup also solved the issue.

    To fix it, I replaced the contextClassLoader in a bootstrap class:

    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

    try {

    Thread.currentThread().setContextClassLoader(XXXBootstrap.class.getClassLoader());

    initializeXMLSecurity();

    initializeXMLTooling(_xmlToolingConfigs);

    ...

    } finally {

    Thread.currentThread().setContextClassLoader(contextClassLoader);

    }

  • RELEVANCY SCORE 2.09

    DB:2.09:Jdbc-Odbc Limitations 18


    I am trying to execute a very simple piece of SQL on an MS Access table...

    ...
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ).newInstance();
    cnn = DriverManager.getConnection( url, user, password );
    Statement stmt = cnn.createStatement();

    upd = "INSERT INTO someTable ( Field1, Field2 ) VALUES ( 1, 'Some
    value' ) ;";
    stmt.executeUpdate( upd );
    ...

    This works fine, but this one...

    ...
    upd = "INSERT INTO someTable ( Field1, Field2 ) VALUES ( 1, 'Some
    value' ), ( 2, 'Some value' ) ;";
    ...

    ...returns the following error...

    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Missing
    semicolon (;) at end of SQL statement.

    Is it a limitation of the jdbc-odbc bridge that only one record can be
    inserted at a time?

    Thanks for any help.

    DB:2.09:Jdbc-Odbc Limitations 18

    upd = "INSERT INTO someTable ( Field1, Field2 )
    ) VALUES ( 1, 'Some
    value' ) ;";Remove the semi-colon in the string.

    upd = "INSERT INTO someTable ( Field1, Field2 )
    ) VALUES ( 1, 'Some
    value' ), ( 2, 'Some value' ) ;";That simply isn't valid SQL. Re-write it.

  • RELEVANCY SCORE 2.09

    DB:2.09:Using Stax jf


    Hi everyone,

    I'm trying to find out if the J2 SDK supports Stax out of the box.

    So far it seems, that even Java 5 only supports DOM and SAX.

    Is this correct?

    Thanks in advance,
    Paulo Pinto

    DB:2.09:Using Stax jf

    Yes, I think StAX will become part of the Java platform in Java 6.0 (Mustang). WSDP 1.6 includes an EA implementation.

  • RELEVANCY SCORE 2.09

    DB:2.09:Stax Api Java5 Rt.Jar Conflict zs



    Hi All,I'm using;Jboss 4.2.3.GAJava 1.5.0_06Jboss ships with stax-api.jar that contains an XMLConstants class. This class conflicts with a class of the same name in the jvm rt.jar.For some reason Eclipse IDE is picking up the stax-api.jar first, flagging a compile error. This class does not contain the constant I have referenced in my code.How do I get around this. I thought I could simply remove the jar from my classpath. However I then receive further errors.This would suggest to me that stax-api.jar shipped with JBoss and Java 5 or 6 are incompatible!I would have expected to see many more posts regarding this issue!How do I get round this?

    DB:2.09:Stax Api Java5 Rt.Jar Conflict zs


    Hi All,I'm using;Jboss 4.2.3.GAJava 1.5.0_06Jboss ships with stax-api.jar that contains an XMLConstants class. This class conflicts with a class of the same name in the jvm rt.jar.For some reason Eclipse IDE is picking up the stax-api.jar first, flagging a compile error. This class does not contain the constant I have referenced in my code.How do I get around this. I thought I could simply remove the jar from my classpath. However I then receive further errors.This would suggest to me that stax-api.jar shipped with JBoss and Java 5 or 6 are incompatible!I would have expected to see many more posts regarding this issue!How do I get round this?

  • RELEVANCY SCORE 2.09

    DB:2.09:Some Help With Mysql Fetch Size zk


    To get the number of rows returned by a MySQL query, I do this:

    public static void main(String[] args) throws Exception
    {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection connection = DriverManager.getConnection(url, user, password);
    Statement statement = connection.createStatement();
    String query = "SELECT * FROM users";
    ResultSet rs = statement.executeQuery(query);

    int number = statement.getFetchSize();
    connection.close();
    System.out.print(number);
    }which returns 0 even though I have 7 users. What am I doing wrong?

    DB:2.09:Some Help With Mysql Fetch Size zk

    Jamwa wrote:
    Anyway my main aim was not only to get the results, but in case I got no results returned then I tell the user that via a JOptionPane.It's not clear to mean what you are trying to do:

    1. If all you want to know is the number of rows in the table, or whether or not the table is empty, use the SELECT COUNT(*) query -- very easy.
    2. If you want to retrieve row data from the table, and display a message in the special case of no data, load the data from each row into a User object
    and accumulate these objects in a ListUser. When you are done you can check if list.isEmpty()

  • RELEVANCY SCORE 2.08

    DB:2.08:Invoking A Method (Known At Runtime) On A Class (Also Known At Runtime) ff


    Hello,

    Here's a queer problem that I'm facing. I need to call a method on an object - the caveat being that both the method name and class name of the object are known only at runtime.

    I've been using Reflection and trying out the following code:

    // The class instantiated can be just about anything and does not
    // necessarily implement any known interfaces
    System.out.println("Going to instantiate class "+className);

    Method method;
    Object newInstance;
    Object[] arguments;
    Class newClass;
    Class[] parameterTypes;

    try {
    newClass = Class.forName(className);
    newInstance = newClass.newInstance();
    parameterTypes = new Class[] {String.class};
    arguments = new Object[] {};
    }
    catch (Exception e) {
    throw new CommandExecutorException("Unable to create instance of class "+className, e);
    }

    System.out.println("Going to call method "+commandName);
    try {
    method = newClass.getMethod(commandName, parameterTypes);
    // I assume that the method I call will always return a String
    String s = (String)method.invoke(newInstance,arguments);
    System.out.println(s);
    }
    catch (Exception e) {
    throw new CommandExecutorException("Unable to invoke method " + commandName, e);
    }

    When I run this, I get the following output (I try to invoke the method GetName on class Namer here):

    Going to instantiate class Namer
    Going to call method GetName
    java.lang.NoSuchMethodException
    at java.lang.Class.getMethod0(Native Method)
    at java.lang.Class.getMethod(Class.java:888)
    at CommandExecutor.executeCommand(CommandExecutor.java:54)
    at main3.main(main3.java:42)

    I suspect the problem to be because once I create an instance of the class, I have no clue what to typecast it to, to I take it as an Object.
    And the Object class does not have any method called GetName that returns a String.

    Any ideas ??

    DB:2.08:Invoking A Method (Known At Runtime) On A Class (Also Known At Runtime) ff

    Sorry guys, that was a stupid Cut-n-paste error - just managed to get it working now and the error was in the line:

    parameterTypes = new Class[] {String.class};

    because of which the code was looking for GetName(String) instead of GetName()

    Thanks for all who looked at it...

  • RELEVANCY SCORE 2.08

    DB:2.08:How To Install Staf/Stax On Esxi? 9j



    How to Install STAF on ESXi ? I know this can be done .. Even I have used it. but does not know the step by step process ...

    DB:2.08:How To Install Staf/Stax On Esxi? 9j


    Is Workbench 2.0 available to download? Any pointers would be highly appreciated.

    Thanks.

  • RELEVANCY SCORE 2.07

    DB:2.07:Stax Problem On Weblogic 8.1.6 3x


    Hi I have following problem on weblogic with streaming xml parsing:

    We have spring context with parsers deployed as backend for EJBs. All parsers work flawlessly in standalone tests but after being deployed on WLS they throw this exception:

    java.lang.NoSuchMethodError: init
    at com.bea.xml.stream.AttributeBase.init(AttributeBase.java:49)
    at com.bea.xml.stream.XMLEventAllocatorBase.getAttributes(XMLEventAllocatorBase.java:59)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocateStartElement(XMLEventAllocatorBase.java:91)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocate(XMLEventAllocatorBase.java:227)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocate(XMLEventAllocatorBase.java:251)
    at com.bea.xml.stream.XMLEventReaderBase.parseSome(XMLEventReaderBase.java:198)
    at com.bea.xml.stream.XMLEventReaderBase.nextEvent(XMLEventReaderBase.java:126)

    we are using
    stax 1.2
    stax-api 1.0.1

    help !

    DB:2.07:Stax Problem On Weblogic 8.1.6 3x

    Hi I have following problem on weblogic with streaming xml parsing:

    We have spring context with parsers deployed as backend for EJBs. All parsers work flawlessly in standalone tests but after being deployed on WLS they throw this exception:

    java.lang.NoSuchMethodError: init
    at com.bea.xml.stream.AttributeBase.init(AttributeBase.java:49)
    at com.bea.xml.stream.XMLEventAllocatorBase.getAttributes(XMLEventAllocatorBase.java:59)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocateStartElement(XMLEventAllocatorBase.java:91)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocate(XMLEventAllocatorBase.java:227)
    at com.bea.xml.stream.XMLEventAllocatorBase.allocate(XMLEventAllocatorBase.java:251)
    at com.bea.xml.stream.XMLEventReaderBase.parseSome(XMLEventReaderBase.java:198)
    at com.bea.xml.stream.XMLEventReaderBase.nextEvent(XMLEventReaderBase.java:126)

    we are using
    stax 1.2
    stax-api 1.0.1

    help !

  • RELEVANCY SCORE 2.07

    DB:2.07:The Point Of .Newinstance() k7


    Hi folks,

    Correct me if I'm wrong, but wasn't the idea of declaring a class as "abstract" to keep people from creating instances of that class? Sort of creating an interface?

    I just happened to stumble across an example in the xml-tutorial that told me to implement this

    factory = SAXParserFactory.newInstance();line of code. Never having heard of this method, I tried to call the constructor using

    factory = new() SAXParserFactory;I was told that SAXParserFactory was abstract, hence could not be instanciated. But the API reveals that the method newInstance()

    Returns:
    A new instance of a SAXParserFactory

    just like the name suggested it would... Where's the catch? I don't get it! Please explain to me the idea of having two calls do the same thing and to stop one of them doing it!?! What am I missing?

    DB:2.07:The Point Of .Newinstance() k7

    Hi folks,

    Correct me if I'm wrong, but wasn't the idea of
    declaring a class as "abstract" to keep people from
    creating instances of that class? Sort of creating an
    interface?

    I just happened to stumble across an example in the
    xml-tutorial that told me to implement this

    factory = SAXParserFactory.newInstance();line of code. Never having heard of this method, I
    tried to call the constructor using

    factory = new() SAXParserFactory;I was told that SAXParserFactory was abstract, hence
    could not be instanciated. But the API reveals that
    the method newInstance()

    Returns:
    A new instance of a SAXParserFactory

    just like the name suggested it would... Where's the
    catch? I don't get it! Please explain to me the idea
    of having two calls do the same thing and to stop one
    of them doing it!?! What am I missing?The method newInstance() in SAXParserFactory is static and is not abstract. Abstract classes can have fully implemented instance and static methods so this is not an unusual thing to see.
    What happens is that you actually get an implementation of SAXParserFactory returned.
    Check it out by calling
    System.out.println("Class of impl returned = " + SAXParserFactory.newInstance().getClass().getName() ):

  • RELEVANCY SCORE 2.07

    DB:2.07:Reflection Inconsistency 7a


    1.
    Byte.TYPE.getName(); returns "byte";

    2.
    new byte[]{}.getClass().getName() returns "[B".
    Why not "[byte" ?
    It wouldn't get confused with an array of objects of a class called byte, as this would return "[Lbyte"

    [b]3.
    Class.forName("byte"); //and
    Class.forName("B"); Both choke. Why? I thought there was a Class object whose name was "byte". I can understand why newInstance() would choke, but that should come later. With that class object I may want to run "isPrimitive()" or "getName()" on them which make perfect sense.

    4.
    Why should Class.getPrimitiveClass() be private? Why isn't it's functionality implemented in the forName() method?

    Why these inconsistencies?

    DB:2.07:Reflection Inconsistency 7a

    1.
    Byte.TYPE.getName(); returns "byte";There is a difference between Byte the wrapper class and byte the primitive data type. Here you are asking for the name of the primitive data type byte which is "byte".

    2.
    new byte[]{}.getClass().getName() returns
    "[B".
    Why not "[byte" ?
    It wouldn't get confused with an array of objects of a
    class called byte, as this would return "[Lbyte"
    Again, you are asking for the name of the class that represents the primitive type byte. This is NOT the same as asking for the wrapper class Byte. [b3.Class.forName("byte"); //and
    Class.forName("B"); Both choke. Why? I thought there was a Class
    object whose name was "byte". I can understand why
    newInstance() would choke, but that should come later.
    With that class object I may want to run
    "isPrimitive()" or "getName()" on them which make
    perfect sense.

    There is no class named "byte" or "B". To get the wrapper class, use Class.forName("Byte"); //note the capital BNot sure why you would want to load a class for byte (the datatype) since it is NOT a class.

    4.
    Why should Class.getPrimitiveClass() be private? Why
    isn't it's functionality implemented in the forName()
    method?Not sure, but think about this. If Class.getPrimitiveClass() were public and you called that on a Vector or any other class that does not have a primitive representation, what whould you expect to happen? Remember, wrapper classes are special classes used to wrap primitive types when you absoultely mush have an object (for example if you wish to hold a collection of numbers in a Vector).

    Why these inconsistencies?Perhaps maybe it's more of an inconsistant understanding on your part. This stuff can get a little tricky.

    Hope all this helps.

  • RELEVANCY SCORE 2.07

    DB:2.07:Stax To Sax pp



    All,

    Does anybody know of an StAX to SAX converter, so that given a StAX implementation
    , I can generate a SAX stream to pass to a ContentHandler and LexicalHandler of
    an existing SAX application.

    The basics are not all that difficult to implement, but it gets trickier with
    e.g. namespaces.

    Thanks,

    Peter

    DB:2.07:Stax To Sax pp

    Hi Peter,

    Not sure, but I've entered CR172373 to pass this enhancement request
    along to our engineering team.

    Thanks for the feedback,
    Bruce

    Peter Coppens wrote:

    All,

    Does anybody know of an StAX to SAX converter, so that given a StAX implementation
    , I can generate a SAX stream to pass to a ContentHandler and LexicalHandler of
    an existing SAX application.

    The basics are not all that difficult to implement, but it gets trickier with
    e.g. namespaces.

    Thanks,

    Peter

  • RELEVANCY SCORE 2.07

    DB:2.07:Urgent - Query On Stax 1x


    Hi All,

    I started learning and working with STAX- api (Iterator)
    My requirement is providing the implementation to the methods like

    writeElement
    writeStartElement

    How can i use STAX inorder to implement the above methods.
    Also can anyone provide the implementation classes for the interfaces in the STAX-api.jar (source code)

    Thanks in Advance.

    DB:2.07:Urgent - Query On Stax 1x

    Hi All,

    I started learning and working with STAX- api (Iterator)
    My requirement is providing the implementation to the methods like

    writeElement
    writeStartElement

    How can i use STAX inorder to implement the above methods.
    Also can anyone provide the implementation classes for the interfaces in the STAX-api.jar (source code)

    Thanks in Advance.

  • RELEVANCY SCORE 2.07

    DB:2.07:Xml Stream Api And Cdata d9


    I'm parsing this file with a XMLEventReader, and I never have a Characters event which isCData() returns true.
    ?xml version="1.0" encoding="utf-8"?
    mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    mx:Script
    ![CDATA[
    [ Embed("file0.mp3") ]
    public var file0:Class;
    ]]
    /mx:Script
    mx:Fade id="showApplication" alphaFrom="0" alphaTo="1" duration="2000"/
    /mx:ApplicationI used jdk1.6 or jdk1.5 with stax 1.2.0, and both don't manage to warn me that there's a CDATA section.
    I tried a tip dealing with the property report-cdata-event, but this property is not recognized.
    Is it possible to configure a XMLEventReader to report CDATA content?

    DB:2.07:Xml Stream Api And Cdata d9

    The best handling of CDATA is found not in SAX or StAX, but in VTD-XML...
    since it is non-extractive parsing, it is fully preserved in its original byte content

  • RELEVANCY SCORE 2.07

    DB:2.07:Difference Between Stax 1.2.0 And Jdk 1.6 Implementation 1a


    Hello,

    I'm using Stax to write an XML document. I noticed that there's a difference between stax 1.2.0 and the jdk 1.6 implementation while writing a StartDocument event:
    in jdk 1.6, it writes :
    ?xml version="1.0"?and in jdk 1.5 with stax 1.2.0, it writes the same event like :
    ?xml version='1.0' encoding='UTF-8'?The differences are about the single/double quotes and the encoding presence.

    I would like to know if it's possible to have the same behaviour in both jdk? Which version of Stax must I use in jdk 1.5 to have the same result than in jdk 1.6?

    DB:2.07:Difference Between Stax 1.2.0 And Jdk 1.6 Implementation 1a

    Then this is a requirement outside of XML, since XML says it doesn't matter. So you will have to do something outside of XML to prepare your data for the non-conforming XML parser. Post-processing the document might work.

  • RELEVANCY SCORE 2.07

    DB:2.07:How To Order Xml File With Stax? kd


    Hello everyone,
    I am trying to write a program in Java that order by one XML File for some criteria (like order by statement in SQL Language). I need to use StAX because i use very large XML files and memory-based APIs can't handle big xml files. I am thinking to implement QuickSort Algorithm but when i am looking to StAX API (cursor-based API) i didn't see a method like event.previous or something that can replace/delete or move one XML node. My question is: Is possible to navigate through nodes in a XML File and delete/insert/move the nodes between other nodes without loading them to memory using StAX?

    Best Regards,
    Bruno Oliveira

    DB:2.07:How To Order Xml File With Stax? kd

    So what EPJ suggests is quite true: the sorting of large volumes of data externally is the way to go. But perhaps the data you need to sort isn't actually that large a volume. You cannot keep all nodes in memory because of the 16M JPEG in each of them, but the 20.000 file names that you actually sort on easily can. So you take a multi pass approach: read in the XML first to harvest the sort keys, sort in memory, then traverse the XML file multiple times to output the nodes according to the sorted order. You can reduce the number of passes in the output file by adding some smart buffering or multiple files that can be merged later.

  • RELEVANCY SCORE 2.07

    DB:2.07:Bug In Commportidentifier.Getportidentifiers() cc


    Hi,

    CommPortIdentifier.getPortIdentifiers()
    From java communications API, when called again returns resultset twice. After each successive invokation it keeps adding the ports to the last result set.

    Here is the test code:

    //////////////////////////////////////////

    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }

    ////////////////////////////

    Every call to listPorts keep adding machine port list to the last result set.

    Any idea what's going on? Is this a bug?

    I am trying the same logic in an Applet. Even if I call listPorts from applet init method, it still has the same problem.import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }
    import javax.comm.*;
    import java.util.Enumeration;

    public class Test {

    public static String listPorts() {

    System.out.println("listPorts Called");

    String drivername = "com.sun.comm.Win32Driver";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    drivername = "javax.comm.*";
    try
    {
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
    }
    catch (Throwable th)
    {
    // Discard it
    }

    StringBuffer portList = new StringBuffer("");
    Enumeration ports =
    CommPortIdentifier.getPortIdentifiers();
    int portCount = 0;
    while (ports.hasMoreElements()) {
    portCount++;
    CommPortIdentifier port =
    (CommPortIdentifier)ports.nextElement();
    String type;
    switch (port.getPortType()) {
    case CommPortIdentifier.PORT_PARALLEL:
    type = "Parallel";
    break;
    case CommPortIdentifier.PORT_SERIAL:
    type = "Serial";
    break;
    default: /// Shouldn't happen
    type = "Unknown";
    break;
    }
    // System.out.println(port.getName() + ": " + type);
    portList.append(port.getName() + ": " + type + " ");
    }
    System.out.println("portCount="+portCount);
    System.out.println(portList.toString());
    return portList.toString();
    }

    public static void main(String[] args) {
    listPorts();
    listPorts();
    listPorts();
    listPorts();
    }
    }

    //////////////////////////////////////////

    The program prints ports for the first call and then keeps adding the ports to the result set for each successive call to listPorts from main.

    I am trying to run this from an applet. If I put the same code inside applet init method. I get the same behavior between page loads. Looks like it's per JVM invocation.

    Any help is appreciated.

    Thanks,
    Prashant Rane

    DB:2.07:Bug In Commportidentifier.Getportidentifiers() cc

    Each call to initialise will add its ports to the commportidentifier. This is how its supposed to work, as each driver is only supposed to be initialized once.

    Why don't you follow the examples on the javax.comm pages?
    http://java.sun.com/products/javacomm/javadocs/API_users_guide.html

  • RELEVANCY SCORE 2.07

    DB:2.07:Factoryconfigurationerror When I Try To Do Xmloutputfactory.Newinstance() fm


    I am trying to run a test program from my model that assembles an XML stream to be sent as a message to another process. To create the XML stream I have the following code:

    XMLOutputFactory factory = XMLOutputFactory.newInstance(); // Here is where the exception happens
    return factory.createXMLStreamWriter (getXmlStream()); // (returns a bytearrayoutputstream I created earlier)Unfortunately here I get the following:

    Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
    at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
    at web.rlm.controller.rm.Synchronization.newXmlWriter(Synchronization.java:86)
    at web.rlm.controller.rm.Synchronization.refreshOpn(Synchronization.java:136)
    at web.rlm.controller.rm.Synchronization.refreshOpns(Synchronization.java:127)
    at web.rlm.controller.rm.Synchronization.main(Synchronization.java:114)Can anyone shed some light on this?

    DB:2.07:Factoryconfigurationerror When I Try To Do Xmloutputfactory.Newinstance() fm

    I am trying to run a test program from my model that assembles an XML stream to be sent as a message to another process. To create the XML stream I have the following code:

    XMLOutputFactory factory = XMLOutputFactory.newInstance(); // Here is where the exception happens
    return factory.createXMLStreamWriter (getXmlStream()); // (returns a bytearrayoutputstream I created earlier)Unfortunately here I get the following:

    Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
    at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
    at web.rlm.controller.rm.Synchronization.newXmlWriter(Synchronization.java:86)
    at web.rlm.controller.rm.Synchronization.refreshOpn(Synchronization.java:136)
    at web.rlm.controller.rm.Synchronization.refreshOpns(Synchronization.java:127)
    at web.rlm.controller.rm.Synchronization.main(Synchronization.java:114)Can anyone shed some light on this?

  • RELEVANCY SCORE 2.07

    DB:2.07:Help On Creating Chart 8k



    I need some help on creating chart as shown in the attachment.I want the sum of field(stax_amount) to be displayed below the field stax.

    for example

    s.no stax stax_amount

    1 10 100

    2 20 200

    3 30 300

    sum 600 600

    here the sum of stax_amount gets displayed equivalent to the field stax.

    DB:2.07:Help On Creating Chart 8k


    Dear Rajamani,

    It cannot be done however you create a Text Object below the chart and you can use sum(stax_amount) there.

    Hope this helps you.

  • RELEVANCY SCORE 2.07

    DB:2.07:At New In Smartform xp



    Hi all,

    I have a internal table, in that there are the following fields
    STAX
    SNO
    NAME
    NOINV

    I want to write a header text when AT NEW STAX* is triggred. how to achive this
    in smartforms.

    DB:2.07:At New In Smartform xp


    method.

    loop u r final itab.

    put one more field in itab with text----,

    whenever at first is triggered , u pas the text data to this field, other wise you pass null data.

    endloop.

    in the text/cell ,call that text field directly.

    THIS MAY HELP YOU OUT.

    OK

  • RELEVANCY SCORE 2.07

    DB:2.07:I Use The Newest Version Jdbc, But Still Return No Suitable Driver Error sz


    Hi. I am using the following statements to connect my SQL Server 2005 database:              Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver).newInstance();              con = DriverManager.getConnection(jdbc:sqlserver:172.16.0.5//:1433;              DatabaseName=Security, pasw, pasw);These code works for couple months, and later on, it returns java.sql.SQLException: No suitable driver Error.Then I download the jdbc driver from MS for SQL Server 2005, but it still return such errors.

    DB:2.07:I Use The Newest Version Jdbc, But Still Return No Suitable Driver Error sz

    Also, here is one sample way to connect using SQL 2005 driver:
      Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);  Connection conn = DriverManager.getConnection(jdbc:sqlserver://MySQLServer;user=MyUser;password=MyPassword;databaseName=MyDatabase;);  

  • RELEVANCY SCORE 2.07

    DB:2.07:Stax Reference Implementation mc



    In the following piece of code everything works as expected until I have an xml
    element that is
    structured in the following way. element/ The "accept" method is notified
    of the
    START_ELEMENT but it never receives notification of the END_ELEMENT. Am I missing

    something or is there a bug?

    XMLInputFactory factoryI= XMLInputFactory.newInstance();
    XMLStreamReader streamReader = factory.createXMLStreamReader((InputStream)
    p.inputStream);
    XMLStreamReader filteredStreamReader = factory.createFilteredReader(streamReader,
    new StreamFilter() {
    boolean accept = true;

    public boolean accept(XMLStreamReader reader) {
    switch (reader.getEventType()) {
    case XMLStreamConstants.START_ELEMENT:
    System.out.println("start: " + getUriName(reader));
    break;
    case XMLStreamConstants.END_ELEMENT:
    System.out.println("stop: " + getUriName(reader));
    break;
    }
    }
    return accept;
    }
    });

    DB:2.07:Stax Reference Implementation mc


    SOLVED! the character offset position is the same for START and STOP element
    "Frank" fwalinsky@extol.com wrote:

    In the following piece of code everything works as expected until I have
    an xml
    element that is
    structured in the following way. element/ The "accept" method is
    notified
    of the
    START_ELEMENT but it never receives notification of the END_ELEMENT.
    Am I missing

    something or is there a bug?

    XMLInputFactory factoryI= XMLInputFactory.newInstance();
    XMLStreamReader streamReader = factory.createXMLStreamReader((InputStream)
    p.inputStream);
    XMLStreamReader filteredStreamReader = factory.createFilteredReader(streamReader,
    new StreamFilter() {
    boolean accept = true;

    public boolean accept(XMLStreamReader reader) {
    switch (reader.getEventType()) {
    case XMLStreamConstants.START_ELEMENT:
    System.out.println("start: " + getUriName(reader));
    break;
    case XMLStreamConstants.END_ELEMENT:
    System.out.println("stop: " + getUriName(reader));
    break;
    }
    }
    return accept;
    }
    });

  • RELEVANCY SCORE 2.07

    DB:2.07:Urgent Help: Invalid Cursor State d1


    I got the following error when the query returns no row.

    javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Invalid cursor state

    Here is the code:
    -------------------------------------------------------------------------------------------------
    %@page language="java" import="java.sql.*"%
    %@ include file="ar.jsp" %
    %
    Driver Driverrs = (Driver)Class.forName(MM_ar_DRIVER).newInstance();
    Connection Connrs = DriverManager.getConnection(MM_ar_STRING,MM_ar_USERNAME,MM_ar_PASSWORD);
    String sql ="select entry_id from ar_system where entry_id 0";
    PreparedStatement Statementrs = Connrs.prepareStatement(sql);
    ResultSet rs = Statementrs.executeQuery();
    %
    Entry ID is: %=rs.getString("entry_id")%
    %
    rs.close();
    Connrs.close();
    %
    ----------------------------------------------------

    Anybody has any clue? Thanks much in advance!

    DB:2.07:Urgent Help: Invalid Cursor State d1

    The above solution is the correct one. However, I don't see that anyone answered the question as to WHY you were getting the error. The reason you were getting an invalid cursor state is because you weren't calling .next() at all. When you get back a result set, the cursor is above row 1. You have to call .next() to move the cursor to the first row of results.

  • RELEVANCY SCORE 2.07

    DB:2.07:Need Help In Use Of Xmlresolver Resolveentity Method xp


    Hi,

    I have implemented the XMLResolver interface and set the resolver to XMLInputFactory.setXMLResolver method.
    But when i try to execute the below program it throws exception.
    Below is the code. Could anyone guide me how to proceed ...

    ---Main java file ---------
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.InputStream;

    import javax.xml.stream.XMLInputFactory;
    import javax.xml.stream.XMLResolver;
    import javax.xml.stream.XMLStreamConstants;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamReader;

    public class ResolverTest {

    static String testPrefix = "JAXBSD";
    static String testNo = "002";
    static String testID = testPrefix + testNo;

    /**
    * @param args
    */
    public static void main(String[] args) {

    XMLInputFactory xmlif = XMLInputFactory.newInstance();
    xmlif.setXMLResolver(new XMLResolverAdapter(xmlif));

    InputStream inputStream;
    try {

    File file = new File(testNo + "/XMLResolverTest.xml");
    String systemId = file.toURI().toString() ;
    System.out.println("------"+systemId);

    inputStream = new FileInputStream(file);

    XMLStreamReader streamReader = xmlif.createXMLStreamReader(systemId,inputStream);

    while(streamReader.hasNext()){
    int eventType = streamReader.next() ;
    if(eventType == XMLStreamConstants.START_ELEMENT){

    eventType = streamReader.next() ;
    System.out.println("---4---");
    if(eventType == XMLStreamConstants.CHARACTERS){
    String text = streamReader.getText() ;
    System.out.println("-----------hey i got it replace entity----------------------------"+ text);
    }
    }
    }
    } catch (XMLStreamException e) {
    System.out.println("-----XMLStreamException-------"+ e.getMessage());
    }catch(Exception e)
    {
    System.out.println("-----Exception-------"+ e.getMessage());
    }
    }
    }

    class XMLResolverAdapter implements XMLResolver {

    private final XMLInputFactory inputFactory;
    String testNo = "002";
    public XMLResolverAdapter(XMLInputFactory inputFactory ) {
    this.inputFactory = inputFactory;

    }

    public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) throws XMLStreamException {

    InputStream inputStream;
    try {
    inputStream = new FileInputStream(new File(testNo + "/replace2.txt"));
    } catch (FileNotFoundException e) {
    throw new XMLStreamException(e.getMessage());
    }
    return inputFactory.createXMLStreamReader(inputStream);
    }
    }

    ---------------------------------- xml file ----------------------
    !--
    Document : XMLResolverTest.xml

    --
    !DOCTYPE root [
    !ENTITY replace PUBLIC "-//W3C//DTD HTML //EN" "E:/stax/JAXBSD/002/replace1.txt"
    ]
    rootreplace;/root

    ----------------------- replace1.txt file ---------------------------
    !--
    replace1. txt
    --
    replace1
    ------------------- replace2.txt ------------------------------------
    !--
    replace2.txt
    --
    replace2
    --------------------------------

    DB:2.07:Need Help In Use Of Xmlresolver Resolveentity Method xp

    prinu wrote:
    Is sun implementation is supporting resolve entity which return XMLStreamReader / XMLEventReadear ?I don't know. But you could at least find out whether your resolver is being used. It's possible the resolver isn't setting things up correctly.

    Any suggestion ?Debugging. Find out whether the parser is calling your resolver.

  • RELEVANCY SCORE 2.07

    DB:2.07:Stax :Streaming Api For Xml 7p


    hi
    I would like to know about stAX and how it is better over the earlier approaches like SAX and DOM

    DB:2.07:Stax :Streaming Api For Xml 7p

    http://www.xml.com/pub/a/2003/09/17/stax.html