Results 1 to 7 of 7
  1. #1
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default java.lang.NoSuchMethodError

    I am getting the error, java.lang.NoSuchMethodError, during program execution. My project compiles okay. I have

    In the class, CensusCommon, I have:

    public static final String user = "censusrecords";
    public static final String databaseURL = "jdbc:mysql://localhost/censusrecords";

    In my main routine, I have:

    DBManage dbManage = new DBManage();

    dbManage.setUser(CensusCommon.user);
    dbManage.setURL(CensusCommon.databaseURL);

    And in my DBManage class, I have:

    private String databaseURL; // database URL

    public void setDatabaseURL(String d){
    databaseURL = d;
    }

    The first statement, setUser, works fine. the second one is the giving me problems. I re-booted, thinking I had some contamination. No Joy. I changed the name of the method. Again No Joy. CensusCommon.user and CensusCommon.databaseURL are both static final variables. I changed the argument, CensusCommon.databaseURL, to a pure string, "C". Again no joy.

    I am using NetBeans on an MS Vista system.

    Appreciate some help!

    Thanks.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: java.lang.NoSuchMethodError

    The DBManage class used in execution is not the one used in compilation.
    That's my bet.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: java.lang.NoSuchMethodError

    Quote Originally Posted by Tolls View Post
    The DBManage class used in execution is not the one used in compilation.
    That's my bet.

    That the assumption I've been working on the last couple of hours. I added a another method to the DBManage class and it gave me the same error which implies what you are suggesting is correct.

    So I deleted the Library link and re-linked it. That didn't work.

    Right now, I'm at a loss where else to look. Appreciate any suggestions you might have for to help me with this problem.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: java.lang.NoSuchMethodError

    Um, I just noticed, according to your first post the method is called:
    setDatabaseURL
    and yet you are calling:
    setURL
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: java.lang.NoSuchMethodError

    Misleading. I changed the name to see if the error followed. It did. The correct name is SetDatabaseURL and I have restored that name to my class.

    I think your suggestion that I'm picking up different libraries at compile and execution might be correct. I am using NetBears. I re-linked the library that contains DBManage and that didn't work.

    I'm not sure what else to look for. Right now I'm "stopped" at trying to solve this problem. Appreciate your suggestions.

    Thanks.

  6. #6
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: java.lang.NoSuchMethodError

    Quote Originally Posted by Tolls View Post
    The DBManage class used in execution is not the one used in compilation.
    That's my bet.
    Okay. I not longer think a different class is being used in execution then used in compilation. Please review my logic in reaching this decision. Thanks.

    DBManage is defined in a package of common routines. I added a new class, DBControl, to this class of common classes. I was able to instantiate this new class and invoke a method defined in this new class and it worked. Since it is packaged in the same jar as DBManage, I have to assume compile and execution are picking up the same jar.

    Does my conclusion make sense? If so, what can you recommend I try?

    Thanks for your help..

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: java.lang.NoSuchMethodError

    Do you have more than one jar file?
    Because the JVM will pick up the first DBManage it encounters.

    Alter DBManage so that the setUser call outputs something to the console or logs.
    Rebuild and run.
    If nothing is output then you know that that is not the code being executed.

    How are you running this?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 5
    Last Post: 03-17-2011, 02:26 PM
  2. Error Exeption: java.lang.NoSuchMethodError: main
    By Javanoobs in forum New To Java
    Replies: 4
    Last Post: 02-08-2011, 03:35 PM
  3. error java.lang.NoSuchMethodError: main
    By Mars in forum New To Java
    Replies: 8
    Last Post: 10-05-2010, 05:37 PM
  4. Replies: 6
    Last Post: 09-08-2009, 02:05 PM
  5. [error] java.lang.NoSuchMethodError: main
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 04-29-2009, 11:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •