Problem with getNodeValue() - simple Java XPath question

I am trying to extract the node values from a XML file:
<root>
  <frame>
     <boxes>
       <box>
          <spec>22</spec>
          <spec>2222</spec>
       </box>
       <box>
          <spec id="BA" value="short"/>
          <spec id="BB" value="thin"/>
          <spec id="BC" value="black"/>
          <spec id="BD" value="full"/>
          <spec id="BE" value="7"/>
          <spec id="BF" value="deactive"/>
       </box>                
     </boxes>
     <circles>
       <circle id="CA" value="blue"/>
       <circle id="CB" value="green"/>
     </circles>
  </frame>
</root>I use this code:
         XPathFactory factory = XPathFactory.newInstance();
         XPath xpath = factory.newXPath();
         XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");            
         Object result = xPathExpression.evaluate(doc, XPathConstants.NODESET);
         NodeList nodes = (NodeList) result;
         for (int i = 0; i < nodes.getLength(); i++) {
             System.out.println(nodes.item(i).getNodeValue());
         }But only:
null
null
null
null
null
null
null
null
get printed. I would have assumed:
22
2222
null
null
null
null
null
null
since the two first spec nodes contains the above numbers. Any ideas?

change this:
XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");to this:
XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec/text()");Need to xpath all the way down to the text of the node.
You could use
System.out.println(nodes.item(i).getTextContent());with your current xpath but if the spec node has children, these will also be included in the output.

