java. lang.NoSuchMethodError: javax. servlet. ServletContext. getContextPath()Ljava/lang/String;

Problem Description: in eclipse 3 This error always occurs when starting Tomcat6 in 7,

     java. lang.NoSuchMethodError: javax. servlet. ServletContext. getContextPath()Ljava/lang/String;

After searching the Internet for a long time, there were different opinions, and finally found a solution. With reference to this method, my problem was solved.

Solution: find the JDK installation directory and enter JRE \ lib \ ext to see if there is a servlet API Jar (mine does not). If not, copy the servlet-api.jar in Tomcat to JRE \ lib \ ext

If you restart tomcat, the error does not appear.

If you have this rack package under JRE \ lib \ ext and there is still an error, you can try using the servlet API in Tomcat Replace servlet API. Jar under JRE \ lib \ ext Jar, restart Tomcat

Updated February 14, 2020:

An error is reported when starting Dubbo project:

Exception in thread "NettyClientWorkerThread_4" java. lang.NoClassDefFoundError: com/aliyun/openservices/shade/io/netty/util/concurrent/DefaultPromise$1 at com. aliyun. openservices. shade. io. netty. util. concurrent. DefaultPromise. notifyListeners(DefaultPromise.java:435) at com. aliyun. openservices. shade. io. netty. util. concurrent. DefaultPromise. setSuccess(DefaultPromise.java:102) at com. aliyun. openservices. shade. io. netty. util. concurrent. SingleThreadEventExecutor$2. run(SingleThreadEventExecutor.java:179) at java. lang.Thread. run(Thread.java:745)

At first glance, it's Java Lang. NoClassDefFoundError. Naturally, it is thought that this class cannot be found during class loading.

Then I checked the jar package and found that it was in ons-client-1.8 0.Final. Jar.

@H_ 301_ 96@com /aliyun/openservices/ons-client/1.8. 0.Final

@H_ 301_ 96@ons -client-1.8. 0.Final. jar

After the MVN package is executed in the actual project, if there is this jar, why will there be errors. Continue to turn the log and find that there is a dependency loading problem at the top.

Originally, there was a problem with Dubbo: reference configuration. Group = "@ Dubbo. Someservice. Group @"

The configuration corresponding to the placeholder in the group of Dubbo reference here forgot to load in the properties configuration file.

It is obviously a dependency problem, but it reports an error Java Lang. NoClassDefFoundError, pit father.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>