Rectangle 27 3

This generally means that the version of the library or class you compiled against is not the same version that is being run now.

When you compiled, the method was there (otherwise there would have been a compile error), but now it is not (maybe because the jar file is too old).

Try a clean build and deploy of your whole project.

The other frequent case is reflection, when you have method names constructed at run time (for methods that just do not exist).

..i'am making jar on maven and i'am getting output and build success .But when i keep it in server it show the NoSuchMethodError ..

Java.lang.NoSuchMethodError: com.Person.setCompanyList(Ljava/util/Arra...

nosuchmethoderror
Rectangle 27 11

You are mixing Spring 3.1.1 with Spring 2.5.6. Add explicit dependencies or dependency management entries for those Spring dependencies that are still on 2.5.6 to upgrade them to 3.1.1 or downgrade your project.

Hi Rec Thanks for the response ,Which one are you refering to as 2.5.6 .Can you point out that .

Well, look at what you posted yourself: org.springframework:spring-context:jar:2.5.6, org.springframework:spring-beans:jar:2.5.6, etc. There is even a 3.1.0.RC2 in there. All Spring dependencies should have the same version. Just add explicit dependencies on the 3.1.1 version for all of these artifacts to your pom instead of relying on transitive inclusion.

Yes Rec i understand i am missing out something here , spring-context:jar:2.5.6 or spring-beans:jar:2.5.6 is in the dependency tree , but i did not add them explicitly,I am finding trouble in removing them as i need to use 3..1.1 .could you please suggest

Maven uses the principle of the "closest version". "Close" means, how many dependency steps away from your project. So if you do not explicitly include these dependencies in the correct version yet, then start doing it. Nothing is "closer" than the dependency defined in the pom itself. Excluding them can lead to problems as other dependency may need them. Otherwise, refer to this post for an example of how to exclude a dependency. I wouldn't recommend it in your situation though.

spring - java.lang.NoSuchMethodError: org.springframework.web.context....

java spring maven spring-batch
Rectangle 27 4

Caused by: java.lang.NoSuchMethodError: edu.stanford.nlp.util.Generics.newHashMap()Ljava/util/Map;
  at edu.stanford.nlp.pipeline.AnnotatorPool.(AnnotatorPool.java:27)
  at edu.stanford.nlp.pipeline.StanfordCoreNLP.getDefaultAnnotatorPool(StanfordCoreNLP.java:305)

then this isn't caused by the shiny new Stanford NLP tools that you've just downloaded. It is because you also have old versions of one or more Stanford NLP tools on your classpath.

The straightforward case is if you have an older version of a Stanford NLP tool. For example, you may still have a version of Stanford NER on your classpath that was released in 2009. In this case, you should upgrade, or at least use matching versions. For any releases from 2011 on, just use tools released at the same time -- such as the most recent version of everything :) -- and they will all be compatible and play nicely together.

The tricky case of this is when people distribute jar files that hide other people's classes inside them. People think this will make it easy for users, since they can distribute one jar that has everything you need, but, in practice, as soon as people are building applications using multiple components, this results in a particular bad form of jar hell. People just shouldn't do this. The only way to check that other jar files do not contain conflicting versions of Stanford tools is to look at what is inside them (for example, with the jar -tf command).

In practice, if you're having problems, the most common cause (in 2013-2014) is that you have ark-tweet-nlp on your classpath. The jar file in their github download hides old versions of many other people's jar files, including Apache commons-codec (v1.4), commons-lang, commons-math, commons-io, Lucene; Twitter commons; Google Guava (v10); Jackson; Berkeley NLP code; Percy Liang's fig; GNU trove; and an outdated version of the Stanford POS tagger (from 2011). You should complain to them for creating you and us grief. But you can then fix the problem by using their jar file from Maven Central. It doesn't have all those other libraries stuffed inside.

Thanks @Frdric Henri, the problem was an old version of stanford segmenter. After I deleted the library, now it works.

java.lang.NoSuchMethodError: edu.stanford.nlp.util.Generics.newHashMap...

java java-ee stanford-nlp nosuchmethoderror
Rectangle 27 8

javax.servlet.http.HttpServletRequest.getParts() is only available starting with Servlet API 3.0

  • Be sure you are running Jetty 9 (or newer)
WEB-INF/web.xml
  • Make sure your build tool is using the servlet-api 3.1 (or newer) jars.
  • (Optionally) Make sure you have the same servlet api 3.1 jar in your WEB-INF/lib directory.

Thanks for the quick response, I'll check it now.

I checked all the points you mentioned, but all of them are ok, servlet-api-3.0 as well as jetty v8 are included, but not working.

