Java Tomcat,底层Netty线程没有停止(Java Tomcat, underlying Netty threads not stopped)
我正在尝试使用log4j appender将日志发送到GrayLog2(
log4j2-gelf
)。 所以我将我的依赖项添加到我的pom.xml
配置log4j2.xml
来配置我的appender。 使用maven构建整个东西并将其部署到本地tomcat,一切正常。 当我尝试关闭tomcat时会发生问题。 Tomcat不会停止,如果我不kill -9 PID
tomcat和catalina.out
最终得到这样: 完成堆栈跟踪引起我注意的是
java.lang.NoClassDefFoundError:io / netty / util / concurrent / DefaultPromise $ 1
首先,我认为我可能有另一个依赖导入netty会导致此异常。 但我已经找了一些时间,并且无法找到任何其他网络导入。 然后我看到了:
引起:java.lang.ClassNotFoundException:非法访问:此Web应用程序实例已经停止。 无法加载[io.netty.buffer.PoolArena $ 1]。 抛出以下堆栈跟踪以进行调试以及尝试终止导致非法访问的线程。
这就是我的问题。 我的理解是gelf-appender使用Netty作为与GrayLog服务器异步通信的方式。 但它本身就是服务器。 那么Tomcat是否有可能在杀死底层Netty之前停止父servlet? 哪会导致这个问题? 我试图找到关于Tomcat关闭的方式的一些文档,但到目前为止我没有找到任何东西,超过我对这个诊断完全错误...
I'm trying to use a log4j appender to send logs to GrayLog2 (
log4j2-gelf
). So I add my dependency to mypom.xml
configure thelog4j2.xml
to configure my appender. Build the whole thing with maven and deploy it to a local tomcat, and everything works fine. The problem happen when I try to shutdown the tomcat. Tomcat does not stop if I don'tkill -9 PID
the tomcat and thecatalina.out
ends up with this : Complete stack traceWhat got my attention is the
java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
First I thought that I may have another dependency importing netty that would cause this exception. But I've looking for some time and was not able to find any other netty import. Then I saw the :
Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [io.netty.buffer.PoolArena$1]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
And this is where my question is coming. My understanding is that the gelf-appender is using Netty as a way to communicate asynchronously with the GrayLog server. But it's a server itself. So would it be possible that the Tomcat is stopping the parent servlet before killing the underlying Netty ? Which would lead to this problem ? I've trying to find some documentation on the way that Tomcat shutsdown, but so far I did not find anything, more than that I could perfectly be wrong concerning this diagnostic...
原文:https://stackoverflow.com/questions/40930844
最满意答案
不,webpack不仅会在你的包中包含jquery的ajax部分,即使你正在使用Webpack 2(webpack 1和之前没有实现树摇动;也就是说,整个模块将包含在你的包中,而不仅仅是你导入的那些)这是因为在NPM中如何销售jquery:作为一个大型jquery.js模块。
如果您打算使用jquery,可以使用ajax模块构建jquery,但这需要一些手动操作(例如,您不能只
import {ajax} from 'jquery'
执行import {ajax} from 'jquery'
)。 有一个用于lodash的babel插件,它可以在自己的模块中销售每个方法,因此您不必在webpack构建中包含所有lodash。 它是一个babel插件,因为它依赖于import { some_method } from 'library'
语法中的import { some_method } from 'library'
。如果您正在寻找一个简单的ajax库,我强烈建议使用isomorphic-fetch (在浏览器中,只使用'whatwg-fetch')。 它使您的代码非常整洁。
No, webpack will not only include the ajax portions of jquery in your bundle, even if you are using Webpack 2 (webpack 1 and previous does not implement tree-shaking; that is, the entire module will be included in your bundle, not just those that you import) this is because of how jquery is vended in NPM: as one, large jquery.js module.
If you are intent on using jquery, there are ways to build jquery using only the ajax module, but this will require some manual effort (eg. you can't just do
import {ajax} from 'jquery'
). There is a babel plugin for lodash, which does vend each method in its own module so you don't have to include all of lodash in your webpack build. It is a babel plugin because it relies on theimport { some_method } from 'library'
syntax.If you are looking for an easy ajax library, I highly recommend using isomorphic-fetch (which, in browsers, just uses 'whatwg-fetch'). It keeps your code very tidy.
相关问答
更多-
您需要使用expose-loader来使jQuery可用于全局范围内的其他脚本。 module: { rules: [{ test: require.resolve('jquery'), use: [{ loader: 'expose-loader', options: 'jQuery' },{ loader: 'expose-loader', options: '$' }] }] } You need ...
-
问题 我正在使用这篇文章只导入我需要的jQuery的部分。 本文是在jquery 2.2.0发布之前编写的。 在jQuery 2.1.x中 : // jquery/src/selector-sizzle.js define([ "./core", "sizzle" ], function( jQuery, Sizzle ) { //... }) 所以sizzle被解析为
/node_modules/sizzle 然而在jQuery 2.2.x中 : // jquer ... -
节点项目中webpack的正确路径是./node_modules/.bin/wepback 在npm脚本中,您可以访问所有节点模块,就好像它们位于PATH上一样,因此您需要这样: "dev":"clear; npm run --silent sound:trash; webpack --env development --watch; npm run --silent sound:microwave" 请注意,webpack不需要package.json中的文件夹范围 编辑:或者使其与您的构建脚本保持一致: ...
-
Webpack 3'未捕获ReferenceError:jquery未定义'(Webpack 3 'Uncaught ReferenceError: jquery is not defined')[2023-08-30]
您需要使用ProvidePlugin,而不是DefinePlugin。 并删除“外部”部分。 You need to use ProvidePlugin, not DefinePlugin. And also remove "externals" section. -
这不完全正确 - “我已经通过npm下载并按照文档中的说明导入了它”。 您不必将require('fancybox')($)赋值给变量,此调用不返回任何内容。 下面 - 它是来自docs的片段 var $ = require('jquery'); 需要( '的fancybox')($); <-------(2) 您可以使用console.log($.fancybox)检查您的jQuery对象是否具有fancybox方法。 如果它返回一个函数,则表示您已成功将fancybox包导入代码。 所以你应该在另一个地 ...
-
你有没有尝试过: module.exports = { ... resolve: { alias: { jquery: "jquery/src/jquery" } } }; 有一个相关的答案显示了在这里导入jQuery的所有选项: 在webpack中管理jQuery插件依赖 Have you tried: module.exports = { ... resolve: { alias: { ...
-
jQuery与Webpack 2(jQuery with Webpack 2)[2023-02-16]
将插件添加到webpack配置的插件部分,如下所示: var webpack = require('webpack') ... plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', }) ] 编辑: 你有循环依赖: timeago: jquery client: timeago jquery 但是jquery和client是同一个bundle。 尝试在html中切换include js包,如下 ... -
不,webpack不仅会在你的包中包含jquery的ajax部分,即使你正在使用Webpack 2(webpack 1和之前没有实现树摇动;也就是说,整个模块将包含在你的包中,而不仅仅是你导入的那些)这是因为在NPM中如何销售jquery:作为一个大型jquery.js模块。 如果您打算使用jquery,可以使用ajax模块构建jquery,但这需要一些手动操作(例如,您不能只import {ajax} from 'jquery'执行import {ajax} from 'jquery' )。 有一个用于l ...
-
如何使用Webpack包含jQuery和jQuery验证?(How to include jQuery and jQuery Validation using Webpack?)[2022-01-18]
jquery只能在DOM上使用。 验证也是如此 https://www.npmjs.com/package/jquery#node 因此,如果要包含jquery,则必须使用脚本标记将其注入客户端条目文件(webpack)中 这样,jquery将始终在具有DOM的环境中运行。 之后,您将能够通过窗口使用jquery。$在您的反应应用程序中。 (componentDidMount) (componentWillMount does not support DOM afaik) jquery can only ... -
如果您只是按正确的顺序将所需的脚本添加到页面中,则无需担心webpack中的脚本。 您所要做的就是告诉webpack这些模块是从外部引用加载的,如下所示: { externals: { 'jquery': 'jQuery' } } 这告诉webpack每次需要('jquery')它将返回一个全局可用的变量jQuery。 If you just add the scripts you need to the page in the correct order, you don't need ...