getDeclaredMethod leading to java.lang.NoSuchMethodException

Anita

In one of my classes i have put below lines of code to call the preOTPOperations of BLH class

Class<?> clazz = Class.forName("com.test.BLH");
Object obj = clazz.newInstance();
Class<?>[] paramTypes = new Class[4];
paramTypes[0]=String.class;
paramTypes[1]=String.class;
paramTypes[2]=Integer.class;
paramTypes[3]=COConfig.class;
Method m = clazz.getDeclaredMethod("preOTPOperations", paramTypes); 
String responseMessage = (String) m.invoke(obj, new Object[]{cardnumber, null, bankId, myConfig});

But, i get java.lang.NoSuchMethodException, when i try to invoke preOTPOperations method of BLH as above using invoke().

In BLH class i have preOTPOperations as below.

public String preOTPOperations(String cardnumber, String mobileNumber, int bankid, COConfig coConfig){

    //some code goes here

}

Not sure why i am getting NoSuchMethodException in spite of having preOTPOperations in BLH class with public access specifier. Someone kindly suggest the solution. Am i missing something? Thanks in advance!

yole

You need to change Integer.class to int.class. Integer and int are not the same types, and the method isn't found because you're specifying the wrong type.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Weird java.lang.InstantiationException and java.lang.NoSuchMethodException after upgrading from JDK8 to JDK11

From Java

java.lang.NoSuchMethodException for onCreate

From Dev

java.lang.NoSuchMethodException: Unknown property

From Dev

Java - java.lang.NoSuchMethodException

From Dev

Java reflection getDeclaredMethod class check

From Dev

java.lang.NoSuchMethodException: setHomeActionContentDescription [int]?

From Dev

ProGuard java.lang.NoSuchMethodException

From Dev

No default constructor found; nested exception is java.lang.NoSuchMethodException

From Dev

A java.lang.NoSuchMethodException error (layouts)

From Dev

java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

From Dev

Error: java.lang.NoSuchMethodException: java.lang.Long.<init>() in spring MVC

From Dev

Struts Hibernate Integration with Annotations (java.lang.NoSuchMethodException)

From Dev

Kafka throws java.lang.NoSuchMethodException

From Dev

android java.lang.AssertionError: java.lang.NoSuchMethodException - Proguard

From Dev

What causing this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]

From Dev

Why Scala needs duplicate constructor? (java.lang.NoSuchMethodException)

From Dev

Java reflection: constructor for primitive int causes: java.lang.NoSuchMethodException: int.<init>(int)

From Dev

java.lang.NoSuchMethodException for onCreate

From Dev

Weird java.lang.InstantiationException and java.lang.NoSuchMethodException after upgrading from JDK8 to JDK11

From Dev

Java reflection: constructor for primitive int causes: java.lang.NoSuchMethodException: int.<init>(int)

From Dev

java.lang.NoSuchMethodException: Bean has no property named

From Dev

java.lang.NoSuchMethodException: akka.cluster.ClusterActorRefProvider

From Dev

getDeclaredMethod in Java Fails

From Dev

A java.lang.NoSuchMethodException error (layouts)

From Dev

java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

From Dev

Why Scala needs duplicate constructor? (java.lang.NoSuchMethodException)

From Dev

java.lang.NoSuchMethodException struts servlet

From Dev

java.lang.NoSuchMethodException: AffirmativeBased.<init>()

From Dev

java.lang.NoSuchMethodException: <Class>.<init>(java.lang.String) when copying custom Transformer

Related Related

  1. 1

    Weird java.lang.InstantiationException and java.lang.NoSuchMethodException after upgrading from JDK8 to JDK11

  2. 2

    java.lang.NoSuchMethodException for onCreate

  3. 3

    java.lang.NoSuchMethodException: Unknown property

  4. 4

    Java - java.lang.NoSuchMethodException

  5. 5

    Java reflection getDeclaredMethod class check

  6. 6

    java.lang.NoSuchMethodException: setHomeActionContentDescription [int]?

  7. 7

    ProGuard java.lang.NoSuchMethodException

  8. 8

    No default constructor found; nested exception is java.lang.NoSuchMethodException

  9. 9

    A java.lang.NoSuchMethodException error (layouts)

  10. 10

    java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

  11. 11

    Error: java.lang.NoSuchMethodException: java.lang.Long.<init>() in spring MVC

  12. 12

    Struts Hibernate Integration with Annotations (java.lang.NoSuchMethodException)

  13. 13

    Kafka throws java.lang.NoSuchMethodException

  14. 14

    android java.lang.AssertionError: java.lang.NoSuchMethodException - Proguard

  15. 15

    What causing this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]

  16. 16

    Why Scala needs duplicate constructor? (java.lang.NoSuchMethodException)

  17. 17

    Java reflection: constructor for primitive int causes: java.lang.NoSuchMethodException: int.<init>(int)

  18. 18

    java.lang.NoSuchMethodException for onCreate

  19. 19

    Weird java.lang.InstantiationException and java.lang.NoSuchMethodException after upgrading from JDK8 to JDK11

  20. 20

    Java reflection: constructor for primitive int causes: java.lang.NoSuchMethodException: int.<init>(int)

  21. 21

    java.lang.NoSuchMethodException: Bean has no property named

  22. 22

    java.lang.NoSuchMethodException: akka.cluster.ClusterActorRefProvider

  23. 23

    getDeclaredMethod in Java Fails

  24. 24

    A java.lang.NoSuchMethodException error (layouts)

  25. 25

    java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

  26. 26

    Why Scala needs duplicate constructor? (java.lang.NoSuchMethodException)

  27. 27

    java.lang.NoSuchMethodException struts servlet

  28. 28

    java.lang.NoSuchMethodException: AffirmativeBased.<init>()

  29. 29

    java.lang.NoSuchMethodException: <Class>.<init>(java.lang.String) when copying custom Transformer

HotTag

Archive