Double check your build and WEB-INF/lib, you likely have more than 1 servlet api jar in your WEB-INF/lib directory (or in your build path if eclipse, or dependency tree if maven), one of which is an older incompatible version.

Thanks a bunch for the help, I've solved the issue by taking a look carefully to the issues you mentioned.

jetty - Facing java.lang.NoSuchMethodError: HttpServletRequest.getPart...

java jetty nosuchmethoderror
Rectangle 27 4

This problem is caused by having an old, incompatible copy of the JPA API on the classpath.

Conflicts with the right version of the JPA 2.1 API:

Unfortunately Maven 3 is still unable to handle re-distributions of the same artifacts, which are sometimes necessary.

org.hibernate

sure, feel free to search for another one, but the API is the same for all distributions as it's defined by the JPA standard.

Hibernate 5.2.7 - java.lang.NoSuchMethodError: org.hibernate.engine.sp...

java hibernate nosuchmethoderror
Rectangle 27 2

Caused by: java.lang.NoSuchMethodError: org.springframework.web.portlet.context.ConfigurablePortletApplicationContext.setId(Ljava/lang/String;)V

It sounds like you are using a old version of spring-context.jar Spring Context API - Version 2.0.x.

Are you using profile local_test? Make sure you are using correct spring version in jboss server(jboss/lib), or simply remove <scope>provided</scope> from your project's pom.xml (under profile local_test).

I checked the contents of the portlet. There really are two versions of the spring-context - 3.firepic.org/3/images/2012-07/26/uqb65sn5veam.png I do not understand how he gets into the portlet. I removed <scope>provided</scope> from pom.xml under profile local_test but it has no effect.

spring - java.lang.NoSuchMethodError: org.springframework.web.portlet....

spring spring-mvc jboss nosuchmethoderror jboss-portal
Rectangle 27 1

Jodd modules are distributed in two flavors:

1 .as a single bundle jar, that contain all Jodd modules in one distribution archive.

So Jodd may be used on any platform where there is a suitable Java 7+ runtime environment.

Excellent answer! Just little add-on, up to v3.6.6, Jodd was working on any Java 5+ environment, starting from v3.7.0 it will work on Java 7+.

java.lang.NoSuchMethodError: jodd.Jodd.init(Ljava/lang/Class;)V - Stac...

java nosuchmethoderror jodd
Rectangle 27 2

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-multipart-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency>

2.2.0 seems to be very old

web services - Exception in thread "main" java.lang.NoSuchMethodError:...

java web-services rest jboss resteasy
Rectangle 27 1

As Frdric said, the best solution is to delete all dependencies causing this mismatching in runtime and compiling and add the library again and buil again, if you're using maven:

<dependency>
    <groupId>edu.stanford.nlp</groupId>
    <artifactId>stanford-corenlp</artifactId>
    <version>3.6.0</version>
</dependency>

java.lang.NoSuchMethodError: edu.stanford.nlp.util.Generics.newHashMap...

java java-ee stanford-nlp nosuchmethoderror
Rectangle 27 3

I found this to work as a solution. Add it in your weblogic.xml:

<wls:container-descriptor>
    <wls:prefer-application-packages>
        <!--  jersey-bundle-*.jar-->
        <wls:package-name>com.sun.jersey.*</wls:package-name>
        <wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
        <wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>

        <!-- Jackson-*.jar -->
        <wls:package-name>org.codehaus.jackson.*</wls:package-name>

        <!-- jettison-*.jar -->
        <wls:package-name>org.codehaus.jettison.*</wls:package-name>

        <!-- jsr311*.jar -->
        <wls:package-name>javax.ws.rs.*</wls:package-name>

        <!-- asm.jar -->
        <wls:package-name>org.objectweb.asm.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>
<!-- jsr311*.jar -->
<wls:package-name>javax.ws.rs.*</wls:package-name>

web services - java.lang.NoSuchMethodError: javax.ws.rs.core.Applicati...

java web-services jersey weblogic jax-rs
Rectangle 27 64

  • The servlet container does not support Servlet 2.5.
  • The web.xml is not declared conform Servlet 2.5 or newer.
  • The webapp's runtime classpath is littered with servlet container specific JAR files of a different servlet container make/version which does not support Servlet 2.5.
  • Make sure that the root declaration of web.xml complies Servlet 2.5 (or newer, at least the highest whatever your target runtime supports). For an example, see also somewhere halfway our servlets wiki page.
  • Make sure that you don't have any servlet container specific libraries like servlet-api.jar or j2ee.jar in /WEB-INF/lib or even worse, the JRE/lib or JRE/lib/ext. They do not belong there. This is a pretty common beginner's mistake in an attempt to circumvent compilation errors in an IDE, see also How do I import the javax.servlet API in my Eclipse project?.

