You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Ralph Johnson <jo...@cs.uiuc.edu> on 2015/11/06 11:28:52 UTC

wrong error message?

I'm calling a Java library (Poi) from Groovy.  I get a "no such method"
error that says to me that I am passing two arguments, but I am really
passing three.   My code is

int i -> sheet.copyRows([sourceRow], i, new CellCopyPolicy())
and the error message is

java.lang.NoSuchMethodError:
org.apache.poi.xssf.usermodel.XSSFSheet.copyRows(Ljava/util/List;ILorg/apache/poi/ss/usermodel/CellCopyPolicy;)V

The way I read it, I am giving copyRows two arguments, a List and a
CellCopyPolicy.   It didn't seem to see the integer that was the second
argument.

Can anyone see what I am doing wrong?   I can give more context, but it is
just as likely to confuse as to illuminate.

-Ralph Johnson

Re: wrong error message?

Posted by Jochen Theodorou <bl...@gmx.org>.
Hi,

java.lang.NoSuchMethodError is an error from the JVM. In Java it is 
thrown if the class you compiled against has changed and the old target 
of the method call no longer exists.

Groovy does not know about any @Beta annotation by default. Did the 
error happen with static compilation? Because with dynamic Groovy it is 
almost impossible to have this error... unless of course, the error is a 
faulty internal non-dynamic code.

A trace to see what code actually made the method call should shed light 
on the issue. I still thin the classpath was the problem. You changing 
the source surely made you do a classpath change as well. It is very 
possible, that you "shadowed" the offending poi jar with that.

bye blackdrag


On 06.11.2015 15:31, Ralph Johnson wrote:
> Thanks for the advice on reading error messages.
>
> I am using the trunk of Poi, so it is the latest.   I rechecked the
> classpath and that wasn't the problem.   The problem turned out to be
> that the methods were annotated with @Beta, and that must have confused
> Groovy in some way.  Perhaps the annotation changes the method name so
> that Groovy's method lookup can't find it.   In any case, since I had
> source, I got rid of the annotation and then my program could find the
> method.
>
> The Beta annotation was developed by Google, but it appears that other
> projects are using it, so it would be unfortunate if Groovy had trouble
> with Java code that used the Beta annotation.
>
> -Ralph Johnson
>
> On Fri, Nov 6, 2015 at 7:01 AM, Winnebeck, Jason
> <Jason.Winnebeck@windstream.com <ma...@windstream.com>>
> wrote:
>
>     It’s in there. For the primitive types, there’s no semi-colon at the
>     end. For example void f(int, int, int) has signature f(III)V. With
>     the L (object) type, it’s L<class>; with semi-colon at end. You can
>     see L*;IL*; in there. That I before the second L is the int argument
>     you are looking for.____
>
>     __ __
>
>     As for why you get no such method error, I don’t know. I use POI in
>     my project and the version of POI that I have does not have this
>     method at all. On the website
>     https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFSheet.html#copyRows%28java.util.List,%20int,%20org.apache.poi.ss.usermodel.CellCopyPolicy%29,
>     it does has a signature you are trying to call.____
>
>     __ __
>
>     If you think your POI is new enough to have that method, a common
>     issue I’ve seen in cases like this is that accidentially multiple
>     versions of a library (POI in this case) are on the classpath at the
>     same time and you’re really loading an older version than you think.____
>
>     __ __
>
>     Jason____
>
>     __ __
>
>     *From:*rjohnson.uiuc@gmail.com <ma...@gmail.com>
>     [mailto:rjohnson.uiuc@gmail.com <ma...@gmail.com>]
>     *On Behalf Of *Ralph Johnson
>     *Sent:* Friday, November 06, 2015 5:29 AM
>     *To:* users@groovy.incubator.apache.org
>     <ma...@groovy.incubator.apache.org>
>     *Subject:* wrong error message?____
>
>     __ __
>
>     I'm calling a Java library (Poi) from Groovy.  I get a "no such
>     method" error that says to me that I am passing two arguments, but I
>     am really passing three.   My code is____
>
>     __ __
>
>     int i -> sheet.copyRows([sourceRow], i, new CellCopyPolicy())____
>
>     and the error message is____
>
>     __ __
>
>     java.lang.NoSuchMethodError:
>     org.apache.poi.xssf.usermodel.XSSFSheet.copyRows(Ljava/util/List;ILorg/apache/poi/ss/usermodel/CellCopyPolicy;)V____
>
>     __ __
>
>     The way I read it, I am giving copyRows two arguments, a List and a
>     CellCopyPolicy.   It didn't seem to see the integer that was the
>     second argument.____
>
>     __ __
>
>     Can anyone see what I am doing wrong?   I can give more context, but
>     it is just as likely to confuse as to illuminate.____
>
>     __ __
>
>     -Ralph Johnson____
>
>     ------------------------------------------------------------------------
>     This email message and any attachments are for the sole use of the
>     intended recipient(s). Any unauthorized review, use, disclosure or
>     distribution is prohibited. If you are not the intended recipient,
>     please contact the sender by reply email and destroy all copies of
>     the original message and any attachments.
>
>


