I am getting an infinite loop.  Why?

This small block of code is giving me an infinite loop. I can't understand why. The file is called "owners.dat" and it only has 10 lines. The purpose of this block of code is to count how many lines are in a file. What the heck is going on here?
               Scanner countFile = new Scanner(new FileReader("owners.dat"));
               while (countFile.hasNextLine())
                    size = size +1;
               }Thanks for any advice

You're never advancing the file, you're just continually checking that it has a next line, which it always does. You need to call Scanner.nextLine() in the loop.
BufferedReader.readLine() would be a lot more efficient if this is a large file, but then why do you need to know the number of lines in a file at all?

Similar Messages

  • Why am I getting an infinite loop?

    I have a for loop that never stops as the question suggests. If the boolean expression is true the loop does not stop. I tried tracing the loop and still cant figure out the solution. Please help. The code where the error is below with comments where the error is encountered:
        public static void printGame()
             //DECLARING
             //User input, height of wall
             int height = 0;
             //User input, how much R2-D2 climbs each day
             int climb;
             //User input, how much R2-D2 slips each day
             int slip;
             //Count of how many days it takes for R2-D2 leaves
             int count = 1;
             //Total after each day which is total + climb - slip
             int total = 0; 
             //User input, play again option
             char plyagn;
             //Gameplay         
             System.out.println("Please type in the height of the wall");
             //Height input
             height = In.getInt();
             System.out.println("Please type in how much R2-D2 climbs each day");
             //Climb input
             climb = In.getInt();
             System.out.println("Please type in how much R2-D2 slips each day");
             //Slip input
             slip = In.getInt();
             //Evaluation       
             for( ; height != total; count++) //<----My ERROR which is an infinite loop that never exits
                  total = total + climb - slip;
                  System.out.println(total); //I tried tracing the error
                  System.out.println(height); //I tried tracing the error
              //Printing the result of the evaluation
             System.out.println("R2-D2 will leave on the " + count + " day");
             System.out.println("Press Enter to continue");
             In.getChar();
             clear();
             System.out.println("Do you want to play again? (y/n)");
             plyagn = In.getChar();
             //If statment, prints appropriate message if or if not to play again
             if(plyagn == 'y' || plyagn == 'Y')
                  printMenu();
             //If n or any other value end program
             else
                  printEnd();
        }//End of printGame method

    flounder wrote:
    Lets say th variables have these values
    height = 10
    climb = 4
    slip = 1 which effectively adds 3 to total at each step.
    So total is 0, 3, 6, 9, 12, 15, 18 etc
    Total will always be not equal to height.
    So change your condition. Also, why are you using a for loop instead of a while loop.Flounder, I was hoping you would answer my question as you always provide good answers. Continuing, I feel so dumb for missing that error. Oh and as for using the for loop instead of a while loop is something i was meaning to change. Anyhow, Thank You.

  • PDF Forms in Firefox - infinite loop

    Howdy,
         I am a developer who is using PDF forms (FDF) to populate data into a database via form submission. Everything works fine on Internet Explorer but, on Firefox 3.6.17 with Adobe Reader X, I either end up getting a blank form when launched from an FDF which has valid data OR, I get into a situation where new firefox windows come up continuously in what appears to be an infinite loop (have to log out to end the recursion). Anyway, figured I'd see if anybody here had seen that before and, if so, if there's a solution to it?
    Thanks!

    I have a similar problem, but apparently in the inverse direction. We recently "upgraded" to Acrobat X (Version 10.1).
    I have a web application that uses data in a database to populate a PDF form displayed in a browser window. (Display in browser window is checked.) At the beginning of August, we started to get an infinite loop whenever trying to display the form.
    Behavior pattern:
    (1) Click the link that's supposed to open the new form. A new IE window opens (as is supposed to happen). Status says "connecting" but there's nothing in the  URL.
    (2) 1/2 second later, a file download popup appears.
    (3) 1/2 second later,  Adobe Acrobat window appears (as if I had run Acrobat as a program). There are 4  windows on the screen at this point, including the normal application window.
    (4) After a 1/2  second delay, system goes into infinite loop, displaying (1) and (2) in an  infinite sequence.Window 3 (Acrobat) seems to simply stay open. Howeve
    Cycle time is about 1/2 second for all 3  popup windows to display one time. This occurs on 19 different  computers (different models, but all running Windows Vista Enterprise, Internet Explorer 7 and Acrobat 10.1.

  • A problem with infinite loop

    Hi there! My program has to get data on two species in any order and respond by telling how many years it will take for the species with lower population outnumber the species that starts with higher population. If the species with the smaller population never outnumbers the species with the higher population I'll get an infinite loop. What is the right approach here?
    Thanks.
    public class Species
    private String name1;name2
    private int population1, population2;
    private double growthRate1, growthRate2;
    public void readInput( )
    System.out.println("What is the first species' name?");
    name1 = SavitchIn.readLine( );
    System.out.println("What is the population of the species?");
    population1 = SavitchIn.readLineInt( );
    while (population1 < 0)
    System.out.println("Population cannot be negative.");
    System.out.println("Reenter population:");
    population1 = SavitchIn.readLineInt( );
    System.out.println(
    "Enter growth rate (percent increase per year):");
    growthRate1 = SavitchIn.readLineDouble( );
    ystem.out.println("What is the second species' name?");
    name2 = SavitchIn.readLine( );
    System.out.println("What is the population of
    the species?");
    population2 = SavitchIn.readLineInt( );
    while (population2 < 0)
    System.out.println("Population cannot be negative.");
    System.out.println("Reenter population:");
    population2 = SavitchIn.readLineInt( );
    System.out.println(
    "Enter growth rate (percent increase per year):");
    growthRate2 = SavitchIn.readLineDouble( );
    public void writeOutput( )
    System.out.println("Name of the species' = " + name1);
    System.out.println("Population = " + population1);
    System.out.println("Growth rate = " + growthRate1 + "%");
    System.out.println("Name of the species' = " + name2);
    System.out.println("Population = " + population2);
    System.out.println("Growth rate = " + growthRate2 + "%");
    public void OutnumbersPopulation()
    double max, min;
    int years=0
    if(population1>population2)// this is to determine which population is smaller
    max=population1;
    min=population2;
    else if (population2>population1)
    max=population2;
    min=population1;
    while ((years > 0) && (min <=max))//This could be an infinite loop if min never outnumbers max
    min= (min +
    (growthRate/100) * min);
    max=(max + (growthRate/100) * max);
    years ++;
    System.out.println("The species with the lower population will outnumber the species with higher population
    in" + (years+1) + "years");

    Cross post. original is in "New to Java Technology".

  • Alert Component with OnKillFocus Causes Infinite Loop

    I have this script...
    txtPPM.onKillFocus = function(txtPPM)
    import mx.controls.Alert;
    Alert.show("blah blah");
    When my focus shifts away from the txtPPM textfield I get an
    infinite loop error. I haven't been able to find a successful
    method to fix this. Any suggetions?

    Probably related to the FocusManager (V2 components). There
    may be other
    ways to work around it, but here's something quick:
    import mx.controls.Alert;
    var alertClickHandler:Function = function (evt_obj:Object) {
    switch (evt_obj.detail) {
    case Alert.OK :
    trace("You clicked: " + Alert.okLabel);
    break;
    case Alert.CANCEL :
    trace("You clicked: " + Alert.cancelLabel);
    break;
    txtPPM.onKillFocus = txtFocusHandler;
    function showAlert(){
    Alert.show("blah blah blah", "", undefined, this,
    alertClickHandler);
    function txtFocusHandler(newFocus:Object){
    this.onKillFocus = undefined;
    showAlert();
    txtPPM.onKillFocus = txtFocusHandler;

  • MS-6390 and Radeon 9200SE "infinite loop" error

    I recently installed a radeon 9200SE PCI graphics card, and after about a week of perfect operation I began getting the "infinite loop" error. I've tried every fix I can find and nothing works, and upgrading my motherboard isnt an option since I can't afford it.
    Anyone have any ideas as to how I can fix this?

    tried another pci slot with it?

  • Infinite looping code. Why?

    Hi,
    Have 2 rules. Rule 1, searches IdM repository for users matching params entered by a user. This rule generates a list as [GenericObject:000001,GenericObject:000034]. I pass this list to the searchResultList variable in rule below (Rule2) which (atlease I expect to) gets teh firstname aand sotre number from the GenericObjects in the list generated by Rule1.However, Rule2 always goes in a infinite loop, adn I dont understand why? Can any one help me pleae?
    <block trace='true'>
      <defvar name='displaysearchlist'>
        <dolist name='searchlist'>
          <ref>searchResultList</ref>
          <defvar name='displaystring1'>
            <get>
              <ref>searchlist</ref>
              <s>firstname</s>
            </get>
          </defvar>
          <defvar name='displaystring2'>
            <get>
              <ref>searchlist</ref>
              <s>storenumber</s>
            </get>
          </defvar>
          <append name='displaysearchlist'>
            <concat>
              <ref>displaystring1</ref>
              <s> - </s>
              <ref>displaystring2</ref>
            </concat>
          </append>
        </dolist>
      </defvar>
      <ref>displaysearchlist</ref>
    </block>Thanks in advance.

    When you use the defvar the variable isn't actually created until it is referenced, which then goes back and uses the code to set the variable. So the defvar outside the list is evaluated when you call the displaysearchlist inside the dolist, creating the infinite loop.
    since you are appending the list inside the dolist, use defvar name displaysearchlist, then set it to null.
    ie
    <defvar name='displaysearchlist'/>
    <set name='displaysearchlist'>
    <null/>
    </set>
    <dolist...
    David

  • Why does javadoc goes into an infinite loop

    at my dos prompt , in the same directory as my Page.java file, i type javadoc Page.java
    why does it go into an infinite loop? instead of producing any documentation
    it just says for example
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    javadoc Page.java
    Stephen

    this is a sample page -- i'm using jdk 1.4 trying to run javadoc Tracer.class or javadoc Tracer.java or javadoc Tracer gives throws the console into an infinite loop with the statement being printed over and over again. But i haven't just noticed this problem with javadoc -- i noticed this problem with certain types of mistakes in the code rather than just displaying the compiler error -- it creates this infinite loop in the dos console window. any thoughts ?
    here is my version.
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    * Tracer.class logs items according to the following criteria:
    * 2 = goes to text file Crawler_log.txt
    * 1 = goes to console window because it is higher priority.
    * @author Stephen
    * @version 1.0
    * @since June 2002
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    class Tracer{
         public static void log(int traceLevel, String message, Object value)
              pout.write(getLogFileDate(new Date()) +" >" + message + " value = " + value.toString());
         public static void log(int traceLevel, String message )
              pout.write("HI HOW ARE YOU " ) ;
              pout.flush();
         //public static accessor method
         public static Tracer getTracerInstance()
              return tracerInstance;
         private static String getLogFileDate(Date d )
              String s = df.format(d);
              String s1= s.replace(',','-');
              String s2= s1.replace(' ','-');
              String s3= s2.replace(':','.');
              System.out.println("getLogFileDate() = " + s3 ) ;
              return s3;
         //private instance
         private Tracer(){
              System.out.println("Tracer constructor works");
              df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
              date                    = new java.util.Date();
              try{
              pout = new PrintWriter(new BufferedWriter(new FileWriter("Crawler_log"+getLogFileDate(new Date())+".txt", true)));
              pout.write("**************** New Log File Created "+ getLogFileDate(new Date()) +"****************");
              pout.flush();
              }catch (IOException e){
              System.out.println("**********THERE WAS A CRITICAL ERROR GETTING TRACER SINGLETON INITIALIZED. APPLICATION WILL STOP EXECUTION. ******* ");
         public static void main(String[] argz){
         System.out.println("main method starts ");
         Tracer tt = Tracer.getTracerInstance();
         System.out.println("main method successfully gets Tracer instance tt. "+ tt.toString());
         //the next method is where it fails - on pout.write() of log method. Why ?
         tt.log(1, "HIGH PRIORITY");
         System.out.println("main method ends ");
         //private static reference
         private static Tracer tracerInstance = new Tracer();
         private static Date date     = null;
         private static PrintWriter pout = null;
         public static DateFormat df = null;
    }

  • ITunes update to 4.0 requires checking 32-bit mode in "Get Info" window. No such checkbox exists. iTunes refuses to launch. iMac 27-in., Mac OS 10.6.8. Tried re-installing iTunes 4, but went into infinite loop while in "Registering Installed Components"

    After updating to iTunes 4, launching the application indicated that 64-bit mode was only available in Mac OS 10.7 Lion and to use in 32-bit mode by checking the 32-bit mode checkbox in the iTunes "Get Info" window. However, this window does not have the aforementioned checkbox. Thus, iTunes is now unusable.  Tried to download fresh install from Apple site, but this process went into an infinite loop during the "registering installed components" phase of the installation. Had to force quit. System is iMac 27-inch, Core i7 processor, Mac OS 10.6.8.  Is there a problem with iTunes 4? Can I go back to the previous version? Thanks.

    Ah! I found several other people with the same problem in this forum. I followed the suggestion to move iTunes 4 from the "Applications" to the desktop and launch it from there. It worked! I moved it back into the Application folder and its still okay.  Thanks!  This is a definitely a bug that Apple needs to address quickly.

  • Hasmap.put,get infinite loop, 27.6 optimizer problem

    Helo,
    We have a very busy (3000 users) Weblogic Portal and Weblogic Integration instance.
    We found that some times (once a week) weblogic server threads go to infinite loop doing hasmap.get, hashmap put or hashmap remove operations.
    Our developers found that there are synchronization problems with hashmap operations in the portal and wli code, (in 5 classes until today) they patched (synchronized) it and now the instances are stable.
    We contacted oracle support, but they only recommended us some wlw.. setting, none of them worked.
    The strange thing that the code that we patched is existed in weblogic server for years, so I tried to exclude the hasmap class from the optimizer in jrockit.opt file. Now the instances are also stable without the inhouse patches.
    So I suspect theh the jrockit optimizer optimize the hasmap class after some time in a wrong way; how can I find some evidence about it?
    The thead dumps showing only the hasmap operations and very high cpu usage.
    We are on Jrockit 27.6, JVM 1.5, Portal and WLI 9.2MP3
    Regards,
    LJ

    Not sure if it is relevant to the issues you describe in this thread, but a common problem with HashMaps is incorrect (missing) synchronization on concurrent operations. If you do have several threads concurrently accessing a HashMap without synchronization, it might mess up the internal data structures in the HashMap object. This can lead to infiinite loops when trying to iterate through the HashMap at some later time. This problem is not JVM-specific but changes in timing due to different JVM versions, JIT compilation/optimization or different HW etc can cause a previous "stable" program to become "unstable".
    I've seen a number of JRockit support issues related to this problem over the years, and in almost all cases it's been a problem in the Java code (which could be WLS, or the user application).
    Unfortunately it's far from trivial to troubleshoot concurrency issues. One (slow) way of checking your own code is to wrap all HashMaps in a SynchronizedMap. This will slow down your application but if the problem goes away then it's a good indication of the root cause. Not very useful if the problem is in 3rd party code that you don't have the source for, of course. In that case you have to open a ticket with the vendor (Oracle or other 3rd party).
    Cheers,
    Henrik

  • Can anyone figure out why this runs into an infinite loop?

    Hi,
    I have the following class, and if i run it, I encounter an infinite loop. I have pinpointed the problem and it is because of the lines:
    try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception exp) {
                   System.err.println("Failed");
                exp.printStackTrace();
            }Here is the class. Any and all help is greatly appreciated. Thanks!
    package org.aemf.clinical.tol.gui.printing;
    import org.aemf.clinical.tol.model.TOLBion;
    import org.aemf.clinical.tol.model.Range;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.*;
    import java.awt.print.*;
    import java.awt.*;
    import java.util.Iterator;
    import java.util.ArrayList;
    * Created by IntelliJ IDEA.
    * User: arashn
    * Date: Feb 9, 2005
    * Time: 1:26:38 PM
    public class printTableTest implements Printable, Pageable {
         private PageFormat pf;
         private String[] headers = { "Heading 1", "Heading 2", "Heading 3"};
         private java.util.List bions = null;
         private ArrayList<Object[][]> data = new ArrayList<Object[][]>();
         public printTableTest(PageFormat format) {
              this.pf = format;
         public int getNumberOfPages() {
            return 1;
        public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
            return pf;
         public void setBions(java.util.List b) {
              bions = b;
              for(int x=0; x < 3; x++) {
                   //TOLBion bion = (TOLBion) bions.get(x);
                   int ndx = 0;
                   //Object[][] tempData = new Object[bion.getNumRanges()][3];
                   Object[][] tempData = new Object[2][3];
              //     for (Iterator itr = bion.getRanges(); ndx < 2 && itr.hasNext(); ) {
                   for (; ndx < 2 ; ) {
                   // Range range = (Range)itr.next();
                        //tempData[ndx] = new Object[] { new Integer(range.getFrequency()), range.getLowerBound(), range.getUpperBound() };
                        tempData[ndx] = new Object[] { "col 1: " + x, "col 2: " + x, "col 3: " + x };
                        ndx++;
                   data.add(tempData);
        public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
            return this;
         public int print(Graphics g, PageFormat format, int pageIndex) throws PrinterException {
              if(pageIndex > 1) {
                   return Printable.NO_SUCH_PAGE;
                                                                              System.err.println("Page: " + pageIndex);
              JFrame frame = null;
              JTable tableView = null;
              Graphics2D g2 = (Graphics2D) g;
              //Object[][] data = new Object[3][3];
              g2.setColor(Color.black);
              g2.translate(format.getImageableX() + 72, format.getImageableY() + 72);
              for(int x=0; x < data.size(); x++) {
                   tableView = new JTable(new PrintTableModel(headers, data.get(x)));
                   frame = new JFrame();
                   JScrollPane scrollpane = new JScrollPane(tableView);
                   scrollpane.setPreferredSize(new Dimension(300, 80));
                   frame.getContentPane().setLayout(new BorderLayout());
                   frame.getContentPane().add(BorderLayout.CENTER,scrollpane);
                   frame.pack();
                   tableView.paint(g2);
                   g2.translate(0, - tableView.getTableHeader().getHeight());
                   tableView.getTableHeader().paint(g2);
                   g2.translate(0, format.getImageableHeight()/3);
              return Printable.PAGE_EXISTS;
         public static void main(String args[]) {
              PrinterJob printerJob = PrinterJob.getPrinterJob();
              try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception exp) {
                   System.err.println("Failed");
                exp.printStackTrace();
             int INCH = 72;
              double LETTER_WIDTH = 8.5 * INCH;
              double LETTER_HEIGHT = 11 * INCH;
            Paper paper = new Paper();
              int margin = INCH/6; // << set your margins here
              double pageWidth = LETTER_WIDTH - 2 * margin;
              double pageHeigth = LETTER_HEIGHT - 2 * margin;
              paper.setImageableArea(margin, margin, pageWidth, pageHeigth) ;
              PageFormat format = printerJob.defaultPage();
              format.setPaper(paper);
            printTableTest pp = new printTableTest(format);
            pp.setBions(new ArrayList());
              printerJob.setPageable(pp);
              boolean doPrint = printerJob.printDialog();
              if (doPrint) {
                   try {
                        printerJob.print();
                   } catch (PrinterException exception) {
                        System.err.println("Printing error: " + exception);
             System.exit(0);
         private class PrintTableModel extends AbstractTableModel {
              private Object[][] data = null;
              private String[] headers = null;
              public PrintTableModel(String[] headers, Object[][] data) {
                   this.headers = headers;
                   this.data = data;
              public int getColumnCount() { return headers.length; }
              public int getRowCount() { return data.length; }
              public Object getValueAt(int row, int col) { return data[row][col]; }
              public String getColumnName(int column) { return headers[column]; }
              public Class getColumnClass(int col) { return getValueAt(0,col).getClass(); }
              public boolean isCellEditable(int row, int col) { return false; }
              public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; }
    }

    I have managed to create an even simpler version which tries to print the same header 3 times. Again, if you remove the setLookAndFeel line, everything works out great.
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.print.*;
    import java.awt.*;
    * Created by IntelliJ IDEA.
    * User: arashn
    * Date: Feb 9, 2005
    * Time: 1:26:38 PM
    public class printTableTest implements Printable, Pageable {
         private PageFormat pf;
         public printTableTest(PageFormat format) {
              this.pf = format;
         public int getNumberOfPages() {
            return 1;
        public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
            return pf;
        public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
            return this;
         public int print(Graphics g, PageFormat format, int pageIndex) throws PrinterException {
              if(pageIndex > 1) {
                   return Printable.NO_SUCH_PAGE;
              System.err.println("Printing Page: " + pageIndex);
              Graphics2D g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              g2.translate(format.getImageableX() + 72, format.getImageableY() + 72);
              DefaultTableColumnModel dtcm = new DefaultTableColumnModel();
              TableColumn tc = new TableColumn();
              tc.setHeaderValue("Heading 1");
              dtcm.addColumn(tc);
              tc.setHeaderValue("Heading 2");
              dtcm.addColumn(tc);
              tc.setHeaderValue("Heading 2");
              dtcm.addColumn(tc);
              JTableHeader tableHeader = new JTableHeader(dtcm);
              JScrollPane scrollpane2 = new JScrollPane(tableHeader);
              scrollpane2.setPreferredSize(new Dimension(300, 80));
              JFrame frame2 = new JFrame();
              frame2.getContentPane().add(BorderLayout.NORTH,scrollpane2);
              frame2.pack();
              for(int x=0; x < 3; x++) {                   
                   tableHeader.paint(g2);
                   g2.translate(0, format.getImageableHeight()/3);
              return Printable.PAGE_EXISTS;
         public static void main(String args[]) {
              PrinterJob printerJob = PrinterJob.getPrinterJob();
              try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception exp) {
                   System.err.println("Failed");
                exp.printStackTrace();
             int INCH = 72;
              double LETTER_WIDTH = 8.5 * INCH;
              double LETTER_HEIGHT = 11 * INCH;
            Paper paper = new Paper();
              int margin = INCH/6; // << set your margins here
              double pageWidth = LETTER_WIDTH - 2 * margin;
              double pageHeigth = LETTER_HEIGHT - 2 * margin;
              paper.setImageableArea(margin, margin, pageWidth, pageHeigth) ;
              PageFormat format = printerJob.defaultPage();
              format.setPaper(paper);
            printTableTest pp = new printTableTest(format);
              printerJob.setPageable(pp);
              boolean doPrint = printerJob.printDialog();
              if (doPrint) {
                   try {
                        printerJob.print();
                   } catch (PrinterException exception) {
                        System.err.println("Printing error: " + exception);
             System.exit(0);
    }

  • SQL stored procedure Staging.GroomDwStagingData stuck in infinite loop, consuming excessive CPU

    Hello
    I'm hoping that someone here might be able to help or point me in the right direction. Apologies for the long post.
    Just to set the scene, I am a SQL Server DBA and have very limited experience with System Centre so please go easy on me.
    At the company I am currently working they are complaining about very poor performance when running reports (any).
    Quick look at the database server and CPU utilisation being a constant 90-95%, meant that you dont have to be Sherlock Holmes to realise there is a problem. The instance consuming the majority of the CPU is the instance hosting the datawarehouse and in particular
    a stored procedure in the DWStagingAndConfig database called Staging.GroomDwStagingData.
    This stored procedure executes continually for 2 hours performing 500,000,000 reads per execution before "timing out". It is then executed again for another 2 hours etc etc.
    After a bit of diagnosis it seems that the issue is either a bug or that there is something wrong with our data in that a stored procedure is stuck in an infinite loop
    System Center 2012 SP1 CU2 (5.0.7804.1300)
    Diagnosis details
    SQL connection details
    program name = SC DAL--GroomingWriteModule
    set quoted_identifier on
    set arithabort off
    set numeric_roundabort off
    set ansi_warnings on
    set ansi_padding on
    set ansi_nulls on
    set concat_null_yields_null on
    set cursor_close_on_commit off
    set implicit_transactions off
    set language us_english
    set dateformat mdy
    set datefirst 7
    set transaction isolation level read committed
    Store procedures executed
    1. dbo.p_GetDwStagingGroomingConfig (executes immediately)
    2. Staging.GroomDwStagingData (this is the procedure that executes in 2 hours before being cancelled)
    The 1st stored procedure seems to return a table with the "xml" / required parameters to execute Staging.GroomDwStagingData
    Sample xml below (cut right down)
    <Config>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    </Config>
    If you look carefully you will see that the 1st <target> is missing the ManagedTypeViewName, which when "shredded" by the Staging.GroomDwStagingData returns the following result set
    Example
    DECLARE @Config xml
    DECLARE @GroomingCriteria NVARCHAR(MAX)
    SET @GroomingCriteria = '<Config><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><Watermark>2015-01-30T08:59:14.397</Watermark></Target><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName><Watermark>2015-01-30T08:59:14.397</Watermark></Target></Config>'
    SET @Config = CONVERT(xml, @GroomingCriteria)
    SELECT
    ModuleName = p.value(N'child::ModuleName[1]', N'nvarchar(255)')
    ,WarehouseEntityName = p.value(N'child::WarehouseEntityName[1]', N'nvarchar(255)')
    ,RequiredWarehouseEntityName =p.value(N'child::RequiredWarehouseEntityName[1]', N'nvarchar(255)')
    ,ManagedTypeViewName = p.value(N'child::ManagedTypeViewName[1]', N'nvarchar(255)')
    ,Watermark = p.value(N'child::Watermark[1]', N'datetime')
    FROM @Config.nodes(N'/Config/*') Elem(p)
    /* RESULTS - NOTE THE NULL VALUE FOR ManagedTypeViewName
    ModuleName WarehouseEntityName RequiredWarehouseEntityName ManagedTypeViewName Watermark
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity NULL 2015-01-30 08:59:14.397
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity 2015-01-30 08:59:14.397
    When the procedure enters the loop to build its dynamic SQL to delete relevant rows from the inbound schema tables it concatenates various options / variables into an executable string. However when adding a NULL value to a string the entire string becomes
    NULL which then gets executed.
    Whilst executing "EXEC(NULL)" would cause SQL to throw an error and be caught, executing the following doesnt
    DECLARE @null_string VARCHAR(100)
    SET @null_string = 'hello world ' + NULL
    EXEC(@null_string)
    SELECT @null_string
    So as it hasnt caused an error the next part of the procedure is to move to the next record and this is why its caught in an infinite loop
    DELETE @items WHERE ManagedTypeViewName = @View
    The value for the variable @View is the ManagedTypeViewName which is NULL, as ANSI_NULLS are set to ON in the connection and not overridded in the procedure then the above statement wont delete anything as it needs to handle NULL values differently (IS NULL),
    so we are now stuck in an infinite loop executing NULL for 2 hours until cancelled.
    I amended the stored procedure and added the following line before the loop statement which had the desired effect and "fixed" the performance issue for the time being
    DELETE @items WHERE ManagedTypeViewName IS NULL
    I also noticed that the following line in dbo.p_GetDwStagingGroomingConfig is commented out (no idea why as no notes in the procedure)
    --AND COALESCE(i.ManagedTypeViewName, j.RelationshipTypeViewName) IS NOT NULL
    There are obviously other ways to mitigate the dynamic SQL string being NULL, there's more than one way to skin a cat and thats not why I am asking this question, but what I am concerned about is that is there a reason that the xml / @GroomingCriteria is incomplete
    and / or that the procedures dont handle potential NULL values.
    I cant find any documentation, KBs, forum posts of anyone else having this issue which somewhat surprises me.
    Would be grateful of any help / advice that anyone can provide or if someone can look at their 2 stored procedures on a later version to see if it has already been fixed. Or is it simply that we have orphaned data, this is the bit that concerns most as I dont
    really want to be deleting / updating data when I have no idea what the knock on effect might be
    Many many thanks
    Andy

    First thing I would do is upgrade to 2012 R2 UR5. If you are running non-US dates you need the UR5 hotfix also.
    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click
    here

  • Infinite loop error after using Java Sun Tutorial for Learning Swing

    I have been attempting to create a GUI following Sun's learning swing by example (example two): http://java.sun.com/docs/books/tutorial/uiswing/learn/example2.html
    In particular, the following lines were used almost word-for-word to avoid a non-static method call problem:
    SwingApplication app = new SwingApplication();
    Component contents = app.createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);I believe that I am accidentally creating a new instance of the gui class repeatedly (since it shows new GUI's constantly and then crashes my computer), possibly because I am creating an instance in the main class, but creating another instance in the GUI itself. I am not sure how to avoid this, given that the tutorials I have seen do not deal with having a main class as well as the GUI. I have googled (a nice new verb) this problem and have been through the rest of the swing by example tutorials, although I am sure I am simply missing a website that details this problem. Any pointers on websites to study to avoid this problem would be appreciated.
    Thanks for your time-
    Danielle
    /** GUI for MicroMerger program
    * Created July/06 at IARC
    *@ author Danielle
    package micromerger;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.swing.JFileChooser;
    import java.lang.Object;
    public class MGui
         private static File inputFile1, inputFile2;
         private static File sfile1, sfile2;
         private static String file1Name, file2Name;
         private String currFile1, currFile2;
         private JButton enterFile1, enterFile2;
         private JLabel enterLabel1, enterLabel2;
         private static MGui app;
         public MGui()
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        System.out.println("About to run create GUI method");
                        app = new MGui();
                        System.out.println("declared a new MGui....");
                        createAndShowGUI();
         //initialize look and feel of program
         private static void initLookAndFeel() {
            String lookAndFeel = null;
         lookAndFeel = UIManager.getSystemLookAndFeelClassName();
         try
              UIManager.setLookAndFeel(lookAndFeel);
         catch (ClassNotFoundException e) {
                    System.err.println("Couldn't find class for specified look and feel:"
                                       + lookAndFeel);
                    System.err.println("Did you include the L&F library in the class path?");
                    System.err.println("Using the default look and feel.");
                } catch (UnsupportedLookAndFeelException e) {
                    System.err.println("Can't use the specified look and feel ("
                                       + lookAndFeel
                                       + ") on this platform.");
                    System.err.println("Using the default look and feel.");
                } catch (Exception e) {
                    System.err.println("Couldn't get specified look and feel ("
                                       + lookAndFeel
                                       + "), for some reason.");
                    System.err.println("Using the default look and feel.");
                    e.printStackTrace();
         // Make Components--
         private Component createLeftComponents()
              // Make panel-- grid layout
         JPanel pane = new JPanel(new GridLayout(0,1));
            //Add label
            JLabel welcomeLabel = new JLabel("Welcome to MicroMerger.  Please Enter your files.");
            pane.add(welcomeLabel);
         //Add buttons to enter files:
         enterFile1 = new JButton("Please click to enter the first file.");
         enterFile1.addActionListener(new enterFile1Action());
         pane.add(enterFile1);
         enterLabel1 = new JLabel("");
         pane.add(enterLabel1);
         enterFile2 = new JButton("Please click to enter the second file.");
         enterFile2.addActionListener(new enterFile2Action());
         pane.add(enterFile2);
         enterLabel2 = new JLabel("");
         pane.add(enterLabel2);
         return pane;
         /** Make GUI:
         private static void createAndShowGUI()
         System.out.println("Creating a gui...");
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("MicroMerger");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //Add stuff to the frame
         //MGui app = new MGui();
         Component leftContents = app.createLeftComponents();
         frame.getContentPane().add(leftContents, BorderLayout.WEST);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    private class enterFile1Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile1 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file1Name = inputFile1.getName();
                   enterLabel1.setText(file1Name);
    private class enterFile2Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile2 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file2Name = inputFile2.getName();
                   enterLabel2.setText(file2Name);
    } // end classAnd now the main class:
    * Main.java
    * Created on June 13, 2006, 2:29 PM
    * @author Danielle
    package micromerger;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Main
        /** Creates a new instance of Main */
        public Main()
         * @param args the command line arguments
        public static void main(String[] args)
            MGui mainScreen = new MGui();
            //mainScreen.setVisible(true);
            /**Starting to get file choices and moving them into GPR Handler:
             System.out.println("into main method");
         String file1Name = new String("");
             file1Name = MGui.get1Name();
         System.out.println("good so far- have MGui.get1Name()");
        }// end main(String[] args)
    }// end class Main

    um, yeah, you definitely have a recursion problem, that's going to create an infinite loop. you will eventually end up an out of memory error, if you don't first get the OS telling you you have too many windows. interestingly, because you are deferring execution, you won't get a stack overflow error, which you expect in an infinite recursion.
    lets examine why this is happening:
    in main, you call new MGui().
    new MGui() creates a runnable object which will be run on the event dispatch thread. That method ALSO calls new MGui(), which in turn ALSO creates a new object which will be run on the event dispatch thead. That obejct ALSO calls new MGui(), which ...
    well, hopefully you get the picture.
    you should never unconditionally call a method from within itself. that code that you have put in the constructor for MGui should REALLY be in the main method, and the first time you create the MGui in the main method as it currently exists is unnecessary.
    here's what you do: get rid of the MGui constructor altogether. since it is the implicit constructor anyway, if it doesn't do anything, you don't need to provide it.
    now, your main method should actually look like this:
    public static void main( String [] args ) {
      SwingUtilities.invokeLater( new Runnable() {
        public void run() {
          MGui app = new MGui();
          app.createAndShowGUI();
    }// end mainyou could also declare app and call the constructor before creating the Runnable, as many prefer, because you would have access to it from outside of the Runnable object. The catch there, though, is that app would need to be declared final.
    - Adam

  • Infinite loop/afrLoop when deploying ADF application to standalone weblogic

    Working with Oracle ADF / JDeveloper 11.1.2.2
    I have enabled ADF security in my application and am using JAAS combined with Oracle EBS users and roles to provide security to the application. Testing on my local integrated weblogic server works fine.
    When deploying my Oracle ADF application to a standalone Weblogic server through an EAR file, requesting a JSF page causes the server to go into an infinite loop on both IE and firefox.
    GET /test-app/faces/login.jsf HTTP/1.1     200
    GET /test-app/faces/login.jsf?_afrLoop=346001033248597&_afrWindowMode=0&Adf-Window-Id=w0 HTTP/1.1     302
    GET /test-app/adfAuthentication HTTP/1.1     302
    GET /test-app/faces/login.jsf HTTP/1.1     200
    GET /test-app/faces/login.jsf?_afrLoop=346001340281597&_afrWindowMode=0&Adf-Window-Id=w0 HTTP/1.1     302
    GET /test-app/adfAuthentication HTTP/1.1     302
    GET /test-app/faces/login.jsf;jsessionid=syWvP1nMY1L87BySh2JbTd1tb4SY0HzDw6T3LvLctvkbMWKmqqJv!1800986117 HTTP/1.1     200
    GET /test-app/adfAuthentication HTTP/1.1
    Reviewing some of the suggestions from the forum and from the link below, I have tried fixing the issue through updates to my web.xml - but am still having the same issue.
    https://blogs.oracle.com/jdevotnharvest/entry/solving_jdeveloper_11gr2_issue_with
    Updated web.xml:
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Allowed ADF Resources</web-resource-name>
    <url-pattern>/adf/*</url-pattern>
    <url-pattern>/afr/*</url-pattern>
    <url-pattern>/bi/*</url-pattern>
    <url-pattern>/servlet/GraphServlet/*</url-pattern>
    <url-pattern>/servlet/GaugeServlet/*</url-pattern>
    <url-pattern>/mapproxy/*</url-pattern>
    <url-pattern>/adflib/</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
    <web-resource-name>allPages</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
    <web-resource-name>adfAuthentication</web-resource-name>
    <url-pattern>/adfAuthentication</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>valid-users</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/faces/login.jsf</form-login-page>
    <form-error-page>/faces/login-error.jsf</form-error-page>
    </form-login-config>
    </login-config>
    <security-role>
    <role-name>valid-users</role-name>
    </security-role>
    weblogic.xml
    <security-role-assignment>
    <role-name>valid-users</role-name>
    <principal-name>users</principal-name>
    </security-role-assignment>
    I know other users have experienced similar issues - but I am having trouble debugging or troubleshooting why this is happening.
    Any suggestions on how to further troubleshoot or resolve this issue would be appreciated!
    Dan

    I was able to resolve the login page looping issue.
    The issue is related to the login page being a JSF page based on a page template.
    When I created the JSF login page as a page template - the template contains a binding:
    <af:pageTemplate viewId="/test-template.jsf" value="#{bindings.ptb1}" id="pt1">
    When I deploy my application to the test weblogic server, the anonymous-role grants are not being respected. So even though I grant view access to the login JSF page to anonymous-role -- it appears that weblogic is trying to request a login for any page with a pageDef (including the login page). By re-creating the login page with no pageDef (a JSF page that does not use a page template) -- the login page is displayed (rather than entering into a loop).
    There is still a seperate issue with the anonymous-role grant not working as I would expect it to work that I will need to troubleshoot further.

  • Satellite A100-998: Blue Screen error - nv4_disp.dll infinite loop

    I bought this laptop a month ago and I have a serious problem with 3d applications, 3ds max and video games. I receive a blue screen saying
    Error message: STOP 0x000000EA THREAD_STUCK_IN_DEVICE_DRIVER
    nv4_disp.dll
    STOP: 0x000000EA (0x8408E6B8, 0x88D33F60, 0xBAF7BCBC, 0x00000001)
    (hope i noted down correctly) and it says something about "that this device caught in an infinite loop)
    I downloaded the latest drivers for my nvidia display Forceware 84.68 (GeForce Go 7300, 512ram)from Toshiba but nothing changed. Any suggestions ? What is the problem? the performance is really good until the blue screen appears, so i don't see why this happens...
    The laptop came with windows xp media center edition.
    Thanks in advance.

    > Yes, i think so, the problem is that it is not easy
    > to be separated with my laptop ... especially when
    > you have deadlines! I will call them tomorrow maybe
    > there is a hardware problem. It happens in all 3d
    > applications, and i have the most recent drivers.
    Did you ever get an answer? When i took my laptop home, the first thing i did once it was setup was test various 3d programs, because i bought it to do my 3d work on as well as having something mobile for work. I got that stop error, called toshiba and was told to uninstall and reinstall the graphics driver. Sounded like a fob but i did it anyway, and it had no effect. It seems like there's nothing i can do as Nvidia says they don't support it, it's a toshiba problem, and toshiba swears it can't be their fault.
    I used to see it on my desktop (before it went to computer heaven) until i updated the driver (a new one came out), and then i never got it again. From what toshiba tech support told me, it sounds like they won't be updating the driver for the go 7300 as it's regarded as too old? I'm pretty disappointed as my search of reviews of the product never revealed this flaw.
    One person who i talked to advised me to disable Hardware Acceleration, but wihout that i might as well saved money and gotten a cheapy graphics card. The price difference between a notebook with this card and one with the onboard intel type was huge.
    The first notebook i bought had a faulty dvd drive and i returned it for this one. I cringe at the thought of calling toshiba again and having them tell me to return it to them as if it was a hardware failure, when it sounds like a poorly written driver is causing the STOP.

Maybe you are looking for