JDB command equivalent using com.sun.jdi classes

Using jdb I am able to stop by "stop at $Oracle.Procedure.DTP.PROCEDURE1:5" as seen below
>
main[1] stop at $Oracle.Procedure.DTP.PROCEDURE1:5
Set breakpoint $Oracle.Procedure.DTP.PROCEDURE1:5
main[1] cont
>
Breakpoint hit: "thread=main", $Oracle.Procedure.DTP.PROCEDURE1.PROCEDURE1(), line=5 bci=5
what will be the equivalent of this using com.sun.jdi.VirtualMachine ?
Regards
Anthos

Set breakpoint using createBreakpointRequest().
See:
http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/request/EventRequestManager.html#createBreakpointRequest(com.sun.jdi.Location)
When it hits the breakpoint BreakpointEvent will be posted.
See:
http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/event/BreakpointEvent.html
Hope this helps.

Similar Messages

  • ClassNotFoundException: transpackage.JavaTrans com.sun.jdi.Connec

    I have created an application and I have used JCreator to compile and run it.
    My next step is that I want to make my application as executable jar
    I did the following:
    1- I made a package name called transpackage and I have include it in each file
    2- I have executed the command : jar cfm MyJar.jar Manifest.txt transpackage/*.class
    3- Manifest.txt file contains the following line :
    Main-Class: transpackage.JavaTrans and an empty line after it.
    4- If I executed the follwing line to run the jar file:
    java -jar MyJar.jar
    I got the follwing error:
    Exception in thread "main" java.lang.NoClassDefFoundError: transpackage/JavaTran
    s com/sun/jdi/connect
    Caused by: java.lang.ClassNotFoundException: transpackage.JavaTrans com.sun.jdi.
    connect
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Please advise what the problem here is. I couldn't figure it out. Thanks for help

    The application is running under JCreator Perfectly, but I want to make it as jar executable file
    I have use JCreator to create the jar file and update the manifest file to contain the main class that contains main function. I name the main class is JT. The updating command that I used is
    jar umf manifest jar-fileStill got the following error:
    C:\JT\classes>java -jar JT.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: JT
    Caused by: java.lang.ClassNotFoundException: JT
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)The main class is there what is the problem. I have been trying to fix this peob for a week now. Any Advise is really appreciated. Thanks
    C:\JT\classes>jar tf JT.jar
    META-INF/
    META-INF/MANIFEST.MF
    EventThread$ThreadTrace.clas
    EventThread.class
    images/
    images/compile.gif
    images/exit1.jpg
    images/open.JPG
    images/Thumbs.db
    Info.class
    JT$1.class
    JT$2.class
    JT$3.class
    JT$DemoAction.class
    JT.class
    manifest.txt
    StepInfo.class
    StreamRedirectThread.class
    tmp3642.tmp
    tmp51088.tmp
    tmp58684.tmp
    tmp8207.tmp

  • Com.sun.jdi.ThreadReference.frames() unexpectedly raises an exception

    Hi,
    I'm using JDI for monitoring and manipulating another jvm running on the same machine.
    For retrieving the stackframes of a thread, I call thread.frames(). This call is said to raise a IncompatibleThreadStateException if the corresponding thread on the debugged jvm is not suspended. However, I sometimes encounter situations where this exception is raised even when the thread is suspended ! Furthermore, in this case, the duration of the call thread.frames() is between 1.8 and 2 seconds (instead of a few milliseconds in normal cases().
    // now, the jvm is stopped at a breakpoint
    ThreadReference thread = .....;
    if (thread.isSuspended()) { // will obviously be true
    List frames = thread.frames();
    // the frames() call may raise an exception and takes up to 2 sec.
    Is this a known bug ? Is the API's doc incomplete ? Can someone explain me what's happends, or comment about this strange behaviour ?
    Thanks in advance,
    Jacques-Olivier
    [email protected]

    Can't help, but this happens to me too. Here is a code snippet:
    tr.suspend();
    try
    System.out.println("Suspended: "+tr.isSuspended());
    List lFrames=tr.frames();
    finally
    tr.resume();
    This code snippet always prints 'suspended: true' and always throws the exception on the tr.frames() call, in my code. (running on 1.4.1 FCS, connected using a com.sun.jdi.CommandLineLaunch)
    (Incidentally, my code actually intends to suspend the entire VM, not individual threads. But I threw in the suspend of an individual thread in addition, just in case.)
    --sam                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Exception in thread "main" com.sun.jdi.InternalException: Unexpected JDWP E

    I�m trying to write program to debug J2ME applications running on emulators. I�ve made a connection to the virtual machine that starts and run the application on the emulator. When i try to execute the method AllClasses() from the virtual machine object i get the exception:
    Exception in thread "main" com.sun.jdi.InternalException: Unexpected JDWP Error: 41
         at com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:47)
         at com.sun.tools.jdi.VirtualMachineImpl.retrieveAllClasses1_4(VirtualMachineImpl.java:864)
         at com.sun.tools.jdi.VirtualMachineImpl.retrieveAllClasses(VirtualMachineImpl.java:892)
         at com.sun.tools.jdi.VirtualMachineImpl.allClasses(VirtualMachineImpl.java:258)
    Hope you can help me.
    Thanks.

    com.sun.jdi.InternalException: Unexpected JDWP Error: 41It appears the J2ME VM returned JDWP_Error_NOT_FOUND (41).
    J2ME implements a subset of the J2SE JDI interface.
    Is AllClasses() supported?
    I�ve made a connection to the virtual machine that starts and run the application on the emulator.What other JDI operations are you able to do?

  • Moving from com.sun.xml classes to the new xml support integrated in java

    So far, for our XML implementation, we have used the DocumentEx, ElementEx, etc. from com.sun.xml.
    We understand that xml is now supported by the java itself (javax.xml.parsers?) and we wish to update our code to use the newer API.
    Is there a simple mapping between the old DocumentEx and ElementEx and new classes in javax.xml? Can it really be simple to "get rid" of com.sun.xml?

    The combination of the:
    Oracle XML SQL Utility
    and
    Oracle XML Parser for PLSQL V2
    give you what you need.
    null

  • How can i convert an image into gif file as jpeg by using com.sun.image.*

    please help me to convert an image into gif format. i have used sun's impl com.sun.image.code.jpeg package to convert a buffered image into a jpeg file. is there any implementatioln available from sun to handle gif files.

    Many. Try for instance google with 'java image encoders'. Go to the URL http://www.google.com/search?q=java+image+encoders and be amazed of the wonders of modern web search tools.

  • HOW do you use "com.sun.media.codec.video.jpeg.NativeEncoder"???

    Hi!! I want to know if I can use this encoder (NativeEncoder) for encoding to MJPG.
    If I do: PlugInManager.getPlugInList(new VideoFormat( VideoFormat.RGB),
                        new VideoFormat(VideoFormat.MJPG), PlugInManager.CODEC);
    I obtain only one codec:com.sun.media.codec.video.jpeg.NativeEncoder
    BUT, then, I do: codec.setInputFormat(new VideoFormat( VideoFormat.RGB))-->It returns me:NULL. why????!!!
    Regards!

    The input format may have to be more specific and suitable; eg for Windows :-
    RGBFormat(new Dimension(w,h), w*h*3, Format.byteArray, -1.0F, 24, 3, 2, 1, 3, w*3,-1,-1)

  • Can anybody how to loook up in websphere 6.1 using com.sun.messaging.Queue

    Hi,
    Thanks in advance
    I am really new to webservices can any one provide me code for sending a soap object using jms using WebSphere6.1

    don't crosspost.
    And no, noone is going to tell you how to send SOAP messages to a JMS queue (which was what you were asking elsewhere).

  • Random classcast exception - com.sun.jndi.cosnaming.CNCtxFactory

    Hi,
    I am trying to use a remote ejb (weblogic 8.1.5/ jdk 14) from a j2se 1.5 rmi-iiop client.
    If I use com.sun.jndi.cosnaming.CNCtxFactory to look up the remote home & then use the remote interface, I get the following error RANDOMly (i.e only some calls succeed).
    java.lang.ClassCastException
         at xxx.equals(xxxjava:129)
         at weblogic.corba.utils.IndirectionValueHashtable.get(IndirectionValueHashtable.java:119)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1471)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
         at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
         at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1593)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
         at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
         at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1593)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at weblogic.iiop.RMIMsgOutput.writeObject(RMIMsgOutput.java:117)
         at xxx.yyy_ehqjge_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:492)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:435)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:430)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    I had a look at IndirectionValueHashtable class. It looks like the classcast is happening because the "handle-to-object" map has non String values.
    Could this be a corba compatabilty issue?
    The problem doesn't occur if I use weblogic initial context factory & t3 protocol.
    What is the best way to overcome this problem? I dont want to distribute weblogic.jar [from 8.1.5 server]. wlclient is okay.
    thanks

    Tony Zimmer <> writes:
    Certainly looks like a bug, in which case you need to go through
    support to get it fixed. Do however check that your objects are in
    fact serializable (including all their fields).
    andy
    Tried a few more combinations. No luck so far.
    classcast exception for some objects at some times
    server: WebLogic Server 10.0 / Sun 1.5.0_06/ WinNT 6
    client: Sun jdk 1.5.0_11/1.4.2_14
    java.lang.ClassCastException: java.lang.String
         at xxxpack.client.PaymentReceipt.equals(PaymentReceipt.java:881)
         at weblogic.corba.utils.IndirectionValueHashtable.get(IndirectionValueHashtable.java:119)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1836)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1992)
         at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:2253)
         at weblogic.utils.io.ObjectStreamClass.writeFields(ObjectStreamClass.java:413)
         at weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:235)
         at weblogic.corba.utils.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:182)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1957)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1992)
         at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:2253)
         at weblogic.utils.io.ObjectStreamClass.writeFields(ObjectStreamClass.java:413)
         at weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:235)
         at weblogic.corba.utils.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:182)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1957)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1992)
         at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:2253)
         at xxxpack.server.ProcessPayment_ehqjge_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:479)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:475)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:59)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:1016)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
    server: WebLogic Server 8.1 SP6 / Sun 1.4.2_11 / WinNT 6
    client jdk 1.4.2_14/1.5.0_11:
    java.lang.ClassCastException
         at xxxpack.client.PurchaseAmount.equals(PurchaseAmount.java:148)
         at weblogic.corba.utils.IndirectionValueHashtable.get(IndirectionValueHashtable.java:119)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1471)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
         at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
         at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1593)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
         at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
         at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
         at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1593)
         at weblogic.iiop.IIOPOutputStream.write_value(IIOPOutputStream.java:1624)
         at weblogic.iiop.RMIMsgOutput.writeObject(RMIMsgOutput.java:117)
         at xxxpack.server.ProcessPayment_ehqjge_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:120)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:429)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    Do you have a list/ martix of client-server versions used for the bug fixes?
    Thanks

  • How to get import com.sun.image.codec.jpeg.*;..Help..

    I’m doing a research for video compression n I need to compress the frame as image, I want to use com.sun.image.codec.jpeg.* , but I can’t download the plugin every where. I use JDK 1.5.0 to do my java program. Does any one have a suggestion about my problem? What should I do, so I can use com.sun.image.codec.jpeg.*?
    thanks

    That is part of the following:
    [http://java.sun.com/javase/technologies/desktop/media/2D/]

  • Com.sun.security.auth.module.NTSystem compilation issues in Unix

    Hi ,
    I m using com.sun.security.auth.module.NTSystem in one my java application to get the current domain. The application and app server are running on windows OS.
    Now i want to switch my OS to Unix, where i m getting compilation issues with com.sun.security.auth.module.NTSystem ,
    1)Do i need to change the module from NTSystem to UnixSystem?
    2) I m developing the java application in Eclipse 3.2 with java 1.4 , when i m trying to import the below statment com.sun.security.auth.module.UnixSystem i couldn't? Could you please let me how i can import the UnixSystem or NTSystem will work?
    Appreciate your help!!!!
    Regards,
    Ravi.

    Unix, where i m getting compilation issues with com.sun.security.auth.module.NTSystemOf course.
    Do i need to change the module from NTSystem to UnixSystem?Of course.

  • Use of classes in com.sun.tools.doclets

    Hello -- What is the best practice recommendation wrt using the classes in com.sun.tools.doclets -- particularly with the planned refactoring?
    I'm writing a doclet that doesn't subclass, say, the standard doclet. There are obviously several very useful classes in this package (ClassTree, Util, MethodFinder, etc.) that I'd like to use. I can simply call their methods, but I'm curious to know if their active days are numbered.
    Would it be better to simply incorporate the source? What are the restrictions on using the source in my own doclet?
    If this is all covered somewhere (I've been hunting around a bit), please feel free to simply point me to the info.
    Thanks!
    Steve

    The Java 2 SDK license (which covers javadoc) allows you to only
    redistribute the code unmodified.
    In 1.5.0, the refactoring has renamed all of the packages and
    moved a lot of code around. We hope and plan to release
    the refactored code on java.net around the time 1.5.0 is
    released, and get an early access of it out. We'll notify
    people who are on the javadoc-announce email address which
    people can sign up as described at:
    http://java.sun.com/j2se/javadoc/#forum
    If you want more specific information now about how these will change,
    please let me know and we can answer those questions.
    -Doug Kramer
    Javadoc team

  • Error in parsing: SAX2 driver class com.sun.xml.parser not found

    Hi I have this exception
    Error in parsing: SAX2 driver class com.sun.xml.parser not found
    when I try to run the examples from the book xml and java
    I have added the following jar files to the class path that i have download form java.sun.com
    xml.jar
    xalan.jar
    jaxp.jar
    crimson.jar
    Please can anyone tell me what is missing or wrong..the code must be right since written by oreilly... please have u any ideA
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");//
    I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..to com.sun.xml.parser
    THIS IS THE ALL CODE
    import java.io.IOException;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    import org.xml.sax.*;
    * <b><code>SAXParserDemo</code></b> will take an XML file and parse it using SAX,
    * displaying the callbacks in the parsing lifecycle.
    * @author Brett McLaughlin
    * @version 1.0
    public class SAXParserDemo {
    * <p>
    * This parses the file, using registered SAX handlers, and output
    * the events in the parsing process cycle.
    * </p>
    * @param uri <code>String</code> URI of file to parse.
    public void performDemo(String uri) {
    System.out.println("Parsing XML File: " + uri + "\n\n");
    // Get instances of our handlers
    ContentHandler contentHandler = new MyContentHandler();
    ErrorHandler errorHandler = new MyErrorHandler();
    try {
    // Instantiate a parser
    XMLReader parser =
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");// I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..
    // Register the content handler
    parser.setContentHandler(contentHandler);
    // Register the error handler
    parser.setErrorHandler(errorHandler);
    // Parse the document
    parser.parse(uri);
    } catch (IOException e) {
    System.out.println("Error reading URI: " + e.getMessage());
    } catch (SAXException e) {
    System.out.println("Error in parsing: " + e.getMessage());
    * <p>
    * This provides a command line entry point for this demo.
    * </p>
    public static void main(String[] args) {
    // if (args.length != 1) {
    // System.out.println("Usage: java SAXParserDemo [XML URI]");
    // System.exit(0);
    //String uri = args[0];
    SAXParserDemo parserDemo = new SAXParserDemo();
    parserDemo.performDemo("content.xml");
    * <b><code>MyContentHandler</code></b> implements the SAX
    * <code>ContentHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's content.
    class MyContentHandler implements ContentHandler {
    /** Hold onto the locator for location information */
    private Locator locator;
    * <p>
    * Provide reference to <code>Locator</code> which provides
    * information about where in a document callbacks occur.
    * </p>
    * @param locator <code>Locator</code> object tied to callback
    * process
    public void setDocumentLocator(Locator locator) {
    System.out.println(" * setDocumentLocator() called");
    // We save this for later use if desired.
    this.locator = locator;
    * <p>
    * This indicates the start of a Document parse - this precedes
    * all callbacks in all SAX Handlers with the sole exception
    * of <code>{@link #setDocumentLocator}</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void startDocument() throws SAXException {
    System.out.println("Parsing begins...");
    * <p>
    * This indicates the end of a Document parse - this occurs after
    * all callbacks in all SAX Handlers.</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void endDocument() throws SAXException {
    System.out.println("...Parsing ends.");
    * <p>
    * This will indicate that a processing instruction (other than
    * the XML declaration) has been encountered.
    * </p>
    * @param target <code>String</code> target of PI
    * @param data <code>String</code containing all data sent to the PI.
    * This typically looks like one or more attribute value
    * pairs.
    * @throws <code>SAXException</code> when things go wrong
    public void processingInstruction(String target, String data)
    throws SAXException {
    System.out.println("PI: Target:" + target + " and Data:" + data);
    * <p>
    * This will indicate the beginning of an XML Namespace prefix
    * mapping. Although this typically occur within the root element
    * of an XML document, it can occur at any point within the
    * document. Note that a prefix mapping on an element triggers
    * this callback <i>before</i> the callback for the actual element
    * itself (<code>{@link #startElement}</code>) occurs.
    * </p>
    * @param prefix <code>String</code> prefix used for the namespace
    * being reported
    * @param uri <code>String</code> URI for the namespace
    * being reported
    * @throws <code>SAXException</code> when things go wrong
    public void startPrefixMapping(String prefix, String uri) {
    System.out.println("Mapping starts for prefix " + prefix +
    " mapped to URI " + uri);
    * <p>
    * This indicates the end of a prefix mapping, when the namespace
    * reported in a <code>{@link #startPrefixMapping}</code> callback
    * is no longer available.
    * </p>
    * @param prefix <code>String</code> of namespace being reported
    * @throws <code>SAXException</code> when things go wrong
    public void endPrefixMapping(String prefix) {
    System.out.println("Mapping ends for prefix " + prefix);
    * <p>
    * This reports the occurrence of an actual element. It will include
    * the element's attributes, with the exception of XML vocabulary
    * specific attributes, such as
    * <code>xmlns:[namespace prefix]</code> and
    * <code>xsi:schemaLocation</code>.
    * </p>
    * @param namespaceURI <code>String</code> namespace URI this element
    * is associated with, or an empty
    * <code>String</code>
    * @param localName <code>String</code> name of element (with no
    * namespace prefix, if one is present)
    * @param rawName <code>String</code> XML 1.0 version of element name:
    * [namespace prefix]:[localName]
    * @param atts <code>Attributes</code> list for this element
    * @throws <code>SAXException</code> when things go wrong
    public void startElement(String namespaceURI, String localName,
    String rawName, Attributes atts)
    throws SAXException {
    System.out.print("startElement: " + localName);
    if (!namespaceURI.equals("")) {
    System.out.println(" in namespace " + namespaceURI +
    " (" + rawName + ")");
    } else {
    System.out.println(" has no associated namespace");
    for (int i=0; i<atts.getLength(); i++)
    System.out.println(" Attribute: " + atts.getLocalName(i) +
    "=" + atts.getValue(i));
    * <p>
    * Indicates the end of an element
    * (<code></[element name]></code>) is reached. Note that
    * the parser does not distinguish between empty
    * elements and non-empty elements, so this will occur uniformly.
    * </p>
    * @param namespaceURI <code>String</code> URI of namespace this
    * element is associated with
    * @param localName <code>String</code> name of element without prefix
    * @param rawName <code>String</code> name of element in XML 1.0 form
    * @throws <code>SAXException</code> when things go wrong
    public void endElement(String namespaceURI, String localName,
    String rawName)
    throws SAXException {
    System.out.println("endElement: " + localName + "\n");
    * <p>
    * This will report character data (within an element).
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void characters(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("characters: " + s);
    * <p>
    * This will report whitespace that can be ignored in the
    * originating document. This is typically only invoked when
    * validation is ocurring in the parsing process.
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void ignorableWhitespace(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("ignorableWhitespace: [" + s + "]");
    * <p>
    * This will report an entity that is skipped by the parser. This
    * should only occur for non-validating parsers, and then is still
    * implementation-dependent behavior.
    * </p>
    * @param name <code>String</code> name of entity being skipped
    * @throws <code>SAXException</code> when things go wrong
    public void skippedEntity(String name) throws SAXException {
    System.out.println("Skipping entity " + name);
    * <b><code>MyErrorHandler</code></b> implements the SAX
    * <code>ErrorHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's errors.
    class MyErrorHandler implements ErrorHandler {
    * <p>
    * This will report a warning that has occurred; this indicates
    * that while no XML rules were "broken", something appears
    * to be incorrect or missing.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void warning(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Warning**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Warning encountered");
    * <p>
    * This will report an error that has occurred; this indicates
    * that a rule was broken, typically in validation, but that
    * parsing can reasonably continue.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void error(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Error encountered");
    * <p>
    * This will report a fatal error that has occurred; this indicates
    * that a rule has been broken that makes continued parsing either
    * impossible or an almost certain waste of time.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void fatalError(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Fatal Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Fatal Error encountered");

    I have seen this error when I'm executing inside one of the (j2ee sun reference implementation) server containers (either web or ejb). I believe its caused by "something" having previously loaded the "sax 1 driver class". In my case, I think the container or server is loading the sax parser from a jar that contains a sax 1 version. If you can, ensure that nothing is loading the sax 1 parser from another jar on your system. Verify that you are loading the sax parser from a jar containing the latest version so that you get the sax 2 compliant parser. Good luck!

  • JDB: How to run jdb with sun.* classes.

    I'm attempting to run jdb and step through various classes in sun.*. I run jdb with the sourcepath set to the unzipped contents of the Sun Community License source code that I downloaded (jdb and source code version 1.3.1). However, every time I get to an internal Java API call, the "step" method skips over the call. I can do a "stop in" by specifying the particular internal Java method that I want to stop in and "list" will show me the Java code (which means that it is seeing the Java source). However, typing "step" at this point runs to the end of any of the Java internal methods and back to my own code.
    Is there a way that I can instruct the debugger that I really want to step into the Java internal classes?
    Thanks,
    Kevin Regan
    [email protected]

    Oh yeah, I'm hoping for my first Duke Dollars!
    You must issue an "exclude none" command to jdb
    to be able to trace sun.*
    In fact if you type "exclude" you can see that
    java.*,javax.*,sun.*,com.sun.*
    are excluded from steping by default in jdb(1.4.x)
    -Cameron Elliott
    [email protected]

  • Error while connecting to Microsoft Exchange server using javamail: "com.sun.mail.util.MailConnectException: Couldn't connect to host, port: host name , 993; timeout -1"

    I am trying to read mails from my outlook microsoft exchange server. Following is the code:
    public void readEmailsFromOutlook(/*String host, String username, String password*/ ) throws MessagingException, IOException {
          String host = "hostname";
          String username = "domain\\username";
          String password = "password"
          // Create empty properties
          Properties props = System.getProperties();
          props.setProperty("mail.smtp.auth","true");
          props.setProperty("mail.store.protocol","imaps");
          props.setProperty("mail.imap.auth.plain.disable","true");
          props.setProperty("mail.imap.host",host);
          props.setProperty("mail.imap.port","993");
          props.setProperty("mail.imap.user",username);
          props.setProperty("mail.imap.pwd",password);
          props.setProperty("mail.imap.debug","true");
          props.setProperty("mail.imap.ssl.protocols","SSL");
          props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.setProperty("mail.imap.socketFactory.fallback", "false");
          props.setProperty("mail.imap.socketFactory.port", "993");
          // Get session
                     Session session = Session.getInstance(props, new ExchangeAuthenticator(username, password));
          session.setDebug(true);
          // Get the store
          Store store = session.getStore("imaps");
          //Store store = session.getStore();
          store.connect(host, username, password);
          // Get folder
          Folder folder = store.getFolder("INBOX");
          folder.open(Folder.READ_ONLY);
          BufferedReader reader = new BufferedReader(new InputStreamReader(
              System.in));
          // Get directory
          Message message[] = folder.getMessages();
          for (int i = 0, n = message.length; i < n; i++) {
            System.out.println(i + ": " + message[i].getFrom()[0] + "\t"
                + message[i].getSubject());
            System.out.println("Read message? [YES to read/QUIT to end]");
            String line = reader.readLine();
            if ("YES".equalsIgnoreCase(line)) {
              System.out.println(message[i].getContent());
            } else if ("QUIT".equalsIgnoreCase(line)) {
              break;
          // Close connection
          folder.close(false);
          store.close();
    But it threw the following error:
    DEBUG: setDebug: JavaMail version 1.5.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle]
    DEBUG IMAPS: mail.imap.fetchsize: 16384
    DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
    DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
    DEBUG IMAPS: mail.imap.appendbuffersize: -1
    DEBUG IMAPS: mail.imap.minidletime: 10
    DEBUG IMAPS: trying to connect to host <hostname>,port 993, isSSL true
    com.sun.mail.util.MailConnectException: Couldn't connect to host, port: 10.75.250.60, 993; timeout -1;
      nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:693)
    at javax.mail.Service.connect(Service.java:345)
    at javax.mail.Service.connect(Service.java:226)
    at com.capgemini.utilities.Utilities.readEmailsFromOutlook(Utilities.java:1261)
    Whats wrong with my code?
    Please help!!!!

    You're using the "imaps" protocol, but you've set properties for the "imap" protocol.  Change all the property names from mail.imap.* to mail.imaps.*.
    Also, get rid of all the socket factory properties.
    If you still can't connect, see these connection debugging tips.
    Most likely you're using the wrong host name or port number.  In almost all cases, it's better to just let JavaMail choose the correct port number.

Maybe you are looking for

  • I can't view dataTable in JSF

    Hi, anyone who can help me with java server faces, i want to put data from a resultset to dataTable, i made everithing but my table is not visible. My code is: <?xml version='1.0' encoding='windows-1252'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP

  • No video or startup after chime - could it be...

    a few days ago, while away from home, my pb would only chime and then not startup. you can hear a small chirp of disk activity, but then only the fan. the only way out was to hold the power button and power down. i tried everything, zapping the pram,

  • Solaris 8 on Intel 845

    Has anyone installed solaris 8 on to an Intel 845 motherboard ? :-)

  • Charge new iPad with iPod USB adapter 5V 1amp?

    Is there any problem to charge my new iPad with a USB iPod wall adapter with an output of 5V 1amp? And is it okay to do it daily? Will it affect in any way the battery?

  • Linkage for Template Monster Fla Files

    Alright I have looked about everywhere, except the right place. I know 0 about flash. Just got Flash CS3. Everything I find is for older versions of flash including the info on template monster. I need to know how to assign links for the buttons in t