首页 \ 问答 \ Java Tomcat,底层Netty线程没有停止(Java Tomcat, underlying Netty threads not stopped)

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 my pom.xml configure the log4j2.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't kill -9 PID the tomcat and the catalina.out ends up with this : Complete stack trace

What 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
更新时间:2024-03-09 20:03

最满意答案

不,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 the import { 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中的文件夹范围 编辑:或者使其与您的构建脚本保持一致: ...
  • 您需要使用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: { ...
  • 将插件添加到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 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。