简体   繁体   中英

Tomcat 7 NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()

I am having trouble deploying a web application on tomcat 7. The application is compiled using JDK 7 so I configured tomcat to use JDK 7 by setting JAVA_HOME=/usr/lib/jvm/jdk1.7.0_80/ in /etc/default/tomcat7 . When I run top I can confirm that tomcat is using java 7. However when I try to browse the application I get the following exception

java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
    at org.apache.catalina.core.ApplicationContext.getInitParameterNames(ApplicationContext.java:368)
    at org.apache.catalina.core.ApplicationContextFacade.getInitParameterNames(ApplicationContextFacade.java:367)
    at com.intel.mtwilson.jpa.PersistenceManager.contextInitialized(PersistenceManager.java:143)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

As far as I understand this method has different return types in JDK 7 and JDK 8 and tomcat is for some reason looking for the JDK 8 version even through it is configured to run in JDK 7. What is the reason for this? Do I have to configure anything else to make tomcat use JDK 7?

I think the issue is the the Tomcat you are using wasn't actually compiled with Java 7. It looks like there are some Tomcat 7 builds floating around that were compiled with Java 8 .

You should use Java 8. Even if Tomcat was compiled with Java 7, it should run on Java 8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM