当关闭tomcat服务器时,无法加载org.apache.hadoop.util.ShutdownHookManager [英] Could not load org.apache.hadoop.util.ShutdownHookManager when shutdown tomcat server

查看:2595
本文介绍了当关闭tomcat服务器时,无法加载org.apache.hadoop.util.ShutdownHookManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在tomcat上的简单Web应用程序。这个Web应用程序读写HDFS文件。



我每次遇到使用 ./ bin / shutdown.sh 。我得到了无法加载hadoop的shutdownHookManager异常。

我确定hadoop-common(包含ShutDownManager)在tomcat classpath中。



任何人都可以帮我解决问题吗?



例外我得到了:

  2013年10月14日下午5点57分54秒org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks 
SEVERE:Web应用程序[]使用键创建了一个ThreadLocal类型为[com.ebay.kernel.calwrapper.CalTransactionHelper $ 1](值为[com.ebay.kernel.calwrapper.CalTransactionHelper$1@3d5a1c5f])并且类型为[com.ebay.kernel.calwrapper.CalTransactionHelper.Stack](值[[]]),但在Web应用程序停止时未能删除它。线程将随着时间的推移而被更新,以避免可能的内存泄漏。
2013年10月14日下午5点57分54秒org.apache.coyote.AbstractProtocol stop
INFO:停止ProtocolHandler [http-bio-8080]
2013年10月14日5:57 :54 PM org.apache.coyote.AbstractProtocol stop
INFO:停止ProtocolHandler [ajp-bio-8009]
2013年10月14日下午5点57分54秒org.apache.coyote.AbstractProtocol破坏
INFO:销毁ProtocolHandler [http-bio-8080]
2013年10月14日下午5点57分54秒org.apache.coyote.AbstractProtocol销毁
INFO:销毁ProtocolHandler [ajp -bio-8009]
2013年10月14日下午5点57分54秒org.apache.catalina.loader.WebappClassLoader loadClass
INFO:非法访问:此Web应用程序实例已被停止。无法加载org.apache.hadoop.util.ShutdownHookManager $ 2。最终的跟踪堆栈跟踪是由于出于调试目的而抛出的错误以及试图终止导致非法访问的线程而引起的,并且没有功能影响。
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1559)
at org.apache.hadoop.util.ShutdownHookManager.getShutdownHooksInOrder(ShutdownHookManager.java:124)
at org.apache.hadoop.util.ShutdownHookManager $ 1.run(ShutdownHookManager.java: 52)
在线程Thread-9中的异常java.lang.NoClassDefFoundError:org / apache / hadoop / util / ShutdownHookManager $ 2
在org.apache.hadoop.util.ShutdownHookManager.getShutdownHooksInOrder(ShutdownHookManager.java :124)
在org.apache.hadoop.util.ShutdownHookManager $ 1.run(ShutdownHookManager.java:52)
引起:java.lang.ClassNotFoundException:org.apache.hadoop.util.ShutdownHookManager $ 2
位于org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
位于org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader。 java:1559)
... 2 more


解决方案

我在建造一个majo Mojo时遇到同样的问题。我认为这个问题是由在您的Web应用程序中加载hadoop类的上下文类加载器引起的。 WebAppClassLoader类加载器不可见这些定义。当发生JVM关闭时,关闭钩子正在执行,并调用ShutdownHookManager,但它被加载到现在销毁的上下文类加载器中,并且出现问题。

将hadoop jar放在tomcat的lib目录中可能会有所帮助。或者在启动tomcat时设置一些* _CLASSPATH java选项。这样,WebAppClassLoader将定义类。



否则,您可以在销毁上下文之前手动执行hadoop的关闭挂钩并忽略上述异常。

I have a simple web application run on tomcat. This web application read and write file to HDFS.

The issue I am facing is each time when I stop the server by using ./bin/shutdown.sh. I am getting could not load hadoop shutdownHookManager exception.

I am sure the hadoop-common (contains ShutDownManager) is in tomcat classpath.

Can anyone help me out?

Exception I got:

Oct 14, 2013 5:57:54 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] created a ThreadLocal with key of type [com.ebay.kernel.calwrapper.CalTransactionHelper$1] (value [com.ebay.kernel.calwrapper.CalTransactionHelper$1@3d5a1c5f]) and a value of type [com.ebay.kernel.calwrapper.CalTransactionHelper.Stack] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Oct 14, 2013 5:57:54 PM org.apache.coyote.AbstractProtocol stop 
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Oct 14, 2013 5:57:54 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Oct 14, 2013 5:57:54 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Oct 14, 2013 5:57:54 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Oct 14, 2013 5:57:54 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.apache.hadoop.util.ShutdownHookManager$2.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
  at org.apache.hadoop.util.ShutdownHookManager.getShutdownHooksInOrder(ShutdownHookManager.java:124)
  at org.apache.hadoop.util.ShutdownHookManager$1.run(ShutdownHookManager.java:52)
Exception in thread "Thread-9" java.lang.NoClassDefFoundError: org/apache/hadoop/util/ShutdownHookManager$2
  at org.apache.hadoop.util.ShutdownHookManager.getShutdownHooksInOrder(ShutdownHookManager.java:124)
  at org.apache.hadoop.util.ShutdownHookManager$1.run(ShutdownHookManager.java:52)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.ShutdownHookManager$2
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
  ... 2 more

解决方案

I have the same problem in a maven Mojo I'm building. I think that the problem is caused by the context class loader that loads hadoop classes in your web application. These definitions are not visible by the WebAppClassLoader class loader. When JVM shutdown occurs, shutdown hooks are being executed and that calls the ShutdownHookManager but it was loaded in now destroyed context class loader, and there you have the problem.

Putting hadoop jars in the lib directory of your tomcat will probably help. Or setting some *_CLASSPATH java option when you're starting tomcat. That way the WebAppClassLoader will have definitions of your classes.

Otherwise, you can just execute hadoop's shutdown hooks manually before you destroy your context and ignore the above exception.

这篇关于当关闭tomcat服务器时,无法加载org.apache.hadoop.util.ShutdownHookManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