Good answer, only point 2 is not correct. At least with Spring, if you don't declare Servlet 2.5 in your web.xml, but instead use 2.4 or before, there won't be Servlet 2.5-specific code executed, so you can't get the OP's error.

In my case, another dependency (Axis2) was loading servlet-api 2.3. Putting Axis2 at the end of my dependencies in pom.xml solved the problem. Tnx!

Are there any more than these 3? I am suddenly getting this message after yum auto-updated from tomcat 6.0.35 to 6.0.36. None of the webapps or jars have changed as far as the logs show...

I had the servlet 3.0.1 declared in my pom but another dependency had a transitive one on servlet-api-2.4. I exclueded the 2.4 version and everything worked.

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPa...

java servlets spring-mvc
Rectangle 27 64

  • The servlet container does not support Servlet 2.5.
  • The web.xml is not declared conform Servlet 2.5 or newer.
  • The webapp's runtime classpath is littered with servlet container specific JAR files of a different servlet container make/version which does not support Servlet 2.5.
  • Make sure that the root declaration of web.xml complies Servlet 2.5 (or newer, at least the highest whatever your target runtime supports). For an example, see also somewhere halfway our servlets wiki page.
  • Make sure that you don't have any servlet container specific libraries like servlet-api.jar or j2ee.jar in /WEB-INF/lib or even worse, the JRE/lib or JRE/lib/ext. They do not belong there. This is a pretty common beginner's mistake in an attempt to circumvent compilation errors in an IDE, see also How do I import the javax.servlet API in my Eclipse project?.

Good answer, only point 2 is not correct. At least with Spring, if you don't declare Servlet 2.5 in your web.xml, but instead use 2.4 or before, there won't be Servlet 2.5-specific code executed, so you can't get the OP's error.

In my case, another dependency (Axis2) was loading servlet-api 2.3. Putting Axis2 at the end of my dependencies in pom.xml solved the problem. Tnx!

Are there any more than these 3? I am suddenly getting this message after yum auto-updated from tomcat 6.0.35 to 6.0.36. None of the webapps or jars have changed as far as the logs show...

I had the servlet 3.0.1 declared in my pom but another dependency had a transitive one on servlet-api-2.4. I exclueded the 2.4 version and everything worked.

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPa...

java servlets spring-mvc
Rectangle 27 64

  • The servlet container does not support Servlet 2.5.
  • The web.xml is not declared conform Servlet 2.5 or newer.
  • The webapp's runtime classpath is littered with servlet container specific JAR files of a different servlet container make/version which does not support Servlet 2.5.
  • Make sure that the root declaration of web.xml complies Servlet 2.5 (or newer, at least the highest whatever your target runtime supports). For an example, see also somewhere halfway our servlets wiki page.
  • Make sure that you don't have any servlet container specific libraries like servlet-api.jar or j2ee.jar in /WEB-INF/lib or even worse, the JRE/lib or JRE/lib/ext. They do not belong there. This is a pretty common beginner's mistake in an attempt to circumvent compilation errors in an IDE, see also How do I import the javax.servlet API in my Eclipse project?.

Good answer, only point 2 is not correct. At least with Spring, if you don't declare Servlet 2.5 in your web.xml, but instead use 2.4 or before, there won't be Servlet 2.5-specific code executed, so you can't get the OP's error.

In my case, another dependency (Axis2) was loading servlet-api 2.3. Putting Axis2 at the end of my dependencies in pom.xml solved the problem. Tnx!

Are there any more than these 3? I am suddenly getting this message after yum auto-updated from tomcat 6.0.35 to 6.0.36. None of the webapps or jars have changed as far as the logs show...

I had the servlet 3.0.1 declared in my pom but another dependency had a transitive one on servlet-api-2.4. I exclueded the 2.4 version and everything worked.

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPa...

java servlets spring-mvc
Rectangle 27 1

The implementation of your interface is not present or is not at the correct version. Update the implementation version where it has that method implemented.

Im not sure if Im understanding, what do you mean. this is my code pastie.org/9524189, Im think if the interface is not present the desktop java aplication should not work

Yes but there need to be an implementation of that interface. I won't give you an error till you call a method of that interface. In your case com.sun.jna.Native.register is the interface. Most likely this should be its implementation net.sourceforge.tess4j.TessAPI1 check the version of this jar if it is the latest or not...

Im using maven and i have this <dependency> <groupId>net.sourceforge.tess4j</groupId> <artifactId>tess4j</artifactId> <version>1.3.0</version> </dependency> Is the unique version in the maven repository