Similar Messages

  • Problems with a simple stop watch program

    I would appreciate help sorting out a problem with a simple stop watch program. The problem is that it throws up inappropriate values. For example, the first time I ran it today it showed the best time at 19 seconds before the actual time had reached 2 seconds. I restarted the program and it ran correctly until about the thirtieth time I started it again when it was going okay until the display suddenly changed to something like '-50:31:30:50-'. I don't have screenshot because I had twenty thirteen year olds suddenly yelling at me that it was wrong. I clicked 'Stop' and then 'Start' again and it ran correctly.
    I have posted the whole code (minus the GUI section) because I want you to see that the program is very, very simple. I can't see where it could go wrong. I would appreciate any hints.
    public class StopWatch extends javax.swing.JFrame implements Runnable {
        int startTime, stopTime, totalTime, bestTime;
        private volatile Thread myThread = null;
        /** Creates new form StopWatch */
        public StopWatch() {
         startTime = 0;
         stopTime = 0;
         totalTime = 0;
         bestTime = 0;
         initComponents();
        public void run() {
         Thread thisThread = Thread.currentThread();
         while(myThread == thisThread) {
             try {
              Thread.sleep(100);
              getEnd();
             } catch (InterruptedException e) {}
        public void start() {
         if(myThread == null) {
             myThread = new Thread(this);
             myThread.start();
        public void getStart() {
         Calendar now = Calendar.getInstance();
         startTime = (now.get(Calendar.MINUTE) * 60) + now.get(Calendar.SECOND);
        public void getEnd() {
         Calendar now1 = Calendar.getInstance();
         stopTime = (now1.get(Calendar.MINUTE) * 60) + now1.get(Calendar.SECOND);
         totalTime = stopTime - startTime;
         setLabel();
         if(bestTime < totalTime) bestTime = totalTime;
        public void setLabel() {
         if((totalTime % 60) < 10) {
             jLabel1.setText(""+totalTime/60+ ":0"+(totalTime % 60));
         } else {
             jLabel1.setText(""+totalTime/60 + ":"+(totalTime % 60));
         if((bestTime % 60) < 10) {
             jLabel3.setText(""+bestTime/60+ ":0"+(bestTime % 60));
         } else {
             jLabel3.setText(""+bestTime/60 + ":"+(bestTime % 60));
        private void ButtonClicked(java.awt.event.ActionEvent evt) {                              
         JButton temp = (JButton) evt.getSource();
         if(temp.equals(jButton1)) {
             start();
             getStart();
         if(temp.equals(jButton2)) {
             getEnd();
             myThread = null;
         * @param args the command line arguments
        public static void main(String args[]) {
         java.awt.EventQueue.invokeLater(new Runnable() {
             public void run() {
              new StopWatch().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JPanel jPanel1;
        // End of variables declaration                  
    }

    Although I appreciate this information, it still doesn't actually solve the problem. I can't see an error in the logic (or the code). The fact that the formatting works most of the time suggests that the problem does not lie there. As well, I use the same basic code for other time related displays e.g. countdown timers where the user sets a maximum time and the computer stops when zero is reached. I haven't had an error is these programs.
    For me, it is such a simple program and the room for errors seem small. I am guessing that I have misunderstood something about dates, but I obviously don't know.
    Again, thank you for taking the time to look at the problem and post a reply.

  • Problem with a simple GRE tunnel

    Hello everyone:
    I have a problem with a simple GRE tunnel, and can not make it work, the problem lies in the instruction "tunnel source loopback-0" if I use this command does not work, now if I use "tunnel source <ip wan >" if it works, someone can tell me why?
    Thanks for your help
    Router 1: 2811
    version 12.4
    no service password-encryption
    hostname cisco2811
    no aaa new-model
    ip cef
    interface Loopback0
    ip address 2.2.2.2 255.255.255.255
    interface Tunnel0
    ip address 10.10.1.1 255.255.255.0
    tunnel source Loopback0
    tunnel destination 217.127.XXX.188
    interface Tunnel1
    ip address 10.10.2.1 255.255.255.0
    tunnel source Loopback0
    tunnel destination 80.32.XXX.125
    interface FastEthernet0/0
    description LOCAL LAN Interface
    ip address 192.168.1.254 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    duplex auto
    speed auto
    interface FastEthernet0/1
    description WAN Interface
    ip address 195.77.XXX.70 255.255.255.248
    ip nat outside
    ip virtual-reassembly
    duplex auto
    speed auto
    ip forward-protocol nd
    ip route 0.0.0.0 0.0.0.0 195.77.XXX.65
    ip route 192.168.3.0 255.255.255.0 Tunnel0
    ip route 192.168.4.0 255.255.255.0 Tunnel1
    ip nat inside source route-map salida-fibra interface FastEthernet0/1 overload
    access-list 120 deny ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255
    access-list 120 deny ip 192.168.1.0 0.0.0.255 192.168.4.0 0.0.0.255
    access-list 120 permit ip 192.168.1.0 0.0.0.255 any
    route-map salida-fibra permit 10
    match ip address 120
    Router 2: 2811
    version 12.4
    service password-encryption
    ip cef
    no ip domain lookup
    multilink bundle-name authenticated
    username admin privilege 15 password 7 104CXXXXx13
    interface Loopback0
    ip address 4.4.4.4 255.255.255.255
    interface Tunnel0
    ip address 10.10.1.2 255.255.255.0
    tunnel source Loopback0
    tunnel destination 195.77.XXX.70
    interface Ethernet0
    ip address 192.168.3.251 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    hold-queue 100 out
    interface ATM0
    no ip address
    no ip route-cache cef
    no ip route-cache
    no atm ilmi-keepalive
    dsl operating-mode auto
    interface ATM0.1 point-to-point
    ip address 217.127.XXX.188 255.255.255.192
    ip nat outside
    ip virtual-reassembly
    no ip route-cache
    no snmp trap link-status
    pvc 8/32
    encapsulation aal5snap
    ip route 0.0.0.0 0.0.0.0 ATM0.1
    ip route 192.168.1.0 255.255.255.0 Tunnel0
    ip nat inside source route-map nonat interface ATM0.1 overload
    access-list 100 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
    access-list 120 deny ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
    access-list 120 permit ip 192.168.3.0 0.0.0.255 any
    route-map nonat permit 10
    match ip address 120

    Hello, thank you for the answer, as to your question, I have no connectivity within the tunnel, whether from Router 1, I ping 10.10.1.2 not get response ...
    Now both routers remove the loopback, and the interface tunnel 0 change the tunnel source to "tunnel source " tunnel works perfectly, the problem is when I have to use the loopback. Unfortunately achieved when the tunnel work, this will have to endure multicast, and all the examples found carrying a loopback as' source '... but this is a step back ..
    Tunnel0 is up, line protocol is up
    Hardware is Tunnel
    Internet address is 10.10.1.1/24
    MTU 1514 bytes, BW 9 Kbit, DLY 500000 usec,
    reliability 255/255, txload 1/255, rxload 1/255
    Encapsulation TUNNEL, loopback not set
    Keepalive not set
    Tunnel source 2.2.2.2 (Loopback0), destination 217.127.XXX.188
    Tunnel protocol/transport GRE/IP
    Key disabled, sequencing disabled
    Checksumming of packets disabled
    Tunnel TTL 255
    Fast tunneling enabled
    Tunnel transmit bandwidth 8000 (kbps)
    Tunnel receive bandwidth 8000 (kbps)
    Last input 09:04:38, output 00:00:19, output hang never
    Last clearing of "show interface" counters never
    Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
    Queueing strategy: fifo
    Output queue: 0/0 (size/max)
    5 minute input rate 0 bits/sec, 0 packets/sec
    5 minute output rate 0 bits/sec, 0 packets/sec
    0 packets input, 0 bytes, 0 no buffer
    Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
    11101 packets output, 773420 bytes, 0 underruns
    0 output errors, 0 collisions, 0 interface resets
    0 unknown protocol drops
    0 output buffer failures, 0 output buffers swapped out

  • Problem with win2000sp3 and Java web start

    I have JRE and Java web start (1.2.0_01, build b01) which come downloading file j2re-1_4_1_01-windows-i586-i.exe from sun.
    I have win2000pro running on my PC.
    I had updated win2000 to service pack 2 and everything was fine.
    Now i decided to update to service pack 3 (in the process I also updated other components) from Microsoft and:
    1) Java applets seem to be running fine within i.e.
    2) If i try to run an application from java web start my PC freezes and I have to restart it.
    3) Staroffice 6.0, which runs on Java, seems to be fine.
    I reinstalled both sp3 and jre etc, with no result.
    Is this a known problem?
    Thanks to all.
    Maurizio

    I suspect that you have hit a known problem with Swing on Java 1.4.1 with buggy video drivers. Do you have an ATI card? They are the worst offenders. ATI released new drivers for its Radeon line today. They fix the problem.

  • Hi guys, problem with grey screen and flashing question mark. on top of it while in utility, i'm unable to verify, verify disc permission or repair disc0 which is obviously my main hd. any ideas where to go from here? tried to reistall osx but no luck.

    hi guys, problem with grey screen and flashing question mark. should be straight forward affair but on top of it while in disc utility, i'm unable to verify, verify disc permission, repair or even erase disc0 which is obviously my main hd. any ideas where to go from here? tried to reinstall osx but no luck, stucked when asked to chose location to install osx. would really apreciate any kind of help with this cause i'm quite new mac user. ty

    If you don't have a backup, read this:
    https://discussions.apple.com/docs/DOC-1689

  • [SOLVED] Problem with Vuze and Java RE x86_64

    Hello all !
    First of all, sorry if this issue was posted before, but find no related issue similar to mine.
    Using pacman, I successfully installed JRE (version 6u16-1-x86_64) and Vuze (version 4.2.0.8-1, former Azureus), but Vuze doesn't want to start.
    Running the Vuze's executable in the gnome-terminal, I notice messages from vuze informing it can't find Java executable ("Java exec not found in PATH, starting auto-search..." AND "OOPS, unable to locate java exec in /usr/java/latest /usr/java /usr/lib/jvm/latest /usr/lib/jvm hierarchy") and therefore cannot start the Vuze UI. I also tried but failed in verify the version of Java with the command "java -version" due to command not found.
    What is the best approach to fix this problem with Java 64 bits?
    Thanks in advance
    Last edited by josephg (2009-09-28 18:55:56)

    peart wrote:Just log out and back in, most likely.  There are scripts in /etc/profile.d/ that need to be run to set up your java environment.  They get run automatically when you log in.
    Yep, perfect answer - issue solved. Thanks a lot!

  • Problem with firewall and java on line sites internet explorer

    i have been experiencing problems with java on line games because the firewall has blocked usage.On two of them when i press play to play the game a message appears error on page.If i dowload mozilla will i have the same problems? also when downloading from my gmail account again error on page. When i donload your browser do i click on save or open?
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; WinNT-EVI 27.03.2010)

    Well... good; when we help each other here, we can't
    assume that any step has been taken, unless it's been
    specifically identified. I'm sure that makes it all
    the more frustrating, since you are a very experienced
    user.
    Now, then:
    -- since you have reinstalled the Java Update; and
    -- if you open your Help >> Installed Plug-ins, and
    scroll down the list and find these three items:
    Java Plug-in for Cocoa -- Java 1.4.2 "JavaPluginCocoa.bundle"
    Java Plug-in (CFM) -- Java 1.3.1 "Java Applet Plugin Enabler"
    Java Plug-in "Java Applet.plugin"
    -- and if Enable Java and Enable JavaScript are checked in:
    Safari >> Preferences >> Security, as you say they are; and
    -- if Enable Plug-ins is checked in the same section,
    as you say it is; and
    -- you have repaired permissions, as you say you have; and
    -- you have emptied your Cache; and
    -- your Icons folder ({YOU}/Library/Safari/Icons) has been
    trashed if it is over 750 KB; and
    -- you have Quit, then relaunched Safari after all this,
    as you say you have; and
    -- your {YOU}/Library/Caches and {YOU}/Library/Caches/Safari
    folders have read and write permissions
    ...then, I'm currently at a loss as to what else to suggest.

  • Problem with DigiChat and java

    I can't get into a chat room because of a problem with digichat and java

    can get a  java for mac book pro

  • At a loss with some simple java classwork. Please help.

    Hello. I'm having a problem with some work that I wasn't able to finish in class. I am not very good at java AT ALL, and I'm really at a loss on how to finish up the program and get it to print what I want it to.
    My task is:
    "Write a program that asks for two words and then eliminates the second word from the first word.
    For example:
    forgot - go = fort
    bedevil - bed = evil
    bedevil - evil = bed
    stupid - is = Hey, is is not found in stupid."
    This is my code so far:
    public class wordSubtraction
         public static String big = "bedevil";
         public static String small = "bed";
         public static void main(String[] args)
              elimWord(String big, String small);
         public static void elimWord(String big, String small)
              if(big.indexof(small)==-1)
                   System.out.println(small + " isn't found in " + big);
              else
                   big.substring(0, indexOf(small));
                   small.substring(indexOf(small)+small.length());
                   System.out.println(small + " + " + small.substring + " = " + big);
    I keep getting this error:
    /Users/mewmew/Desktop/wordSubtraction.java:8: ')' expected
              elimWord(String big, String small);
                                    ^
    1 errorI don't understand what this error means or how to fix it, it looks like I have all the parenthesis in there to me. Deleting or adding semi-colins, parethesis, brackets, or curly brackets just seems to give me more errors.
    Any help is appreciated!

    No it's not JJEdit. The errors are a good thing -
    and each one has to be
    dealt with. When you call a String method various
    things have to be
    correct:
    (1) The name of the method - case is important.
    (2) The arguments - the things in the parentheses -
    have to be exactly
    the sort of thing that the method expects. For
    example if the method
    expects an int argument and you give it a String
    there will be problems
    (3) The methods must be called using a String
    variable and a dot. If
    you just say "substring(whatever)" that's an error.
    The compiler is
    saying "substring of what?" You have to write
    "something.substring(whatever)"
    Also - because it will be important later - both
    substring() and indexOf()
    return a value. It is up to you to do something with
    that value. Usually
    you assign it to a variable.
    Just for the record I got the follow from the String
    API doumentation here:
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Stri
    ng.html
    public int indexOf(String str) Returns the index
    within this string of the
    first occurrence of the specified substring.
    public String substring(int beginIndex) Returns a new
    string that is a
    substring of this string. The substring begins with
    the character at the
    specified index and extends to the end of this
    string.
    public String substring(int beginIndex, int
    endIndex)Returns a new
    string that is a substring of this string. The
    substring begins at the
    specified beginIndex and extends to the character at
    index endIndex - 1.
    I would suggest you write elimWord() along these
    lines:public static void elimWord(String big,
    String small)
    int pos = // find the index of small in big
    if(pos == -1)
    System.out.println(small + " isn't found in "
    und in " + big);
    else
    String before = // find the bit before small
    re small in big
    String after = // find the bit after small in
    small in big
    System.out.println(big + " - " + small + " =
    ll + " = " + before + after);
    Thank you! That's very helpful and I feel that I'm THAT much more on my way to understanding what the heck I'm doing.
    I'm trying, though...
    Now I just gotta find out how to get the bits before and after small in big and solve these errors:
    /Users/audreyeckel/Desktop/wordSubtraction.java:24: '.class' expected
              int pos = big.substring(0, int indexOf(small));
                                                   ^
    /Users/audreyeckel/Desktop/wordSubtraction.java:24: ')' expected
              int pos = big.substring(0, int indexOf(small));
                                                                  ^
    2 errorsI just hope I can finish it before it gets TOO late...it's about 2:26 AM here and this is due...TODAY!

  • Problem while executing simple java program

    Hi
    while trying to execute a simple java program,i am getting the following exception...
    please help me in this
    java program :import java.util.*;
    import java.util.logging.*;
    public class Jump implements Runnable{
        Hashtable activeQueues = new Hashtable();
        String dbURL, dbuser, dbpasswd, loggerDir;   
        int idleSleep;
        static Logger logger = Logger.getAnonymousLogger();      
        Thread myThread = null;
        JumpQueueManager manager = null;
        private final static String VERSION = "2.92";
          public Jump(String jdbcURL, String user, String pwd, int idleSleep, String logDir) {
            dbURL = jdbcURL;
            dbuser = user;
            dbpasswd = pwd;
            this.idleSleep = idleSleep;
            manager = new JumpQueueManager(dbURL, dbuser, dbpasswd);
            loggerDir = logDir;
            //preparing logger
            prepareLogger();
          private void prepareLogger(){      
            Handler hndl = new pl.com.sony.utils.SimpleLoggerHandler();
            try{
                String logFilePattern = loggerDir + java.io.File.separator + "jumplog%g.log";
                Handler filehndl = new java.util.logging.FileHandler(logFilePattern, JumpConstants.MAX_LOG_SIZE, JumpConstants.MAX_LOG_FILE_NUM);
                filehndl.setEncoding("UTF-8");
                filehndl.setLevel(Level.INFO);
                logger.addHandler(filehndl);
            catch(Exception e){
            logger.setLevel(Level.ALL);
            logger.setUseParentHandlers(false);
            logger.addHandler(hndl);
            logger.setLevel(Level.FINE);
            logger.info("LOGGING FACILITY IS READY !");
          private void processTask(QueueTask task){
            JumpProcessor proc = JumpProcessorGenerator.getProcessor(task);       
            if(proc==null){
                logger.severe("Unknown task type: " + task.getType());           
                return;
            proc.setJumpThread(myThread);
            proc.setLogger(logger);       
            proc.setJumpRef(this);
            task.setProcStart(new java.util.Date());
            setExecution(task, true);       
            new Thread(proc).start();       
         private void processQueue(){       
            //Endles loop for processing tasks from queue       
            QueueTask task = null;
            while(true){
                    try{
                        //null argument means: take first free, no matters which queue
                        do{
                            task = manager.getTask(activeQueues);
                            if(task!=null)
                                processTask(task);               
                        while(task!=null);
                    catch(Exception e){
                        logger.severe(e.getMessage());
                logger.fine("-------->Sleeping for " + idleSleep + " minutes...hzzzzzz (Active queues:"+ activeQueues.size()+")");
                try{
                    if(!myThread.interrupted())
                        myThread.sleep(60*1000*idleSleep);
                catch(InterruptedException e){
                    logger.fine("-------->Wakeing up !!!");
            }//while       
        public void setMyThread(Thread t){
            myThread = t;
        /** This method is only used to start Jump as a separate thread this is
         *usefull to allow jump to access its own thread to sleep wait and synchronize
         *If you just start ProcessQueue from main method it is not possible to
         *use methods like Thread.sleep becouse object is not owner of current thread.
        public void run() {
            processQueue();
        /** This is just another facade to hide database access from another classes*/
        public void updateOraTaskStatus(QueueTask task, boolean success){
            try{         
                manager.updateOraTaskStatus(task, success);
            catch(Exception e){
                logger.severe("Cannot update status of task table for task:" + task.getID() +  "\nReason: " + e.getMessage());       
        /** This is facade to JumpQueueManager method with same name to hide
         *existance of database and SQLExceptions from processor classes
         *Processor class calls this method to execute stored proc and it doesn't
         *take care about any SQL related issues including exceptions
        public void executeStoredProc(String proc) throws Exception{
            try{
                manager.executeStoredProc(proc);
            catch(Exception e){
                //logger.severe("Cannot execute stored procedure:"+ proc + "\nReason: " + e.getMessage());       
                throw e;
         *This method is only to hide QueueManager object from access from JumpProcessors
         *It handles exceptions and datbase connecting/disconnecting and is called from
         *JumpProceesor thread.
        public  void updateTaskStatus(int taskID, int status){       
            try{
                manager.updateTaskStatus(taskID, status);
            catch(Exception e){
                logger.severe("Cannot update status of task: " + taskID + " to " + status + "\nReason: " + e.getMessage());
        public java.sql.Connection getDBConnection(){
            try{
                return manager.getNewConnection();
            catch(Exception e){
                logger.severe("Cannot acquire new database connection: " + e.getMessage());
                return null;
        protected synchronized void setExecution(QueueTask task, boolean active){
            if(active){
                activeQueues.put(new Integer(task.getQueueNum()), JumpConstants.TH_STAT_BUSY);
            else{
                activeQueues.remove(new Integer(task.getQueueNum()));
        public static void main(String[] args){
                 try{
             System.out.println("The length-->"+args.length);
            System.out.println("It's " + new java.util.Date() + " now, have a good time.");
            if(args.length<5){
                System.out.println("More parameters needed:");
                System.out.println("1 - JDBC strign, 2 - DB User, 3 - DB Password, 4 - sleeping time (minutes), 5 - log file dir");
                return;
            Jump jump = new Jump(args[0], args[1], args[2], Integer.parseInt(args[3]), args[4]);
            Thread t1= new Thread(jump);
            jump.setMyThread(t1);      
            t1.start();}
                 catch(Exception e){
                      e.printStackTrace();
    } The exception i am getting is
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe
    Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820] Please help me.....
    Thanks in advance.....sathya

    I am not willing to wade through the code, but this portion makes me conjecture your using an Oracle connect string instead of a class name.
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe

  • Startup Problems with CQ5.6, Java 1.7, and OSX 10.8

    I'm having a problem with installing CQ5.6 on OSX 10.8 with Java 1.7.  Installing with Java 1.6 is ok, and on OSX 10.7 is ok, but the combo of 10.8 and java 1.7 is having problems.  I've found two issues, but it hasn't gotten us to a solution:
    1) Just out of the box, I get an error connecting to the repository, with the root cause :
    Caused by: java.io.IOException: Could not create a listener on any of the following ports: [8088, 8089, 8090, 8091, 8092, 8093], and could not connect to another cluster node
    I then found this answer: http://www.eyelock.net/blog/archives/490 - and tried starting up with that JVM startup param.
    2) Then, the IOException went away, but was left with the Unknown Host Exception - described here: http://blogs.adobe.com/dmcmahon/2012/09/03/cq5-5-javax-jcr-repositoryexception-unable-to-r egister-data-store-in-cluster/
    After modifying the hosts file and restarting, I'm still having problems.  Anyone else have problems with this combo?
    Thanks in advance.
    - David

    Hi David,
        The envirnoment you are running does it have internet connection?  Please try with adding alias[1].  If does not solve let us know exact stack trace.
    [1]    sudo ifconfig en0 alias 127.0.0.1   
    Thanks,
    Sham

  • Problem with a Timer (Java.util)

    Hello guys,
    I have a small problem with Java timer. The problem is I wanne do some task let's say after 5 seconds, so I created a timer and set its delay to 5000 milli seconds and run my program to see that the task is well performed but the program doesn't end. I tried the timer.cancel() method or tried to assign it to null.... but never works.
    So how do i make the program stop gracefully after the scheduled task finishes.
    My Code...
    int delay = 5000;  
              timer = new Timer();
              //timer.schedule(task, delay)
              final boolean flag =true;
              timer.schedule(new TimerTask() {
                   public void run() {
                        System.out.println("hello");       // the program is still waiting after executing this.... why?
              }, delay);
              // timer.cancel();     
              System.out.println("ccc"); // these two are printed gracefully before the scheduled task... that's good.
              System.out.println("ddd");So any idea on how to solve this problem... make the timer stop after executing the required task.
    Thanks in advance

    Have a read of the JavaDocs, someone went to great lengths to write these to save you headaches like this.
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Timer.html
    Have a play around with this code un-commenting the cancel, runTimerInDifferentScope and garbage collection call to see how it behaves each time.
    import java.util.Timer;
    import java.util.TimerTask;
    public class TimerExample {
         public static void main(String[] args) {
              final Timer timer = new Timer();
              timer.schedule(new TimerTask() {
                   @Override
                   public void run() {
                        System.out.println("[A] After 1 second!");
                        //timer.cancel();
              }, 1000);
              System.out.println("[A]");
              //runTimerInDifferentScope();
              //System.gc();
         private static void runTimerInDifferentScope() {
              final Timer timer = new Timer();
              timer.schedule(new TimerTask() {
                   @Override
                   public void run() {
                        System.out.println(" After 1 second!");
                        //No need to cancel me, I will be garbage collected
              }, 1000);
              System.out.println("[B]");
    Forgot to mention that the call to System.gc() was necessary to clear the timer. This is not something you should depend on (the garbage collector) in your application. I used it in this example because it's likely it would never run with such a small program and plenty of heap space left. If in doubt then use timer.cancel() as with the first example.
    Edited by: michael- on Dec 15, 2009 12:42 PM

  • Problem compiling a simple java file

    Hi,
    When I try to compile the following simple java file
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HowdyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    out.println("<html>");
    out.println("<body>");
    out.println("<center><h1>Hi</h1></center>");
    out.println("</body>");
    out.println("</html>");
    at the command prompt as follows
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
    "C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
    I get the following errors and I cannot compile this java file -
    HowdyServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HowdyServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    HowdyServlet.java:5: cannot find symbol
    symbol: class HttpServlet
    public class HowdyServlet extends HttpServlet {
    ^
    HowdyServlet.java:6: cannot find symbol
    symbol : class HttpServletRequest
    location: class HowdyServlet
    public void doGet(HttpServletRequest request,
    ^
    HowdyServlet.java:7: cannot find symbol
    symbol : class HttpServletResponse
    location: class HowdyServlet
    HttpServletResponse response)
    ^
    HowdyServlet.java:8: cannot find symbol
    symbol : class ServletException
    location: class HowdyServlet
    throws IOException, ServletException {
    ^
    6 errors
    I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
    CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
    PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
    ANT_HOME = C:\Sun\AppServer\lib\ant
    I have spent hours scratching my head but don?t have a clue. I was wondering if you have any idea as why I might be getting these errors.
    Thank you for your time.
    Green

    Hello, did you read the answers?
    You have to put j2ee.jar or servlet-api.jar in your classpath. Those JAR files are included in the Java EE package somewhere. Remove the QTJava.zip junk from the classpath.
    If you don't know what the classpath is and how to set it, read this:
    Setting the class path
    How Classes are Found
    And I'll repeat what the others say: if you are very new to Java, then Java EE will probably be way over your head. First learn the language and the standard API. If you understand that well, start with Java EE. Or do you already know what servlets are, and that you need a servlet container to run them, and how to deploy them etc.?

  • Help with a SIMPLE java thing

    I've only got ONE handful of hair left.
    I'm trying to build a series of dropdown boxes; a day dropdown (Mon, Tue, Wed...), a month dropdown (Jan, Feb, Mar...), a year dropdown, hour dropdown, minute dropdown, and an am/pm dropdown.
    I think I want to build my dropdowns using "for" loops something like this:
    for (i=0;i<12;i++) {
    myStringBuffer.append("<option>" + [someUnknownFunctionThatReturnsTheFirstThreeLettersOfTheMonth(i)] + "</option>")
    I've been trying to mix up various combinations of Date objects (most date functions seem to be depreciated), Calendar Objects, DateFormat Objects and SimpleDateFormat Objects but nothing seems to want to perform the function that I need.
    I've had iffy success creating a calendar object, setting the Month to "i", using the getTime function to return a Date object which I can then pass to the SimpleDateFormat object using the .format(Date) function, after setting the pattern to "EEE", but it seems like just an incredibly complicated way to do what ought to be a simple function...i.e. convert a number 0-11 (or 1-12, I'm not picky) into the name of a stinking Month! Arrgh.
    If anyone can help, I thank you.

    I've done that before, so i'll share it with you.
    import java.text.SimpleDateFormat;
    import java.text.DateFormatSymbols;
    import java.util.Calendar;
    import java.util.Date;
    public String createListOfMonth(String pName) {
    StringBuffer sbMonth = new StringBuffer();
    DateFormatSymbols fm = new DateFormatSymbols();
    String[] arrMonth = fm.getMonths();
    sbMonth.append("<select name=\"" + pName + "\">");
    sbMonth.append("     <option value=\"\">Month</option>\n");
    for (int i=0; i<arrMonth.length; i++) {
    if (!arrMonth.trim().equals("")) {
    String sValue = "0000" + (i + 1);
    sValue = sValue.substring(sValue.length() - 2);               
    sbMonth.append("     <option value=\"" + sValue + "\">" + arrMonth[i] + "</option>\n");
    sbMonth.append("</select>");
    return (sbMonth.toString());
    You can manipulate the symbol (either for months, days) using different locale. You can see the API for java.text.DateFormatSymbols in Java2 SE.
    Regards,
    Hariyanto

  • Probleme with versions of java

    I've copmiled my Applet with java
    1.3.1_16 but doesn't work with the 1.3.1_01 version

    What else did you expect? You can't expect that your applet works with all older java versions... And what is the problem???
    Thea

Maybe you are looking for

  • Purchased movie does not show up in Apple tv

    Hello, I just bought a movie (Valkryie with Tom Cruise)...and for some reason it does not show up in my purchased movies on any of my devices (Apple TV, iPhone) and it also does not show up as purchased in my iTunes library. This is the only movie wh

  • Connecting Linksys WRT610N to WRT160N

    Hi, I was hoping someone could help me with configuring my network which I'm new at. What I have down stairs in my office is a Linksys WRT610N router which is connected to the socket my broadband comes through and my PC. The router is also connected

  • IPad mini video issues

    I just bought my first Apple product.. Not a good experience so far.. I purchased an iPad Mini so that I can record some videos then upload them to my PC to do some video editing. At work we have an iPad Air and it works great every time! When I do t

  • Building a dvd with custom disk size (disk, ISO, or dvd folder)

    My goal at the end of all this is to get a DVD format of video at 6mbps with menu's to be burned to a blu-ray 25GB disk. Using Encore CS6 on a Windows 7 (4.7Gzh 8-core, 16gb ram @2400mhz) 1st attempt:  I used a bluray disk and tried to burn a dvd for

  • Can't download the trial version of Adope Pdf Pack.

    Downloaded the "adope download assistant" ,signed in and nothing appears under "all products" . How to procces further ? Thanks