Re: wrong error message?

Posted by Ralph Johnson <jo...@cs.uiuc.edu>.
Thanks for the advice on reading error messages.

I am using the trunk of Poi, so it is the latest.   I rechecked the
classpath and that wasn't the problem.   The problem turned out to be that
the methods were annotated with @Beta, and that must have confused Groovy
in some way.  Perhaps the annotation changes the method name so that
Groovy's method lookup can't find it.   In any case, since I had source, I
got rid of the annotation and then my program could find the method.

The Beta annotation was developed by Google, but it appears that other
projects are using it, so it would be unfortunate if Groovy had trouble
with Java code that used the Beta annotation.

-Ralph Johnson

On Fri, Nov 6, 2015 at 7:01 AM, Winnebeck, Jason <
Jason.Winnebeck@windstream.com> wrote:

> It’s in there. For the primitive types, there’s no semi-colon at the end.
> For example void f(int, int, int) has signature f(III)V. With the L
> (object) type, it’s L<class>; with semi-colon at end. You can see L*;IL*;
> in there. That I before the second L is the int argument you are looking
> for.
>
>
>
> As for why you get no such method error, I don’t know. I use POI in my
> project and the version of POI that I have does not have this method at
> all. On the website
> https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFSheet.html#copyRows%28java.util.List,%20int,%20org.apache.poi.ss.usermodel.CellCopyPolicy%29,
> it does has a signature you are trying to call.
>
>
>
> If you think your POI is new enough to have that method, a common issue
> I’ve seen in cases like this is that accidentially multiple versions of a
> library (POI in this case) are on the classpath at the same time and you’re
> really loading an older version than you think.
>
>
>
> Jason
>
>
>
> *From:* rjohnson.uiuc@gmail.com [mailto:rjohnson.uiuc@gmail.com] *On
> Behalf Of *Ralph Johnson
> *Sent:* Friday, November 06, 2015 5:29 AM
> *To:* users@groovy.incubator.apache.org
> *Subject:* wrong error message?
>
>
>
> I'm calling a Java library (Poi) from Groovy.  I get a "no such method"
> error that says to me that I am passing two arguments, but I am really
> passing three.   My code is
>
>
>
> int i -> sheet.copyRows([sourceRow], i, new CellCopyPolicy())
>
> and the error message is
>
>
>
> java.lang.NoSuchMethodError:
> org.apache.poi.xssf.usermodel.XSSFSheet.copyRows(Ljava/util/List;ILorg/apache/poi/ss/usermodel/CellCopyPolicy;)V
>
>
>
> The way I read it, I am giving copyRows two arguments, a List and a
> CellCopyPolicy.   It didn't seem to see the integer that was the second
> argument.
>
>
>
> Can anyone see what I am doing wrong?   I can give more context, but it is
> just as likely to confuse as to illuminate.
>
>
>
> -Ralph Johnson
> ------------------------------
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>

RE: wrong error message?

Posted by "Winnebeck, Jason" <Ja...@windstream.com>.
It’s in there. For the primitive types, there’s no semi-colon at the end. For example void f(int, int, int) has signature f(III)V. With the L (object) type, it’s L<class>; with semi-colon at end. You can see L*;IL*; in there. That I before the second L is the int argument you are looking for.

As for why you get no such method error, I don’t know. I use POI in my project and the version of POI that I have does not have this method at all. On the website https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFSheet.html#copyRows%28java.util.List,%20int,%20org.apache.poi.ss.usermodel.CellCopyPolicy%29, it does has a signature you are trying to call.

If you think your POI is new enough to have that method, a common issue I’ve seen in cases like this is that accidentially multiple versions of a library (POI in this case) are on the classpath at the same time and you’re really loading an older version than you think.

Jason

From: rjohnson.uiuc@gmail.com [mailto:rjohnson.uiuc@gmail.com] On Behalf Of Ralph Johnson
Sent: Friday, November 06, 2015 5:29 AM
To: users@groovy.incubator.apache.org
Subject: wrong error message?

I'm calling a Java library (Poi) from Groovy.  I get a "no such method" error that says to me that I am passing two arguments, but I am really passing three.   My code is

int i -> sheet.copyRows([sourceRow], i, new CellCopyPolicy())
and the error message is

java.lang.NoSuchMethodError: org.apache.poi.xssf.usermodel.XSSFSheet.copyRows(Ljava/util/List;ILorg/apache/poi/ss/usermodel/CellCopyPolicy;)V

The way I read it, I am giving copyRows two arguments, a List and a CellCopyPolicy.   It didn't seem to see the integer that was the second argument.

Can anyone see what I am doing wrong?   I can give more context, but it is just as likely to confuse as to illuminate.

-Ralph Johnson

----------------------------------------------------------------------
This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.