当前位置: 首页 > 知识库问答 >
问题:

SLF4J例外

胥承
2023-03-14

我对Java应用程序相当陌生。我正在尝试在eclipse中运行这个开源应用程序。我已经逐一包含了所需的所有外部库,并删除了所有错误。现在,当我运行应用程序时,我在运行时遇到异常。控制台中的消息如下所示:

Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
    at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:189)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:112)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:105)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:235)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:208)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
    at com.shootoff.Main.<clinit>(Main.java:59)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$2(LauncherImpl.java:352)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.joran.spi.JoranException
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 18 more
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    ... 5 more

现在,我可以看出,slf4j日志库是一个例外。我曾尝试在“配置构建路径”的外部jar部分中包含不同版本的slf4j,但我得到了相同的例外。所以我认为slf4j的版本控制不是这里的问题。此外,在异常中,我可以看到异常发生在以下行中:

专用静态最终记录器记录器=记录器工厂。getLogger(主类);

除此之外,我不知道下一步该怎么办。

我已经粘贴了下面的相关代码。希望它有助于解决问题。谢谢。

package com.shootoff;
import com.shootoff.camera.CameraFactory;
import com.shootoff.camera.cameratypes.OptiTrackCamera;
import com.shootoff.camera.cameratypes.PS3EyeCamera;
import com.shootoff.config.Configuration;
import com.shootoff.config.ConfigurationException;
import com.shootoff.gui.controller.ShootOFFController;
import com.shootoff.headless.HeadlessController;
import com.shootoff.plugins.TextToSpeech;
import com.shootoff.util.HardwareData;
import com.shootoff.util.SystemInfo;
import com.sun.javafx.application.LauncherImpl;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.util.Enumeration;
import java.util.Optional;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Stage;
import nu.pattern.OpenCV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main extends Application {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);
    private static final int MINIMUM_CPU_SCORE_EXCELLENT = 4000;
    private static final int MINIMUM_CPU_SCORE_PASSABLE = 3000;
    private static final long MINIMUM_RAM_EXCELLENT = 11712L;
    private static final long MINIMUM_RAM_PASSABLE = 4096L;
    private static final String POOR_HARDWARE_MESSAGE = "Hardware Status: Poor -- Based on the data we gathered,\nMATS will likely not run well on this machine.";
    private static final String PASSABLE_HARDWARE_MESSAGE = "Hardware Status: Passable -- Based on the data we gathered,\nMATS will likely run OK on this machine but may miss\noccasional shots.";
    private static final String EXCELLENT_HARDWARE_MESSAGE = "Hardware Status: Excellent -- Based on the data we gathered,\nthis machine should have no problems running MATS.";
    public static final String SHOOTOFF_DOMAIN = "http://shootoffapp.com/";
    private boolean isJWS = false;
    private static final String RESOURCES_METADATA_NAME = "shootoff-writable-resources.xml";
    private static final String RESOURCES_JAR_NAME = "shootoff-writable-resources.jar";
    private File resourcesMetadataFile;
    private File resourcesJARFile;
    private Stage primaryStage;
    private static final String VERSION_METADATA_NAME = "shootoff-version.xml";
    private static Optional<String> version = Optional.empty();
    private static boolean shouldShowV4lWarning = false;
    public static final String SPLASH_IMAGE = "http://fxexperience.com/wp-content/uploads/2010/06/logo.png";
    private static final int SPLASH_WIDTH = 676;
    private static final int SPLASH_HEIGHT = 227;

共有1个答案

戎俊
2023-03-14

SLF4J似乎不是这里的问题。您缺少的是一个回退jar。阅读此处的文档http://logback.qos.ch/看看您需要哪个库。

 类似资料:
  • 我开始将与一起使用,但问题如下。pom文件中我错了什么或缺少什么? 我的pom.xml: 我非常简单的代码:

  • 我在我的项目中使用log4j2和slf4j 信息: pom文件 更新:我在pom文件中添加了以下依赖项,我在mavenrepository中看到了jar——尽管在运行mvn clean/install时仍然看到相同的消息

  • SLF4J是为各种loging APIs提供一个简单统一的接口,从而使得最终用户能够在部署的时候配置自己希望的loging APIs实现。 Logging API实现既可以选择直接实现SLF4J接的loging APIs如: NLOG4J、SimpleLogger。也可以通过SLF4J提供的API实现来开发相应的适配器如Log4jLoggerAdapter、JDK14LoggerAdapter。

  • 正如我在标题中提到的,我的本地计算机上使用Gradle的项目开始抛出以下错误: 我不知道怎么解决它。 到目前为止我所尝试的; > 删除并安装intellij 以新的回购协议进行尝试 删除gradle缓存 添加了log4j和slf4j库,我在SO上找到了一个解决方案。 如何修复异常:无法实例化SLF4J LoggerFactory? 未能实例化SLF4J LoggerFactory IntelliJ

  • SLF4J Taglib 是一个使用 SLF4J 进行日志输出的JSP标签库,用法如下: <%@ taglib prefix="log" uri="http://www.slf4j.org/taglib/tld" %> <log:debug category="foo.bar">this is a debug message</log:debug>

  • SLF4J Android 是一个在 Android 平台上使用的日志框架,跟 SLF4J 普通用法一样: private static final Logger logger = LoggerFactory.getLogger(MyClass.class); logger.debug("Some log message. Details: {}", someObject.toString());