NoSuchMethodError because wrong class is found

java nosuchmethoderror but method exists
java.lang.nosuchmethoderror at runtime
error java.lang.nosuchmethoderror minecraft
java lang nosuchmethoderror ljava/lang/string
java lang nosuchmethoderror init
no such method error in junit
nosuchmethoderror android
no such method error in selenium

I have a Sprint Boot application and at deployment time I'm getting a NoSuchMethodError. I'm deploying to WebSphere I'm pretty sure it's because the wrong class or version of the class is being found. It seems like the Spring code is looking for it's own class but is finding a class from the IBM jar file and the class it loads doesn't have an 'init()' method on it.

Please let me know if any further information will help determine a fix.

Here's my pom.xml file:

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">


        <relativePath/> <!-- lookup parent from repository -->






Here's the error message:

> Failed to
> load webapp: Failed to load webapp: Error creating bean with name
> &amp;#39&#59;defaultValidator&amp;#39&#59; defined in class path
> resource
> [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]:
> Invocation of init method failed&amp;#59&#59; nested exception is
> java.lang.NoSuchMethodError:
> javax/validation/Configuration.getDefaultParameterNameProvider&amp;#40&#59;&amp;#41&#59;Ljavax/validation/ParameterNameProvider&amp;#59&#59;
> &amp;#40&#59;loaded from file:/C:/Program Files
> &amp;#40&#59;x86&amp;#41&#59;**/IBM/WebSphere/AppServer/plugins/javax.j2ee.validation.jar** by
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@3fb9923&amp;#41&#59;
> called from class
> org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
> &amp;#40&#59;loaded from
> file:/C:/Program&amp;#37&#59;20Files&amp;#37&#59;20&amp;#40&#59;x86&amp;#41&#59;/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/TheGarbers3Node01Cell/eacmanagerEAR.ear/eacmanager.war/WEB-INF/lib/spring-context-5.0.7.RELEASE.jar
> by 

To do this, you need to change the classloader of your application so the correct dependency is pulled in.

To do that via the UI, go to Applications -> WebSphere enterprise applications -> Your Application -> Class loading and update detection and change the Class loader order to be Classes loaded with local class loader first (parent last). This "causes the class loader to attempt to load classes from its local class path before delegating the class loading to its parent.".

If you are deploying an EAR and want this change to propagate to inner applications, you can either change WAR class loader policy to Single class loader for application or change the class loader of the individual war (in the EAR click Manage Modules -> Your Module then change Class loader order).

As long as you provide a version of dependency in question, you should get passed the above issue.

The following script will apply the above settings (replace app_name with the name of your application): (credit)

dep = AdminConfig.getid('/Deployment:app_name/');
depObject = AdminConfig.showAttribute(dep, 'deployedObject');
AdminConfig.modify(depObject, [['warClassLoaderPolicy', 'SINGLE']]);
classldr = AdminConfig.showAttribute(depObject, 'classloader');
AdminConfig.modify(classldr, [['mode', 'PARENT_LAST']]);

3 Steps to Fix NoSuchMethodErrors and NoSuchMethodExceptions, First, we need to find out where the class We find this information in the error message of the NoSuchMethodError : This will cause Java to print out all classes and the  No - as the exceptions have been telling you it is EXACTLY the opposite. Your code is not referencing a class/interface correctly and likely because the jar/class was never resolved. I know it’s not a code or jar file related issue because it all works perfectly on a private enviroment not running from a DB therefore I feel think its DB related.

Try changing the version of springboot in your pom.xml. It may work by referring different version of lib files

2.0.3.RELEASE --> 1.5-.59 etc

java.lang.NoSuchMethodError Example, NoSuchMethodError because the Data class became incompatible with Temp pankaj:Downloads pankaj$ javac error: cannot find  You get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run. Also, you'll want to read the following: Setting the class path (Windows) How Classes

Smells like a you have multiple versions of the same dependency on your classpath. You compile with one but you are running the other.

Run mvn dependency:tree and you can see everything you're bringing in. Often times transitive dependencies can cause the problems you're experiencing-- i.e, your webapp depends on both library Foo-v1 and Bar-v1. However, Foo-v1 itself depends on Bar-v2.

Once you find the duplicate library, try bumping each to be the same or latest version. Another approach is to try using maven's <exclusion></exclusion> so you only have one version of that library in your jar.

See this:

NoSuchMethodError (Java Platform SE 7 ), Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. Since: JDK1.0; See Also:  Since tomcat lib folder jars are looked first by Java Classloader, there is a chance of java.lang.NoSuchMethodError if any method is not found in the class loaded. Conflict because of same class name. For example, your application is using some third party jar which has same fully qualified class name as yours.

java.lang.NoSuchMethodError java code examples, catch (NoSuchMethodException e) { throw new NoSuchMethodError(e. private String extractClassName(NoSuchMethodError cause) { int descriptorIndex = cause. private static Method init() { try { Method m = ClassLoader.class. INFO,​"No default constructor found on "+clazz,e); NoSuchMethodError exp; if(clazz. dynamitechetan changed the title Flutter App Not Building NoSuchMethodError: Class '_CompileTimeError' has no instance getter 'message'. Sep 3, 2018 zoechi added dependency: dart severe: crash labels Sep 3, 2018

NoSuchMethodError Class (Java.Lang), Thrown when the VM notices that a program tries to reference, on a class or object, a method Returns the cause of this Throwable , or null if there is no cause. Film Theory: Avatar and the Science of Waterbending (Avatar the Last Airbender) - Duration: 17:35. The Film Theorists Recommended for you

java.lang.nosuchmethoderror, The NoSuchMethodError is a sub-class of the LinkageError class. Error: Main method not found in class Example, please define the main  public class NoSuchMethodError extends IncompatibleClassChangeError Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.

  • Possible duplicate of Websphere 8.5 with Spring-5
  • I assumed when I started this project that I'd want the latest the Spring has to offer. Are there advantages to using Spring 1.5.x over 2.0.3?
  • @user2608333 just to trial atleast workspace get the latest reference...! If it works fine try creating a new workspace and copy your project...! Hope it works
  • I ran the mvn command to get the tree. I then removed all the prefix data on each line leaving me with the package name and jar name on each line. I sorted them and I don't see any duplicates.
  • @6534686 - I think my problem is that at startup there's a conflicting WebSphere jar file. The stacktrace above shows which jar is being picked up. I guess I could try excluding the jar that maven is including that has the same package/class in it...