简体   繁体   English

Bean初始化失败; 嵌套的异常是java.lang.NoClassDefFoundError:org / eclipse / jetty / server / AbstractConnector

[英]Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector

I have got Spring project. 我有Spring项目。 I need to use JMX . 我需要使用JMX I am using simplejmx - I found it really useful but unfortunately, I cannot manage few, basic things. 我正在使用simplejmx我发现它确实有用,但不幸的是,我无法管理一些基本的东西。

I wrote a really simple server: 我写了一个非常简单的服务器:

package com.pckg.jmx;

import com.j256.simplejmx.web.JmxWebServer;

public class JMXServer {

    public static void main(String[] args) throws Exception {

        JmxWebServer jmxWebServer = new JmxWebServer(8123);
        jmxWebServer.start();
    }

}

with pom.xml : pom.xml

<project...> 

    <properties>
        <jetty-version>8.1.9.v20130131</jetty-version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.j256.simplejmx</groupId>
            <artifactId>simplejmx</artifactId>
            <version>1.8</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
            <version>${jetty-version}</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>${jetty-version}</version>
            <optional>true</optional>
        </dependency>

    </dependencies>

</project>

When I run it, it works well. 当我运行它时,它运行良好。 I want to do it in Spring way. 我想用春天的方式做。 I created jmx-config file: 我创建了jmx-config文件:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <!-- publishes classes that have @JmxResource or implement JmxSelfNaming 
        to jmxServer automagically -->
    <bean id="beanPublisher" class="com.j256.simplejmx.spring.BeanPublisher">
        <property name="jmxServer" ref="jmxServer" />
    </bean>

    <!-- our JmxServer which publishes our beans via JMX -->
    <bean id="jmxServer" class="com.j256.simplejmx.web.JmxWebServer"
        init-method="start" destroy-method="stop">
        <!-- the port should probably come from a configured property -->
        <property name="registryPort" value="8123" />
    </bean>

</beans>

I changed web.xml : 我改变了web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    ...
    jmx-config.xml
    </param-value>
</context-param>

I added simple class: 我添加了简单的类:

package com.pckg.jmx;

import com.j256.simplejmx.common.JmxResource;

@JmxResource
public class DummyJMX {

    private int var = 3;
}

When I run my application I see warnings: 当我运行我的应用程序时,我看到警告:

10:15:07,184 WARN  [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.eclipse.jetty.continuation.Servlet3Continuation$1 due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.eclipse.jetty.continuation.Servlet3Continuation$1
    at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:606)
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]

10:15:07,191 WARN  [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.eclipse.jetty.continuation.Servlet3Continuation$2 due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.eclipse.jetty.continuation.Servlet3Continuation$2
    at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:606)
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]

and an exception (it is too long, I pasted only first part): 和一个例外(太长了,我只粘贴了第一部分):

10:16:54,674 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-13) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanPublisher' defined in class path resource [jmx-config.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) [spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector

I was looking for a solution but I cannot fix it problem. 我一直在寻找解决方案,但无法解决问题。 My idea is that the problem is with pom.xml but I am not sure, moreover, I have no idea how to check it and what I should change. 我的想法是问题出在pom.xml但是我不确定,此外,我也不知道如何检查它以及应该更改什么。

Thanks in advance 提前致谢

You have the jetty-server dependency as optional and if you are packaging the code as war, it may be possible (depending on what other plugins and configuration settings you have in your pom) that jar not to be included in it. 您可以将jetty-server依赖项作为可选项,如果将代码打包为war,则有可能不包含jar(具体取决于pom中的其他插件和配置设置)。 Check the resulting war file and test the packaging without <optional>true</optional> in your pom for 'jetty-server' dependency. 检查生成的war文件,并测试pom中是否包含“ jetty-server”依赖项的包装,而不包含<optional>true</optional>

@Andrei Stefan answer solved this problem but anyhow, there is also another problem. @Andrei Stefan的答案解决了这个问题,但是无论如何,还有另一个问题。

<bean id="jmxServer" class="com.j256.simplejmx.web.JmxWebServer"
    init-method="start" destroy-method="stop">
    <!-- the port should probably come from a configured property -->
    <property name="registryPort" value="8123" />
</bean>

There is no field registryPort in com.j256.simplejmx.web.JmxWebServer : Class JmxWebServer . 有没有现场registryPortcom.j256.simplejmx.web.JmxWebServer类JmxWebServer It should be like this: 应该是这样的:

<bean id="jmxServer" class="com.j256.simplejmx.web.JmxWebServer"
    init-method="start" destroy-method="stop">
    <!-- the port should probably come from a configured property -->
    <property name="serverPort" value="8123" />
</bean>

I hope this will help somone in the future 我希望这会在将来有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决嵌套异常是 java.lang.NoClassDefFoundError: org/eclipse/jetty/server/session/SessionDataStore? - How to resolve nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/session/SessionDataStore? java.lang.NoClassDefFoundError:org / eclipse / jetty / server / NetworkConnector - java.lang.NoClassDefFoundError: org/eclipse/jetty/server/NetworkConnector SparkJava Exception java.lang.NoClassDefFoundError:org / eclipse / jetty / websocket / server / pathmap / PathSpec - SparkJava Exception java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/server/pathmap/PathSpec 线程“ Thread-2” java.lang.NoClassDefFoundError中的异常:org / eclipse / jetty / server / Handler - Exception in thread “Thread-2” java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler Bean初始化失败; 嵌套的异常是java.lang.NoClassDefFoundError:Ljavax / enterprise / concurrent / ManagedThreadFactory - Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Ljavax/enterprise/concurrent/ManagedThreadFactory Java.lang.NoClassDefFoundError:org/eclipse/jetty/util/component/ContainerLifeCycle - Java.lang.NoClassDefFoundError: org/eclipse/jetty/util/component/ContainerLifeCycle 实例化bean失败; 嵌套的异常是java.lang.NoClassDefFoundError:org / springframework / core / io / Resource-使用spring-core.4_2_5 - Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/io/Resource - using spring-core.4_2_5 将 PDF 文档索引到 Solr - 错误 500 java.lang.NoClassDefFoundError: org/eclipse/jetty/server/MultiPart - Index PDF Documents to Solr - Error 500 java.lang.NoClassDefFoundError: org/eclipse/jetty/server/MultiParts 创建名称为&#39;transactionManager&#39;的bean时出错:嵌套异常为java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / - Error creating bean with name 'transactionManager' :nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/ 处理程序处理失败; 嵌套的异常是java.lang.NoClassDefFoundError:org / aspectj / lang / NoAspectBoundException - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/NoAspectBoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM