1 2 Previous Next 16 Replies Latest reply: Dec 29, 2009 4:26 PM by 791266 RSS

    Exception in thread "main" java.lang.StackOverflowError

    843810
      While running simple Java API's as for that encryption on Linux machine using java1.3 i am getting the following errors:

      Exception in thread "main" java.lang.StackOverflowError
      at sun.io.CharToByteConverter.getDefault(CharToByteConverter.java:50)
      at java.lang.String.getBytes(String.java:751)
      at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
      at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:114)
      at java.io.File.exists(File.java:543)
      .........so on

      i have checked there is 2.2GB space in my system.
      kindly suggest this problem is related to which part .i think its not with the API's as they are running fine on windows system.
      thanks
      vigya
        • 1. Re: Exception in thread "main" java.lang.StackOverflowError
          843810
          Stack overflow means that you have an infinite recursion happening somewhere in your code. Something like this:

          public void myMethod(int value)
          {

          myMethod(++value);

          }

          If you call this method, you will get a stack overflow. When a method is called, a stack is alocated that contains method parameter values and space for a return value. In JVM, stack space is finite. If you allocate to many things, you will run out of space to store parameters for the next method call.
          • 2. Re: Exception in thread "main" java.lang.StackOverflowError
            843810
            There is a bug in the CharToByteConverter code which causes a StackOverflowError. Do a search on google to find the solution.
            • 3. Re: Exception in thread "main" java.lang.StackOverflowError
              843810
              Exception in thread "main" java.lang.StackOverflowError
                   at sun.nio.cs.SingleByteDecoder.decodeArrayLoop(Unknown Source)
                   at sun.nio.cs.SingleByteDecoder.decodeLoop(Unknown Source)
                   at java.nio.charset.CharsetDecoder.decode(Unknown Source)
                   at java.nio.charset.CharsetEncoder.isLegalReplacement(Unknown Source)
                   at java.nio.charset.CharsetEncoder.replaceWith(Unknown Source)
                   at java.nio.charset.CharsetEncoder.<init>(Unknown Source)
                   at java.nio.charset.CharsetEncoder.<init>(Unknown Source)
                   at sun.nio.cs.SingleByteEncoder.<init>(Unknown Source)
                   at sun.nio.cs.MS1252$Encoder.<init>(Unknown Source)
                   at sun.nio.cs.MS1252.newEncoder(Unknown Source)
                   at sun.jdbc.odbc.JdbcOdbcObject.CharsToBytes(Unknown Source)
                   at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
                   at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
                   at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
                   at java.sql.DriverManager.getConnection(Unknown Source)
                   at java.sql.DriverManager.getConnection(Unknown Source)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:53)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)
                   at connectdb.ConectdatabaseLab.getConnection(ConectdatabaseLab.java:56)

              Me too! I don't know what erro
              Help me!
              • 4. Re: Exception in thread "main" java.lang.StackOverflowError
                843810
                It looks like connectdb.ConectdatabaseLab.getConnection() method is your problem... See if this method has a reachable base case. I am assuming this method is recursive (it calls itself), which is usually how StackOverflowError's occur.
                • 5. Re: Exception in thread "main" java.lang.StackOverflowError
                  843810
                  I'm am a student from Macedonia, and I have a problem with "(Exception in thread "main" java.lang.StackOverflowError)" and I couldn't find where is it in my code. If you could help me, I would be very grateful.
                  • 6. Re: Exception in thread "main" java.lang.StackOverflowError
                    843810
                    Hi,
                    i am also facing the same problem.
                    sending my code
                    ---------------------------------------------------------------------------
                    public class Category {

                    Category catObj= new Category();
                    private int catId = 0;

                    public int getCatId() {

                    return catId;

                    }
                    public void setCatId(int catId) {
                    this.catId = catId;
                    }
                    private String catName = null;
                    public String getCatName() {

                    return catName;

                    }
                    public void setCatName(String catName) {
                    this.catName = catName;
                    }
                    private String catDesc = null;
                    public String getCatDesc() {
                    return catDesc;
                    }
                    public void setCatDesc(String value) {
                    catDesc = value;
                    }
                    private String catIconUri= null;
                    public String getCatIconUri() {
                    return catIconUri;

                    }
                    public void setCatIconUri(String value) {
                    catIconUri = value;
                    }
                    public Category getObj() {
                    return catObj;
                    }
                    public void setObj(Category value) {
                    catObj = value;
                    }
                    private List catIdList=null;

                    private List catNameList=null;
                    private List catDescList=null;
                    private List catIconUriList=null;
                    private List categoryList=null;
                    private List catobjtlist=null;
                    public List getCatDescList() {
                    return catDescList;
                    }
                    public void setCatDescList(List catDescList) {
                    this.catDescList = catDescList;
                    }
                    public List getCatIconUriList() {
                    return catIconUriList;
                    }
                    public void setCatIconUriList(List catIconUriList) {
                    this.catIconUriList = catIconUriList;
                    }

                    public List getCatIdList() {
                    return catIdList;
                    }
                    public void setCatIdList(List catIdList) {
                    this.catIdList = catIdList;
                    }

                    public List getCatNameList() {
                    return catNameList;
                    }
                    public void setCatNameList(List catNameList) {
                    this.catNameList = catNameList;
                    }
                    public List getObjList() {
                    return categoryList;
                    }
                    public void setObjList(List catobjtlist) {

                    this.catobjtlist = catobjtlist;

                    }
                    }

                    ------------------------------------------------------
                    public class CategoryNew {

                    public static void main(String[] args) {
                    System.out.println("hello");

                    CategoryNew n1 = new CategoryNew();
                    n1.selectAllCategory();

                    }

                    public List selectAllCategory()
                    {
                    Connection con = null;
                    Category category =null ;

                    List cat1;

                    cat1= new ArrayList();

                    PreparedStatement ptmt = null;
                    ResultSet rs = null;
                    System.out.println("iam here 1 sql");
                    try{ 
                    con = retconn();
                    System.out.println("iam here 2 sql");
                    ptmt = con.prepareStatement("select * from category");
                    System.out.println("connection created");
                    rs = ptmt.executeQuery();
                    System.out.println("pstmt called");
                    category = new Category();

                    System.out.println("B4 rs");

                    while (rs.next()) {    

                    System.out.println("inside rs");
                    category.setCatId(rs.getInt(1));
                    category.setCatName(rs.getString(2));
                    category.setCatDesc(rs.getString(3));
                    category.setCatIconUri(rs.getString(4));

                    cat1.add(category);
                    }
                    category.setObjList(cat1);


                    }catch(SQLException e)
                    {System.out.println("iam here 4 sql");
                            System.err.println(e);
                         }

                    return cat1;
                    }

                    public Connection retconn() {

                    Connection conn1 = null;
                    try {
                    String username = "scott";
                    String password = "tiger";
                    String url = "jdbc:oracle:thin:@localhost:1521:oracle"; //PLSExtProc";
                    Class.forName("oracle.jdbc.driver.OracleDriver");
                    //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    conn1 = DriverManager.getConnection(url, username, password);
                    System.out.println("Database connection establish");
                    // return conn1;
                    }
                    catch (Exception e) {
                    System.err.println(e);

                    }

                    return conn1;
                    }


                    }

                    exception
                    ------------------------------
                    iam here 2 sql
                    connection created
                    pstmt called
                    Exception in thread "main" java.lang.StackOverflowError
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category.<init>(Category.java:14)
                         at net.pga.Category
                    • 7. Re: Exception in thread "main" java.lang.StackOverflowError
                      843810
                      Hi Rachis,

                      hope you already found a solution :-)
                      In your case the StackOverflow comes from the fact that you're initializing an object inside itself :
                      public class Category {
                      
                      Category catObj= new Category();
                      Each time you create a Category object it tries to create another object Category (catObj) (which in turns creates another object Category and so on).
                      This is were your StackOverflowError comes from.
                      • 8. Re: Exception in thread "main" java.lang.StackOverflowError
                        843810
                        what is the cause of this error?
                        • 9. Re: Exception in thread "main" java.lang.StackOverflowError
                          jschellSomeoneStoleMyAlias
                          dhanyanr wrote:
                          what is the cause of this error?
                          The cause is that people don't read. For example you didn't read the other responses in this thread that specifically stated what caused it.

                          And don't resurrect old threads.
                          • 10. Re: Exception in thread "main" java.lang.StackOverflowError
                            843810
                            Hi,

                            I have the same error that is Exception in thread "main" java.lang.StackOverflowError but i know why it occurs.
                            It is because of infinite recursion theoretically. Recursion in my code block is related to "if-condition". If "if-statement" is true, recursion is called.
                            I could call the recursion 512 times. More than 512 calls the excepsion is thrown. I think i need about 1000 recursion calls practically. Unfortunately, i cound't that.
                            Can anyone help me for making additional memory space , increasing the limit of stack or clear the stack. Is there any way to do one of these.
                            Or how can i catch and handle this exception when it is thrown? The "Try - Catch Statement" can be used?

                            Thank you in advance.
                            • 11. Re: Exception in thread "main" java.lang.StackOverflowError
                              jschellSomeoneStoleMyAlias
                              fishon wrote:
                              Hi,

                              I have the same error that is Exception in thread "main" java.lang.StackOverflowError but i know why it occurs.
                              As I said in reply #9, the cause is that people do not read.
                              • 12. Re: Exception in thread "main" java.lang.StackOverflowError
                                843810
                                jschell wrote:
                                fishon wrote:
                                Hi,

                                I have the same error that is Exception in thread "main" java.lang.StackOverflowError but i know why it occurs.As I said in reply #9, the cause is that people do not read.
                                Jschell i read all replies of this thread even yours but i couldnt find a solution i need.
                                Did you read my reply #10 completely and carefully?
                                I didnt ask why this error occurs. My question is that how it can be fixed.
                                Must i discard code causes recursion? You adviced that read read read... please give a link, document or anything to me to read.

                                Edited by: fishon on Sep 21, 2009 5:23 PM
                                • 13. Re: Exception in thread "main" java.lang.StackOverflowError
                                  jschellSomeoneStoleMyAlias
                                  fishon wrote:
                                  jschell wrote:
                                  fishon wrote:
                                  Hi,

                                  I have the same error that is Exception in thread "main" java.lang.StackOverflowError but i know why it occurs.As I said in reply #9, the cause is that people do not read.
                                  Jschell i read all replies of this thread even yours but i couldnt find a solution i need.
                                  Did you read my reply #10 completely and carefully?
                                  Did you read the part of my response that said don't resurrect old threads? If so then why did you resurrect this one?
                                  I didnt ask why this error occurs. My question is that how it can be fixed.
                                  Obvious one is don't recurse. You can unroll the recursion.
                                  Reduce information on the stack. Increase the stack limit.
                                  Must i discard code causes recursion?
                                  Depends on what you did and what you need to do.
                                  • 14. Re: Exception in thread "main" java.lang.StackOverflowError
                                    843810
                                    jschell, relax man ;-)

                                    fishon, there's a switch to the jvm to increase the stack size, check
                                    this for example (though it didn't work for me, probably because I actually get the exception in Scala).
                                    1 2 Previous Next