JBoss Wildfly 中 EJB 的错误依赖 [英] Wrong dependencies with EJB in JBoss Wildfly

查看:33
本文介绍了JBoss Wildfly 中 EJB 的错误依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个 TimerHelper 类,它可以从其他类接收 Callables 并尝试执行它们.如果发生异常,它会等待一段时间并再次尝试.所以其他类可以导出必须完成的任务,但目前不完全如此.

i wrote a TimerHelper class which can receive Callables from other classes and tries to execute them. If an exception occurs, it waits some time and tries again. So other classes can export tasks that have to be done, but not exactly at the moment.

@Startup
@Singleton
public class TimerHelper{
private static final Logger LOGGER = Logger.getLogger(TimerHelper.class.getName());

private Callable<Void> task;
private int failureCounter = 0;

public TimerHelper(){

}

@Resource
private ManagedExecutorService executorService;
@Resource
private TimerService timerService;

public void setNewTimer(Callable<Void> task){
this.task = task;

timerService.createIntervalTimer(0, 5000, new TimerConfig());
}

@Timeout
public void timerMethod(Timer timer) {
    if(failureCounter <10){

        try{
            Future<Void> future = executorService.submit(task);
            future.get();       
            LOGGER.log(Level.INFO, "Did something");
            failureCounter =0;
            timer.cancel();
            }catch(Exception e){
                failureCounter++;
                LOGGER.log(Level.WARNING, "Errored while doing something, will try again");
            }

    }else{
        timer.cancel();
        LOGGER.log(Level.SEVERE, "Tried to add something to Database several times, but failed. Please check the OpenRDF-Database");

    }


}

}

这个 TimerHelper 类位于一个 API 包中,许多其他包在它们的 POM.xml 中有依赖关系.除了一个模块用户管理"外,一切正常.当我尝试将它部署到 Wildfly 9 时,我总是遇到这个异常:

This TimerHelper-class is in a API package to which a lot of other packages have a dependency in their POM.xml. Everything works fine except for one module "Usermanagement". I get allways this Exception when i try to deploy it to Wildfly 9:

14:56:19,125 错误 [org.jboss.msc.service.fail](MSC 服务线程 1-7)MSC000001:无法启动服务 jboss.deployment.unit."usermanagement.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."usermanagement.war".PARSE: WFLYSRV0153: 无法处理部署usermanagement.war"的阶段 PARSE在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163)在 org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)在 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在 java.lang.Thread.run(Thread.java:745)引起:java.lang.IllegalArgumentException:WFLYEE0040:一个名为TimerHelper"的组件已在此模块中定义在 org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:162)在 org.jboss.as.ejb3.deployment.processors.EJBComponentDescriptionFactory.addComponent(EJBComponentDescriptionFactory.java:58)在 org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processSessionBeans(SessionBeanComponentDescriptionFactory.java:169)在 org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processAnnotations(SessionBeanComponentDescriptionFactory.java:98)在 org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:57)在 org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81)在 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156)... 5个

14:56:19,125 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."usermanagement.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."usermanagement.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "usermanagement.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: WFLYEE0040: A component named 'TimerHelper' is already defined in this module at org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:162) at org.jboss.as.ejb3.deployment.processors.EJBComponentDescriptionFactory.addComponent(EJBComponentDescriptionFactory.java:58) at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processSessionBeans(SessionBeanComponentDescriptionFactory.java:169) at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processAnnotations(SessionBeanComponentDescriptionFactory.java:98) at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:57) at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156) ... 5 more

14:56:19,126 错误 [org.jboss.as.controller.management-operation] (management-handler-thread - 38) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "usermanagement.war")]) - 失败描述:{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"usermanagement.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"usermanagement.war\".PARSE: WFLYSRV0153: 无法处理部署阶段 PARSE \"usermanagement.war\"引起:java.lang.IllegalArgumentException:WFLYEE0040:一个名为TimerHelper"的组件已在此模块中定义"}}14:56:19,126 错误 [org.jboss.as.server] (management-handler-thread - 38) WFLYSRV0021:部署usermanagement.war"的部署被回滚,失败消息如下:{"WFLYCTL0080: 失败的服务" => {"jboss.deployment.unit.\"usermanagement.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"usermanagement.war\".PARSE: WFLYSRV0153: 无法处理部署 \"usermanagement.war\" 的阶段 PARSE引起:java.lang.IllegalArgumentException:WFLYEE0040:一个名为TimerHelper"的组件已在此模块中定义"}}

14:56:19,126 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 38) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "usermanagement.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"usermanagement.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"usermanagement.war\".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment \"usermanagement.war\" Caused by: java.lang.IllegalArgumentException: WFLYEE0040: A component named 'TimerHelper' is already defined in this module"}} 14:56:19,126 ERROR [org.jboss.as.server] (management-handler-thread - 38) WFLYSRV0021: Deploy of deployment "usermanagement.war" was rolled back with the following failure message: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"usermanagement.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"usermanagement.war\".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment \"usermanagement.war\" Caused by: java.lang.IllegalArgumentException: WFLYEE0040: A component named 'TimerHelper' is already defined in this module"}}

我很确定这是因为@Singleton"注释,但我不知道如何解决这个问题.可能也是因为usermanagement依赖于api"和aaa",而aaa"也依赖于api"?!

I'm pretty sure it's because of the "@Singleton" annotation, but i can't figure out how to solve this problem. Maybe its also because usermanagement has a dependency to "api" and "aaa", and "aaa" also have a dependency to "api" ?!

推荐答案

你解决了吗?在我的情况下,似乎进行服务器清理有帮助(在 Eclipse 中,在服务器上右键并按下clean")然后选择完全发布.

Did you solve this? In my case it seems that doing a server cleanup helped (in eclipse, right button on the server and push "clean") then choose a Full Publish.

干杯内科斯

这篇关于JBoss Wildfly 中 EJB 的错误依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