what is the API version ? Did you just update the version or add it right now ?

In the Test API1.class I found this coment /** * A Java wrapper for <code>Tesseract OCR 3.02 API</code> using * <code>JNA Direct Mapping</code>. */ And this is the full error trace pastie.org/9524220

Cause of java.lang.NoSuchMethodError: com.sun.jna.Native.register(Ljav...

java java-ee tess4j
Rectangle 27 5

You seem to have the org.jboss.logging.Logger class in two libraries:

jboss:jboss-common:jar:4.2.2.GA and org.jboss.logging:jboss-logging:jar:3.1.3.GA

the second one is used by hibernate and I would thing it is the correct one. I think you need to use the correct jboss-common version to not run into this issue.

eclipse - java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMes...

java eclipse maven tomcat dependencies
Rectangle 27 2

You have an old and incompatible version of Tomcat on the classpath. Looking at your build.gradle, it must be coming from one of your fileTree dependencies. You should update their configuration to ensure that the only Tomcat dependencies on the classpath are those that are pulled in by spring-boot-starter-web. If you're not sure where the old Tomcat classes are being loaded from, running the app with -verbose:class will tell you.

Yes - I discovered that when I did a barebones project without my fileTree dependencies, I had no issues. I'm going to pull those out and resolve them one by one...thanks.

Spring Boot exception: java.lang.NoSuchMethodError: StandardJarScanner...

java spring tomcat gradle spring-boot
Rectangle 27 1

You are programming against implementation classes instead against interfaces and you are using AOP (@Transactional) .. please try to reference other spring beans via their interfaces.

Otherwise you have to make sure that your application is configured to proxy classes using cglib (Use of proxies in Spring AOP)

@ManagedProperty(value = "#{UserService}")     UserService userService;
Registration Failure, null

java.lang.NoSuchMethodError: spring.service.UserServiceImpl.addUser(Ls...

java spring
Rectangle 27 20

The getExpected() method on junit.framework.ComparisonFailure was only added in JUnit 3.8.2 (remember, junit.framework package is from JUnit 3.8, whereas JUnit 4 uses org.junit). The method wasn't there in 3.8.1, which is the most common version of 3.x still out there.

I think the method was added for easier migration to JUnit 4 tooling, and occasionally this exception pops up on older code bases that use JUnit 3.8. The Eclipse JUnit 4 test runner would appear to switch back to calling the junit.framework.* code when running JUnit 3.8 tests.

SO I'm guessing you still have JUnit 3.8.1 lurking about on your classpath, and it's clashing with the Eclipse test runner. Either get rid of that JAR, or "upgrade" it to 3.8.2.

If you do not see it in your project dependencies then one of the libraries might be using 3.8. If you cannot remove the library from there then try using the @RunWith(JUnit4.class) annotation.

unit testing - JUnit java.lang.NoSuchMethodError: junit.framework.Comp...

java unit-testing junit
Rectangle 27 20

The getExpected() method on junit.framework.ComparisonFailure was only added in JUnit 3.8.2 (remember, junit.framework package is from JUnit 3.8, whereas JUnit 4 uses org.junit). The method wasn't there in 3.8.1, which is the most common version of 3.x still out there.

I think the method was added for easier migration to JUnit 4 tooling, and occasionally this exception pops up on older code bases that use JUnit 3.8. The Eclipse JUnit 4 test runner would appear to switch back to calling the junit.framework.* code when running JUnit 3.8 tests.

SO I'm guessing you still have JUnit 3.8.1 lurking about on your classpath, and it's clashing with the Eclipse test runner. Either get rid of that JAR, or "upgrade" it to 3.8.2.

If you do not see it in your project dependencies then one of the libraries might be using 3.8. If you cannot remove the library from there then try using the @RunWith(JUnit4.class) annotation.

unit testing - JUnit java.lang.NoSuchMethodError: junit.framework.Comp...

java unit-testing junit
Rectangle 27 19

The problem is that you are mixing different versions of Spring, you are mixing (2.0.8, 3.1.4 and 4.0.2) in your project. That is trouble waiting to happen.

To prevent these kind of things there is now a so called "bill of materials" POM which you can import.

You need to add a dependencyManagement section to import the bom.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.0.5.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Now in your dependencies you can remove the version and replace spring-dao with spring-orm. Added benefit is that all your spring-* dependencies will now be managed to the latest release and you only have a single location for your version number.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
</dependency>

You could apply the same trick for Spring Data as that also has a bom.

Agree! Caused by having different versions of Spring.

spring - java.lang.NoSuchMethodError: org.springframework.core.annotat...

java spring maven junit