GVKun编程网logo

无法用jhat,jps,jstackdebuggingJava Windows服务(无法使用service:jmx:rmi:///jndi)

18

本文将介绍无法用jhat,jps,jstackdebuggingJavaWindows服务的详细情况,特别是关于无法使用service:jmx:rmi:///jndi的相关信息。我们将通过案例分析、数

本文将介绍无法用jhat,jps,jstackdebuggingJava Windows服务的详细情况,特别是关于无法使用service:jmx:rmi:///jndi的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于Debugging Chromium on Windows、debugging – 是否有Windowsdebugging器的检查点function?、debugging“安全点”错误 – 需要理论或实际来debuggingJVM崩溃?、debugging“服务无法启动”Windows安装程序错误的知识。

本文目录一览:

无法用jhat,jps,jstackdebuggingJava Windows服务(无法使用service:jmx:rmi:///jndi)

无法用jhat,jps,jstackdebuggingJava Windows服务(无法使用service:jmx:rmi:///jndi)

我经常在Linux和Mac上展示给开发者的jhat, jps和jstack工具。 但是,最近一位开发人员表示,如果所讨论的Java应用程序是作为Windows服务运行的,那么这些程序在Windows中是不可用的。

一个太阳提交的bug说了一些非常相似的东西 ,但由于不活动而被closures了。

我已经为自己testing过了,虽然我很难相信,但事实上的确如此。 这是设置:

Tomcat或类似的运行Windows服务与“login为”==“本地系统”

具有pipe理权限的用户login到同一台Windows机器。

pipe理员打开Windows任务pipe理器,可以看到java.exe正在运行

pipe理员打开控制台,键入“jps”,获取不包括Tomcat的Java服务进程的进程列表。

作为一个蛮力尝试,从Windows任务pipe理器获取作为服务的tomcat的PID。 键入jstack <pid>。 得到回复:<pid>没有这样的过程

这在Windows XP,Windows 2003 Server和Windows 7下显示重现。Java版本1.5和1.6产生相同的结果。

Windows服务Process.Start不在networking服务帐户下工作

为什么启动一个服务开始其他人(一个exe中的多个服务)?

如何从Windows服务启动系统帐户下的独立进程?

运行Java应用程序作为服务

Windows服务正在运行但事件日志无法正常工作

有没有办法从terminal,即使以pipe理员身份login,以“sudo up”来获得JPS和其他工具来看Java服务?

64位的ChangeServiceConfig2窗口function

如何在Windows Vista中创build一个服务的例子

如何使用C#从应用程序的安装文件夹读取文件?

是否有可能从Windows的Windows服务发送Windows Toast通知?

将Windows C ++服务器编写为服务或控制台应用程序

要运行实用程序,可以使用“mstsc / admin”使用登录帐户(不确定它需要的确切权限,我的是在Administrators组中)连接到控制台会话,并使用Sysinternals psexec工具作为系统。 这是一个使用jstack.exe的例子:

psexec -s "%JAVA_HOME%binjstack.exe" PID >stack.txt

其中PID是进程的进程ID。 您可能还必须根据具体环境,将实际路径替换为JDK。

此外, TEMP目录必须正确设置,否则工具将无法工作。

我已经运行由SYstem用户运行的进程运行这从命令提示符下运行:

c:> time/t 11:18 AM c:> at 11:19 /interactive cmd.exe Added a new job with job ID = 1

将来使用1分钟的时间。 当“at”作业运行时,Windows命令提示符将以用户SYstem的身份打开运行。 从那里你应该能够看到Java进程。

如果服务以本地用户身份运行(通过双击服务并选择“登录”选项卡检查“mmc%windir% system32 SERVICES.MSC”中的详细信息),则可以使用“runas “:

runas /user:USERNAME cmd.exe

你只能得到那些“属于”你的进程 – 相同的用户ID。

你可以用jvisualvm连接到它吗?

我只找到了一个建议来运行visuamvm(或其他工具)作为Windows服务: 监视作为Windows服务运行的Java进程

也许别人知道一个更好的解决方案。

这是我的批处理文件来记录线程转储

:: Creates a thread dump for the tomcat6.exe process saved in a timestamped filename and views it! :: Jim Birch 20111128 rev 2015-10-12 ::Note this required the following files to be placed in the confluence jre/bin folder: :: :: attach.dll - From the Java JDK (must be the same version) :: tools.jar - ditto :: psexec.exe - from Windows sysinternals :: Also,the TEMP directory must be set (stack overflow) set TEMP=c:windowstemp ::go to run location d: cd confluence.applicationjrebin ::build datetime filename rem datetime from wmi.exe for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set dt0=%%I rem datetime string as YYYY-MM-DD-hhmmss set dt=%dt0:~0,4%-%dt0:~4,2%-%dt0:~6,2%-%dt0:~8,6% set ff=td-%dt%.txt echo filename: %ff% ::tomcat PID FOR /F "tokens=2" %%I in ('TASKLIST /NH /FI "IMAGENAME eq tomcat6.exe"' ) DO SET PID=%%I ECHO pid: %PID% ::combine above with jstack command (won't work without psexec) psexec -s "D:confluence.applicationjrebinjstack.exe" -l %PID% >> %ff% :: view output txt file start %ff% ::pause to review script operation,or use ping to wait a few secs ::ping localhost -n 20 >nul pause

Debugging Chromium on Windows

Debugging Chromium on Windows

First see get the code for checkout and build instructions.

Getting started

You can use Visual Studio''s built-in debugger or WinDBG to debug Chromium. You don''t need to use the IDE to build in order to use the debugger: Ninja is used to build Chromium and most developers invoke it from a command prompt, and then open the IDE for debugging as necessary. To start debugging an executable from the command line:

devenv /debugexe out\Debug\chrome.exe  <options to Chromium can go here>
 
This assumes you have Visual Studio installed and have devenv.exe on your path. Note that the path to the binary must use backslashes and must include the ".exe" suffix or Visual Studio will open and do nothing.
 
Goma (the internal Google distributed build) defaults to symbol_level = 1 which means source-level debugging will not work. If you want full debugging with goma then you need to explicitly set symbol_level = 2, and is_win_fastlink = true, however this does tend to expose bugs in debuggers, so caveat debugger, and be sure to use the very latest versions of the debuggers.
 

Profiles

It''s a good idea to use a different profile for your debugging. If you are debugging Google Chrome branded builds, or use a Chromium build as your primary browser, the profiles can collide so you can''t run both at once, and your stable browser might see profile versions from the future (Google Chrome and Chromium use different profile directories by default so won''t collide). Use the command-line option:
 
--user-data-dir=c:\tmp\my_debug_profile  (replace the path as necessary)
 
Using the IDE, go to the  Debugging tab of the properties of the chrome project, and set the  Command Arguments.
 

Chrome debug log

Enable Chrome debug logging to a file by passing  --enable-logging --v=1 command-line flags at startup. Debug builds place the  chrome_debug.log file in the  out\Debug directory. Release builds place the file in the top level of the user data Chromium app directory, which is OS-version-dependent. For more information, see  logging and  user data directory details.
 

Symbol server

If you are debugging official Google Chrome release builds, use the symbol server:
 
https://chromium-browser-symsrv.commondatastorage.googleapis.com
 
In Visual Studio, this goes in  Tools > Options under  Debugging > Symbols. You should set up a local cache in a empty directory on your computer.
 
In windbg you can add this to your symbol server search path with the command below, where c:\Symbols is a local cache directory:
 
.sympath+ SRV*c:\Symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
 
You can also set the _NT_SYMBOL_PATH environment variable to include both the Microsoft and Google symbol servers - VS and windbg should both respect this environment variable:
 
_NT_SYMBOL_PATH=SRV*C:\symbols*https://msdl.microsoft.com/download/symbols;SRV*C:\symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
 
Note that symbol servers will let the debuggers download both the PE files (DLLs and EXEs) and the PDB files.
 
If you set up source indexing (.srcfix in windbg, Tools-> Options-> Debugging-> General-> Enable source server support in Visual Studio) then the correct source files will automatically be downloaded based on information in the downloaded symbols.
 

Multi-process issues

Chromium can be challenging to debug because of its multi-process architecture. When you select Run in the debugger, only the main browser process will be debugged. The code that actually renders web pages (the Renderer) and the plugins will be in separate processes that''s not (yet!) being debugged. The ProcessExplorer tool has a process tree view where you can see how these processes are related. You can also get the process IDs associated with each tab from the Chrome Task Manager (right-click on an empty area of the window title bar to open).

Automatically attach to child processes

There are two Visual Studio extensions that enable the debugger to automatically attach to all Chrome processes, so you can debug all of Chrome at once. Microsoft''s Child Process Debugging Power Tool is a standalone extension for this, and VsChromium is another option that bundles many other additional features. In addition to installing one of these extensions, you must run Visual Studio as Administrator, or it will silently fail to attach to some of Chrome''s child processes.

Single-process mode

One way to debug issues is to run Chromium in single-process mode. This will allow you to see the entire state of the program without extra work (although it will still have many threads). To use single-process mode, add the command-line flag

--single-process

This approach isn''t perfect because some problems won''t manifest themselves in this mode and some features don''t work and worker threads are still spawned into new processes.

Manually attaching to a child process

You can attach to the running child processes with the debugger. Select  Tools > Attach to Process and click the chrome.exe process you want to attach to. Before attaching, make sure you have selected only Native code when attaching to the process This is done by clicking Select... in the Attach to Process window and only checking Native. If you forget this, it may attempt to attach in "WebKit" mode to debug JavaScript, and you''ll get an error message "An operation is not legal in the current state."
 
You can now debug the two processes as if they were one. When you are debugging multiple processes, open the  Debug > Windows > Processes window to switch between them. 
 
 
Sometimes you are debugging something that only happens on startup, and want to see the child process as soon as it starts. Use:
 
--renderer-startup-dialog --no-sandbox
 
You have to disable the sandbox or the dialog box will be prohibited from showing. When the dialog appears, visit Tools > Attach to Process and attach to the process showing the Renderer startup dialog. Now you''re debugging in the renderer and can continue execution by pressing OK in the dialog.
 
Startup dialogs also exist for other child process types:  --gpu-startup-dialog--ppapi-startup-dialog--plugin-startup-dialog (for NPAPI).
 
You can also try  the vs-chromium plug-in to attach to the right processes.

Semi-automatically attaching the debugger to child processes

The following flags cause child processes to wait for 60 seconds in a busy loop for a debugger to attach to the process. Once either condition is true, it continues on; no exception is thrown.
--wait-for-debugger-children[=filter]
The filter, if provided, will fire only if it matches the  --type parameter to the process. Values include  rendererplugin (for NPAPI),  ppapigpu-process, and  utility.
 
When using this option, it may be helpful to limit the number of renderer processes spawned, using:

--renderer-process-limit=1

Image File Execution Options

Using Image File Execution Options (IFEO) will not work because CreateProcess() returns the handle to the debugger process instead of the intended child process. There are also issues with the sandbox.
 
 

Visual Studio hints

Debug visualizers

Chrome''s custom debug visualizers should be added to the pdb files and automatically picked up by Visual Studio. The definitions are in  //tools/win/DebugVisualizers if you need to modify them (the BUILD.gn file there has additional instructions).

Don''t step into trivial functions

The debugger can be configured to automatically not step into functions based on regular expression. Edit default.natstepfilter in the following directory:
  • For Visual Studio 2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers (for all users)
    or 
    %USERPROFILE%\My Documents\Visual Studio 2015\Visualizers (for the current user only)
  • For Visual Studio 2017 Pro: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Packages\Debugger\Visualizers (for all users)
    or 
    %USERPROFILE%\My Documents\Visual Studio 2017\Visualizers (for the current user only)
Add regular expressions of functions to not step into. Remember to regex-escape  and XML-escape them, e.g.  &lt; for  < and  \. for a literal dot. Example:
 
  <Function><Name>operator new </Name><Action> NoStepInto </Action></Function>
  <Function><Name> operator delete </Name><Action>NoStepInto </Action></Function>
   <!-- Skip everything in std -->
  <Function><Name>std::.*</Name><Action>NoStepInto </Action></Function>
   <!-- all methods on WebKit OwnPtr and variants, ... WTF::*Ptr<*>::* -->
  <Function><Name> WTF::.*Ptr&lt;.*&gt;::.* </Name><Action>NoStepInto </Action></Function>
 
This file is read at start of a debugging session (F5), so you don''t need to restart Visual Studio after changing it.
More info:  Andy Pennel''s Blog,  microsoft email thread

V8 and Chromium

V8 supports many command-line flags that are useful for debugging. V8 command-line flags can be set via the Chromium command-line flag --js-flags; for instance:

chrome.exe --js-flags="--trace_exception --heap_stats"

Note that some V8 command-line flags exist only in the debug build of V8. For a list of all V8 flags try:

chrome.exe --js-flags="--help"

Graphics debugging

GPU Acceleration of rendering can be more easily debugged with tools. See:
  • Graphics Debugging in Visual Studio 2013
  • Graphical debugging with NVIDIA NSight

Debugging on another machine

Sometimes it''s useful to debug installation and execution on a machine other than your primary build box. To run the installer on said other machine, first build the mini_installer target on your main build machine (e.g., ninja -C out\Debug mini_installer). Next, on the debug machine:
  • Make the build machine''s build volume available on the debug machine either by mounting it locally (e.g., Z:\) or by crafting a UNC path to it (e.g., \\builder\src)
  • Open up a command prompt and change to a local disk
  • Run src\tools\win\copy-installer.bat in the remote checkout by way of the mount (e.g., Z:\PATHTOCHECKOUT\src\...) or UNC path (e.g., \\builder\src\...). This will copy the installer, DLLs, and PDBs into your debug machine''s C:\out or C:\build (depending on if you''re rocking the component=shared_library build or not)
  • Run C:\out\Debug\mini_installer.exe with the flags of your choice to install Chrome. This can take some time, especially on a slow machine. Watch the Task Manager and wait until mini_installer.exe exits before trying to launch Chrome (by way of the shortcut(s) created by the installer)
  • For extra pleasure, add C:\out\Debug to your _NT_SYMBOL_PATH environment variable
Consider reading the documentation at the top of copy-installer.bat to see how you can run it. It tries to be smart and copy the right things, but you may need to be explicit (e.g., "copy-installer.bat out Debug"). It is safe to re-run the script to copy only modified files (after a rebuild, for example).

Find memory leaks

The Windows heap manager has a really useful debug flag, where it can be asked to capture and store a stack trace with every allocation. The tool to scrape these stack traces out of processes is UMDH, which comes with  WinDbg.
 
UMDH is great. It will capture a snapshot of the heap state as many times as you like, and it''ll do it fairly quickly. You then run it again against either a single snapshot, or a pair of snapshots, at which time it''ll symbolize the stack traces and aggregate usage up to unique stack traces.
 
Turning on the user stack trace database for chrome.exe with gflags.exe makes it run unbearably slowly; however, turning on the user stack trace database on for the browser alone is just fine.
 
While it''s possible to turn on the user stack database with the "!gflag" debugging extension, it''s too late to do this by the time the initial debugger breakpoint hits. The only reasonable way to do this is to 
  1. Launch GFlags.exe,
  2. Enable the user stack trace database (per image below),
  3. Launch Chrome under the debugger.
  4. Set a breakpont when chrome.dll loads with "sxe ld chrome.dll".
  5. Step up, to allow Chrome.dll to initialize.
  6. Disable the stack trace database in GFlags.exe.
  7. Continue chrome, optionally detaching the debugger.
 
GFlags.exe settings for user mode stack trace database.
If you then ever suffer a browser memory leak, you can snarf a dump of the process with 
 
umdh -p:<my browser pid> > chrome-browser-leak-umdh-dump.txt
 
which can then typically be "trivially" analyzed to find the culprit.

Miscellaneous

  • Application Verifier is a free tool from Microsoft (available as part of the Windows SDK) that can be used to flush out programming errors. Starting with M68 Application Verifier can be enabled for chrome.exe without needing to disable the sandbox. After adding chrome.exe to the list of applications to be stressed you need to expand the list of Basics checks and disable the Leak checks. You may also need to disable Handles and Locks checks depending on your graphics driver and specific Chrome version, but the eventual goal is to have Chrome run with Handles and Locks checks enabled. When bugs are found Chrome will trigger a breakpoint so running all Chrome processes under a debugger is recommended. Chrome will run much more slowly because Application Verifier puts every allocation on a separate page.
  • You can check the undocumented ''Cuzz'' checkbox in Application Verifier to get the Windows thread scheduler to add some extra randomness in order to help expose race conditions in your code.
  • Putting every allocation on a separate page will dramatically affect performance so you may want to only do this for some applications. If you right-click on the Heaps checkbox and select Properties you can edit things like the size range for what allocations go into PageHeap (the page-per-allocation system) and you can set a RandRate percentage to randomly put allocations in PageHeap.
  • To put a breakpoint on CreateFile(), add this break point:
{,,kernel32.dll}_CreateFileW@28
    • {,,kernel32.dll}specifies the DLL (context operator).
    • _ prefix means extern "C".
    • @28 postfix means _stdcall with the stack pop at the end of the function. i.e. the number of arguments in BYTES.
  • You can use DebugView from SysInternals or sawbuck to view LOG() messages that normally goes to stderr on POSIX.

debugging – 是否有Windowsdebugging器的检查点function?

debugging – 是否有Windowsdebugging器的检查点function?

有一个窗口(win32,.net)debugging器可以做一些像gdb检查点?

http://sourceware.org/gdb/current/onlinedocs/gdb/Checkpoint_002fRestart.html

在我的新窗口安装Image.FromStream不以相同的方式工作

什么是控件的“On_Load”等效表单?

当窗体位于主监视器的上方和左方时,光标变为对angular线resize

.Net Windows服务和FileSystemWatcher问题

获取当前在Windows任务栏中可见的应用程序(或窗口)列表

我在Windows上听到的最接近的功能是IntelliTrace 。 另一个文档在这里: http : //msdn.microsoft.com/en-us/library/dd264915%28VS.100%29.aspx

该功能有很多限制 – 没有64位本地代码,脚本或sql CLR支持

debugging“安全点”错误 – 需要理论或实际来debuggingJVM崩溃?

debugging“安全点”错误 – 需要理论或实际来debuggingJVM崩溃?

我们在AWS上运行的ubuntu服务器上发生了令人难以置信的jvm崩溃。

我们的JVM在抓取几个网页时崩溃。

崩溃发生在“安全点”cpp模块的第308行。 在gauranteeArmed == 0声明发生的阶段。

我们的系统pipe理员build议,在崩溃的时候,JVM创build了大量的线程。

我们没有在其他Linux或OSX盒子中重现这个错误。

我们使用Ning库来抓取一些网页。

相关文章

如何调查JVM崩溃的原因?

JBoss / HotSpot JVM崩溃

在每一篇文章中都观察到一个来自“无处”的“安全点”相关的崩溃。 最有趣的是,上面的第一个post实际上是在networking相关事件中出现JVM崩溃。

这个bug的神秘性使我相信有一个与线程创build和调度有关的bug,这个bug是我们当前版本的Ubuntu特有的,就java调用它的一些并发特性的方式来说,或者是一些底层的库不兼容性对我们特定的情况非常特别。

我的问题

我的主要问题是 – debugging涉及这些“安全点”的JVM堆栈跟踪的最佳方法是什么?从哪里可以开始了解如何处理这些错误? 还有其他一些问题,但我没有看到一个通用的答案。

其次,对于aws,java,networking以及Ubuntu在云中的行为方式的深入了解,在这里将会非常有用。

尝试使用最新的JVM(6u32或7u4),看看它是否仍然可重现。 如果你使用的是旧版本,至少有一个很好的机会,它已经被修复了。

debugging“服务无法启动”Windows安装程序错误

debugging“服务无法启动”Windows安装程序错误

我有一个用WiX编写的简单的msi来安装一个本地的NT服务。 在msi中进行了一些更改后,它在StartServices标准操作中失败,出现错误“服务启动失败,请确认您有足够的权限”。 如果按“忽略”并手动启动服务,则会成功启动。 问题绝对不是没有足够的权限。 我如何诊断/debugging这些问题? Windows安装程序的详细日志似乎不包含任何有用的信息。

Java计划任务(在Windows中)

C#Windows服务不会显示为已启动

Windows服务和Windows进程有什么区别?

在C#服务应用程序中configurationlog4net的步骤

.NET Windows服务 – 一个项目中的多个服务

安装程序将没有任何有用的信息,因为错误只是由安装程序浮出水面。 这是我如何处理这个。

注释掉ServiceControl元素,这样安装程序不会尝试启动服务。 运行安装程序,并完成。 手动启动服务。

如果服务启动,则表示某种竞争条件。 一种常见的情况是服务依赖于安装到GAC或WinSXS的文件。 安装程序使用PublishAssemblies标准操作将这些文件放在那里。 但是由于GAC和WinSXS API不支持跨越式安装,PublishAssemblies会一直等到提交阶段执行工作。 这是安装程序尝试启动服务之后。 另一种常见的情况是,如果您有一些自定义操作正在安装或配置服务所需的某些内容,并且您在安装过程中所做的操作较晚。

如果服务仍然无法启动,这通常会排除竞争条件。 你必须分析服务本身。 使用诸如依赖,ildasm(如.net)和processexplorer(filemon / regmon)等工具来尝试发现缺少的依赖关系。 更新安装程序,然后冲洗并重复。

如您所见,Windows Installer在启动服务失败时不提供有用的信息。 但是,当显示对话框时,机器处于完美状态以确定发生了什么问题。 所以,而不是取消安装,开始调试。 尝试启动服务,看看是否给你更多的信息。 如果没有,请打开调试器并去镇上。

我基本上遵循这个FireGiant知识库文章中描述的过程。 这是找出服务无法启动的最直接的方法。 Windows Installer不能提供更好的信息本身就太糟糕了。

今天关于无法用jhat,jps,jstackdebuggingJava Windows服务无法使用service:jmx:rmi:///jndi的分享就到这里,希望大家有所收获,若想了解更多关于Debugging Chromium on Windows、debugging – 是否有Windowsdebugging器的检查点function?、debugging“安全点”错误 – 需要理论或实际来debuggingJVM崩溃?、debugging“服务无法启动”Windows安装程序错误等相关知识,可以在本站进行查询。

本文标签: