gpt4 book ai didi

java - 如何在预编译的 jar 文件的执行因 nullpointerException 停止之前进行调试?

转载 作者:行者123 更新时间:2023-12-01 12:47:32 29 4
gpt4 key购买 nike

我想调试为什么对象从这一行返回 null

debug_log = LoggingConfigFileLoader.getLogFilePaths().get("debug.log");

在这里:https://github.com/UniversalMediaServer/UniversalMediaServer/blob/master/src/main/java/net/pms/PMS.java#L356

我希望知道异常发生之前发生了什么java执行。不幸的是,.jar 来自一个大项目,可能很难构建。尤其是对于我这个对java一无所知的人来说。这是在 openjdk7 上(java 开发人员也使用它)。然而,该代码以前从未在 FreeBSD 上运行过。

最后,我想找到这个未处理异常的真正原因/根本原因:

ums4 UMS/ root~# /usr/local/openjdk7/bin/java -Djava.awt.headless=true -classpath /usr/local/share/universal-media-server/ums.jar net.pms.PMS
18:18:12.424 [main] DEBUG o.a.c.c.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is /root/.config/UMS/UMS.conf
18:18:12.430 [main] DEBUG o.a.c.c.DefaultFileSystem - Could not locate file /root/.config/UMS/UMS.conf at null: no protocol: /root/.config/UMS/UMS.conf
18:18:12.431 [main] DEBUG o.a.c.c.ConfigurationUtils - Loading configuration from the absolute path /root/.config/UMS/UMS.conf
18:18:12.431 [main] DEBUG o.a.c.c.PropertiesConfiguration - Base path set to file:///root/.config/UMS/UMS.conf
18:18:12.463 [main] DEBUG o.a.c.c.PropertiesConfiguration - FileName set to UMS.conf
18:18:12.464 [main] DEBUG o.a.c.c.PropertiesConfiguration - Base path set to /root/.config/UMS
18:18:12.480 [main] DEBUG n.p.c.ConfigurationReader - Reading cred.path: default: "", current: "/root/.config/UMS/UMS.cred"
18:18:12.498 [main] INFO net.pms.PMS - Starting Universal Media Server 4.0.0-a1
18:18:12.499 [main] INFO net.pms.PMS - Based on PS3 Media Server by shagrath, copyright 2008-2014
18:18:12.499 [main] INFO net.pms.PMS - http://www.universalmediaserver.com
18:18:12.499 [main] INFO net.pms.PMS -
18:18:12.499 [main] INFO net.pms.PMS - Build: 38318285b (2014-06-02)
18:18:12.499 [main] INFO net.pms.PMS - Java: OpenJDK 64-Bit Server VM 1.7.0_60 64-bit by Oracle Corporation
18:18:12.500 [main] INFO net.pms.PMS - OS: FreeBSD 64-bit 9.2-RELEASE-p3
18:18:12.500 [main] INFO net.pms.PMS - Encoding: US-ASCII
18:18:12.522 [main] INFO net.pms.PMS - Memory: 313 MB
18:18:12.522 [main] INFO net.pms.PMS - Language: en
18:18:12.522 [main] INFO net.pms.PMS -
18:18:12.523 [main] INFO net.pms.PMS - Working directory: /var/db/universal-media-server/.config/UMS
18:18:12.525 [main] INFO net.pms.PMS - Temp directory: /tmp/universalmediaserver
18:18:12.525 [main] INFO net.pms.PMS - Logging config file: internal defaults
18:18:12.526 [main] INFO net.pms.PMS -
18:18:12.526 [main] INFO net.pms.PMS - Profile directory: /root/.config/UMS
18:18:12.527 [main] INFO net.pms.PMS - Profile directory permissions: rw
18:18:12.527 [main] INFO net.pms.PMS - Profile path: /root/.config/UMS/UMS.conf
18:18:12.527 [main] INFO net.pms.PMS - Profile permissions: rw
18:18:12.527 [main] INFO net.pms.PMS - Profile name: ums4
18:18:12.528 [main] INFO net.pms.PMS -
18:18:12.528 [main] INFO net.pms.PMS - Web conf path: /root/.config/UMS/WEB.conf
18:18:12.528 [main] INFO net.pms.PMS - Web conf permissions: file not found
18:18:12.528 [main] INFO net.pms.PMS -
18:18:12.540 [main] ERROR net.pms.PMS - A serious error occurred during PMS init
java.lang.NullPointerException: null
at net.pms.newgui.DbgPacker.<init>(DbgPacker.java:40) ~[ums.jar:4.0.0-a1]
at net.pms.PMS.displayBanner(PMS.java:357) [ums.jar:4.0.0-a1]
at net.pms.PMS.init(PMS.java:509) [ums.jar:4.0.0-a1]
at net.pms.PMS.createInstance(PMS.java:1038) [ums.jar:4.0.0-a1]
at net.pms.PMS.main(PMS.java:1138) [ums.jar:4.0.0-a1]

最佳答案

您可以尝试将项目加载到 IDE 中并设置“异常中断”断点(例如,在 Eclipse 中,它位于“运行 -> 添加 Java 异常断点...”)。

但我认为这种方法只适合比较小的项目。例如,昨天,当 Guava 的先决条件检查中断了长批处理的执行时,我厌倦了等待,我添加了一些日志记录并重新运行了没有调试器的进程。所以YMMV。

关于java - 如何在预编译的 jar 文件的执行因 nullpointerException 停止之前进行调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24546803/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com