java.lang.NoClassDefFoundError: org/jboss/logging/Logger

Posted

技术标签:

【中文标题】java.lang.NoClassDefFoundError: org/jboss/logging/Logger【英文标题】: 【发布时间】:2020-10-17 13:05:22 【问题描述】:

JBoss 服务器版本:7.3

Java 版本:1.8

IDE:日食

例外

Exception in thread "main" 
    at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:64)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at test.Client.main(Client.java:17)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 10 more

即使在出现异常后,以下提到的 jar 也会添加到构建路径中。 java.lang.ClassNotFoundException: org.jboss.logging.Logger .

jbossall-client.jar
jboss-common-client.jar
jboss-logging-3.3.2.Final.jar
jboss-remote-naming-1.0.7.final.jar

代码 主.java

public static void main(String[] args) 
        try 
            InputStream input;
            input = new FileInputStream("/lookup.properties");
            Properties prop = new Properties();
            prop.load(input);
            InitialContext initialContext = new InitialContext(getJBossClientProperties());
            Object obj = initialContext.lookup(prop.getProperty("lookup"));
            System.out.println("Got EJB : "+obj);
         catch (Exception e) 
            System.out.println("Error : "+e);
        
    

    private static Properties getJBossClientProperties() throws Exception 
        InputStream input = new FileInputStream("/config.properties");
        Properties prop = new Properties();
        prop.load(input);
        return prop;
    

lookup.properties

lookup=jndi_lookup

config.properties

java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true

【问题讨论】:

【参考方案1】:

我在 glassfish 上面试过了,效果很好,我知道它的 jboss... 我在这里找到了另一个相关的帖子

java.lang.ClassNotFoundException: org.jboss.logging.Logger

grep 为; 当我从 tje jboss 安装路径(../jboss-5.1.0.GA\client)而不是从 lib 文件夹中添加 jbossall-client.jar 时,它起作用了。

这可能是你的答案.....

【讨论】:

以上是关于java.lang.NoClassDefFoundError: org/jboss/logging/Logger的主要内容,如果未能解决你的问题,请参考以下文章