NoSuchMethodError , though the method is present!

R

Raga

Hi,
Am getting "java.lang.NoSuchMethodError" though the method is actually
there in the class. Can you please throw some light on this?

Thanks.
 
R

Raga

Hi ,
Here's the method from which the exception's thrown:

public String getQuery() {
if (this.query == null) {

if (this.propertyStore != null) {
if(this.propertyStore.containsKey(Constants.SQL)) {
query = (String) propertyStore.get(Constants.SQL);
}
else if(this.propertyStore.containsKey(Constants.DATA_QUERY)) {
query = (String) propertyStore.get(Constants.DATA_QUERY);
}
}

if (query == null) {
return "";
}

query = query.trim().replaceAll("\r\n|\r|\n", " ");
}

if(logger.isEnabledFor(Level.INFO))
logger.info("Query is " + query);

return query;
}




& this' the exact exception thrown:

java.lang.NoSuchMethodError
at devapi.GenericDataHandler.getQuery(Unknown Source)
at core.DataManager.getQueryCollection(Unknown Source)
at core.WebEngine.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)




Thanks .
 
A

Andrew Thompson

Raga wrote:
....
Am getting "java.lang.NoSuchMethodError" though the method is actually
there in the class. Can you please throw some light on this?

You are getting a java.lang.NoSuchMethodError because
actually no it isn't. Further details might require some
further details from you, like a stacktrace (for starters).

Andrew T.
 
R

Raga

Hi, This' where the getQuery() method's called:

public IQueryCollection getQueryCollection()
{
IQueryCollection retCollection = UtilFactory.getQueryCollection();
HandlerNode visitorNode = firstHandler;
do
{
logger.info("Adding " +
visitorNode.getDataHandler().getQuery() + " to query collecton");
retCollection.addQuery(visitorNode.getDataHandler().getRSQID(), visitorNode.getDataHandler().getQuery());
visitorNode = visitorNode.next;
} while (visitorNode != firstHandler);
return retCollection;
}



how do I remove this class' version incompatibility problem? Please
suggest.

Thanks.
 
T

Tor Iver Wilhelmsen

Raga said:
Hi, What further details are reqd? I've already put the stack trace.

NoSuchMetohdError usually is caused by using different versions of a
class at compile-time than run-time. Try checking your classpaths.
 
T

Thomas Kellerer

Raga wrote on 13.10.2006 16:34:
Hi, This' where the getQuery() method's called:

visitorNode.getDataHandler().getQuery()

how do I remove this class' version incompatibility problem? Please
suggest.

Thanks.

Are you sure that visitorNode.getDataHandler() really returns an instance that
supports the getQuery() method?
 
O

Oliver Wong

Thomas Kellerer said:
Raga wrote on 13.10.2006 16:34:

Are you sure that visitorNode.getDataHandler() really returns an instance
that supports the getQuery() method?

If it didn't, (s)he'd get a compile time error. Since there's no
reflection or casting going on here, I suspect the source code and the
..class files are not in sync, as Tor suggested.

- Oliver
 
T

Thomas Kellerer

Oliver Wong wrote on 13.10.2006 18:01:
If it didn't, (s)he'd get a compile time error. Since there's no
reflection or casting going on here, I suspect the source code and the
.class files are not in sync, as Tor suggested.

Depends on the definition of getDataHandler() (which I haven't seen yet) which
might return an abstract class (and the class GenericDataHandler seems to point
into the direction - due to the "Generic".
In that case I do think a NoSuchMethodError could be thrown (but it might be a
different Exception I'm not 100% sure)
 
O

Oliver Wong

Thomas Kellerer said:
Oliver Wong wrote on 13.10.2006 18:01:

Depends on the definition of getDataHandler() (which I haven't seen yet)
which might return an abstract class (and the class GenericDataHandler
seems to point into the direction - due to the "Generic".
In that case I do think a NoSuchMethodError could be thrown (but it might
be a different Exception I'm not 100% sure)

The definition of getDataHandler would claim to return some type, let's
say Foo:

public Foo getDataHandler()

At compile time, the compiler would check that you are only calling methods
which exist in Foo (i.e. to call methods in subclasses of Foo, you'd have to
do a cast), and the code which actually creates the object to be returned
must create a concrete class, so all the methods would be implemented.

- Oliver
 
R

Raga

Hi,

Thanks for your replies. Just now I found out that JVM seems to be
taking some (I don't know from where!) location (or maybe its cache or
something similar). Am saying this because I replaced the jar with a
newly compiled one which has some system.out.println's. But am not
getting to see those newly included messages on the screen, though, if
I run the same on another machine, am able to see the newwly included
messages. Can you please tell me how to clear JVM's cache or why is it
referring to some unknown jar file? I searched the whole system...there
is no other copy of the jar file.


Thanks.
 
L

Lothar Kimmeringer

Raga said:
public String getQuery() {
if (this.query == null) {

if (this.propertyStore != null) {
if(this.propertyStore.containsKey(Constants.SQL)) {
query = (String) propertyStore.get(Constants.SQL);
}
else if(this.propertyStore.containsKey(Constants.DATA_QUERY)) {
query = (String) propertyStore.get(Constants.DATA_QUERY);
}
}

if (query == null) {
return "";
}

query = query.trim().replaceAll("\r\n|\r|\n", " ");
}

Assuming that propertyStore is a Map, there are only "standard-methods"
being called (containsKey, get, trim, replaceAll).

What version of Java is used for executing? replaceAll has been added
to Java in Version 1.4.
if(logger.isEnabledFor(Level.INFO))
logger.info("Query is " + query);

If you get the error with running with Java 1.4 or higher, the problem
must be here then. Check if the Class behind "logger" maybe is in another
Jar in the classpath that is of an older version, that doesn't contain
isEnabledFor.
java.lang.NoSuchMethodError
at devapi.GenericDataHandler.getQuery(Unknown Source)

You should compile your class without optimization to get the
exact line-number where the error occured. That allows to stop
guessing where the problem might be.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 
R

Raga

Hi, Thanks for your patient reply. First of all, it doesn't seem to
take into account the new jar file itself. It seems to take the
classes' bytecodes from its cache or something like that. How do I
clear the cache & make JVM take/use the new classes?

Thanks.
 
L

Lothar Kimmeringer

Raga said:
Hi, Thanks for your patient reply. First of all, it doesn't seem to
take into account the new jar file itself. It seems to take the
classes' bytecodes from its cache or something like that. How do I
clear the cache & make JVM take/use the new classes?

I'm not aware of any caches in action when working with applications.
Are you running an applet? If yes, what is the browser you use, is
there a Java-plugin installed or are you using the originally in-
stalled Virtual Machine? If you use Internet Explorer with no Plugin
where speaking of Java 1.1.4. There are even more methods not
existing with Maps (containsKey was named contains IIRC).


Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 
A

Andrew Thompson

Lothar said:
.....
I'm not aware of any caches in action when working with applications.

Only when running as a web start'ed application.

Note the OP made another post that suggests it is
'plain old java' launching the application, no sign of
any webstart, or ..
...an applet?

...or a servlet (servers can be irritatingly slow to refresh
at times).

Andrew T.
 
O

Oliver Wong

Raga said:
Hi,

Thanks for your replies. Just now I found out that JVM seems to be
taking some (I don't know from where!) location (or maybe its cache or
something similar). Am saying this because I replaced the jar with a
newly compiled one which has some system.out.println's. But am not
getting to see those newly included messages on the screen, though, if
I run the same on another machine, am able to see the newwly included
messages. Can you please tell me how to clear JVM's cache or why is it
referring to some unknown jar file? I searched the whole system...there
is no other copy of the jar file.

How are you running the program? E.g. if you're running it from the
command line, tell us what you typed to get it to run.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top