有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java@Schedule导致重复ServiceException

我试图在我的JAX-WS项目中实现一个简单的方法,目前,它每秒都会打印到控制台。我找到了this简单的指南,并尝试将其应用到我当前的工作项目中

我的TimerService.java看起来像这样:

package brass.ducks.controller;

import javax.ejb.EJB;
import javax.ejb.Schedule;
import javax.ejb.Singleton;

@Singleton
public class TimerService {
    @EJB
    HelloService helloService;

    @Schedule(second="*/1", minute="*",hour="*", persistent=false)
    public void doWork(){
        System.out.println("timer: " + helloService.sayHello());
    }
}

我的HelloService.java看起来像这样:

package brass.ducks.controller;

import javax.ejb.Stateless;

@Stateless
public class HelloService {
    public String sayHello(){
        return "Hello from control: " + System.currentTimeMillis();
    }
}

我注意到教程提到了一些关于如何部署的内容?在我本地的WildFly服务器上部署项目就可以解决这个问题,还是需要其他东西

这也是我的stacktrace:

14:53:03,672 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final
14:53:04,119 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
14:53:04,239 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) starting
14:53:06,683 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0015: Re-attempting failed deployment BrassDucks.war
14:53:06,708 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found BrassDucks.war in deployment directory. To trigger deployment create a file called BrassDucks.war.dodeploy
14:53:06,829 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
14:53:06,860 INFO  [org.xnio] (MSC service thread 1-6) XNIO version 3.3.4.Final
14:53:06,873 INFO  [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.3.4.Final
14:53:06,981 INFO  [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.18.Final
14:53:07,003 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 41) WFLYCLINF0001: Activating Infinispan subsystem.
14:53:07,044 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 48) WFLYJSF0007: Activated the following JSF Implementations: [main]
14:53:07,063 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 60) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
14:53:07,072 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 40) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
14:53:07,303 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 52) WFLYNAM0001: Activating Naming Subsystem
14:53:07,359 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 61) WFLYUT0003: Undertow 1.3.15.Final starting
14:53:07,373 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0003: Undertow 1.3.15.Final starting
14:53:07,378 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 59) WFLYSEC0002: Activating Security Subsystem
14:53:07,446 INFO  [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.2.Final)
14:53:07,470 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 62) WFLYWS0002: Activating WebServices Extension
14:53:07,475 INFO  [org.jboss.as.security] (MSC service thread 1-2) WFLYSEC0001: Current PicketBox version=4.9.4.Final
14:53:07,510 INFO  [org.jboss.as.naming] (MSC service thread 1-4) WFLYNAM0003: Starting Naming Service
14:53:07,530 INFO  [org.wildfly.iiop.openjdk] (ServerService Thread Pool -- 42) WFLYIIOP0001: Activating IIOP Subsystem
14:53:07,552 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 36) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:53:07,559 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-7) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
14:53:07,782 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = h2
14:53:08,133 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 61) WFLYUT0014: Creating file handler for path 'C:\wildfly-10.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
14:53:08,154 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0012: Started server default-server.
14:53:08,183 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
14:53:08,221 INFO  [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
14:53:08,238 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
14:53:08,882 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
14:53:09,092 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0001: AIO wasn't located on this platform, it will fall back to using pure Java NIO.
14:53:09,237 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "mysql-connector-java-5.1.39-bin.jar" (runtime-name: "mysql-connector-java-5.1.39-bin.jar")
14:53:09,253 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "BrassDucks.war" (runtime-name: "BrassDucks.war")
14:53:09,280 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Started FileSystemDeploymentService for directory C:\wildfly-10.0.0.Final\standalone\deployments
14:53:09,374 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=C:\wildfly-10.0.0.Final\standalone\data\activemq\journal,bindingsDirectory=C:\wildfly-10.0.0.Final\standalone\data\activemq\bindings,largeMessagesDirectory=C:\wildfly-10.0.0.Final\standalone\data\activemq\largemessages,pagingDirectory=C:\wildfly-10.0.0.Final\standalone\data\activemq\paging)
14:53:09,587 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221013: Using NIO Journal
14:53:09,823 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
14:53:10,757 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4) 
14:53:10,824 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
14:53:10,835 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
14:53:10,857 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
14:53:10,865 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
14:53:10,868 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
14:53:11,045 INFO  [org.wildfly.iiop.openjdk] (MSC service thread 1-4) WFLYIIOP0009: CORBA ORB Service started
14:53:11,264 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
14:53:11,266 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
14:53:11,358 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.39-bin.jar_com.mysql.jdbc.Driver_5_1
14:53:11,544 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.39-bin.jar_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
14:53:11,559 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) WFLYJCA0001: Bound data source [java:/MySqlNorthwindDS]
14:53:11,605 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) WFLYJCA0001: Bound data source [java:/BrassDucksDS]
14:53:11,634 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:/MySqlEquitiesDS]
14:53:12,241 INFO  [org.jboss.as.protocol] (management I/O-2) WFLYPRT0057:  cancelled task by interrupting thread Thread[management-handler-thread - 1,5,management-handler-thread]
14:53:12,479 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor acceptor
14:53:12,483 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor-throughput acceptor
14:53:12,483 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor-throughput acceptor
14:53:12,484 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-3) WFLYMSGAMQ0016: Registered HTTP upgrade for activemq-remoting protocol handled by http-acceptor acceptor
14:53:12,614 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221007: Server is now live
14:53:12,615 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.1.0.wildfly-011 [nodeID=ad393a41-759e-11e6-8402-b9b09451d246] 
14:53:12,660 INFO  [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 64) WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
14:53:12,696 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 67) AMQ221003: trying to deploy queue jms.queue.Tasks
14:53:12,726 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 68) AMQ221003: trying to deploy queue jms.queue.ExpiryQueue
14:53:12,731 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 66) AMQ221003: trying to deploy queue jms.queue.DLQ
14:53:12,737 INFO  [org.wildfly.extension.messaging-activemq] (ServerService Thread Pool -- 65) WFLYMSGAMQ0002: Bound messaging object to jndi name java:/ConnectionFactory
14:53:12,796 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-7) WFLYJCA0007: Registered connection factory java:/JmsXA
14:53:12,895 INFO  [org.apache.activemq.artemis.ra] (MSC service thread 1-7) Resource adaptor started
14:53:12,895 INFO  [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-7) IJ020002: Deployed: file://RaActivatoractivemq-ra
14:53:12,897 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-7) WFLYJCA0002: Bound JCA ConnectionFactory [java:/JmsXA]
14:53:12,898 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-7) WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory
14:53:15,665 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment BrassDucks.war
14:53:15,797 INFO  [org.jboss.as.protocol] (management I/O-2) WFLYPRT0057:  cancelled task by interrupting thread Thread[management-handler-thread - 1,5,management-handler-thread]
14:53:15,811 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-2) HV000001: Hibernate Validator 5.2.3.Final
14:53:15,930 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-2) WFLYEJB0473: JNDI bindings for session bean named 'BrassDucksDAO' in deployment unit 'deployment "BrassDucks.war"' are as follows:

    java:global/BrassDucks/BrassDucksDAO!brass.ducks.model.BrassDucksDAO
    java:app/BrassDucks/BrassDucksDAO!brass.ducks.model.BrassDucksDAO
    java:module/BrassDucksDAO!brass.ducks.model.BrassDucksDAO
    java:global/BrassDucks/BrassDucksDAO
    java:app/BrassDucks/BrassDucksDAO
    java:module/BrassDucksDAO

14:53:15,931 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-2) WFLYEJB0473: JNDI bindings for session bean named 'Trader' in deployment unit 'deployment "BrassDucks.war"' are as follows:

    java:global/BrassDucks/Trader!brass.ducks.model.Trader
    java:app/BrassDucks/Trader!brass.ducks.model.Trader
    java:module/Trader!brass.ducks.model.Trader
    java:global/BrassDucks/Trader
    java:app/BrassDucks/Trader
    java:module/Trader

14:53:15,932 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-2) WFLYEJB0473: JNDI bindings for session bean named 'HelloService' in deployment unit 'deployment "BrassDucks.war"' are as follows:

    java:global/BrassDucks/HelloService!brass.ducks.controller.HelloService
    java:app/BrassDucks/HelloService!brass.ducks.controller.HelloService
    java:module/HelloService!brass.ducks.controller.HelloService
    java:global/BrassDucks/HelloService
    java:app/BrassDucks/HelloService
    java:module/HelloService

14:53:15,932 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-2) WFLYEJB0473: JNDI bindings for session bean named 'TimerService' in deployment unit 'deployment "BrassDucks.war"' are as follows:

    java:global/BrassDucks/TimerService!brass.ducks.controller.TimerService
    java:app/BrassDucks/TimerService!brass.ducks.controller.TimerService
    java:module/TimerService!brass.ducks.controller.TimerService
    java:global/BrassDucks/TimerService
    java:app/BrassDucks/TimerService
    java:module/TimerService

14:53:16,333 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."BrassDucks.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."BrassDucks.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "BrassDucks.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    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: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0052: Failed to install component TimerService
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:109)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    ... 5 more
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.module.BrassDucks.BrassDucks.TimerService is already registered
    at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158)
    at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:235)
    at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:768)
    at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
    at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2401)
    at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:223)
    at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2401)
    at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:317)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deployComponent(ComponentInstallProcessor.java:198)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:101)
    ... 6 more

14:53:16,377 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "BrassDucks.war")]) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"BrassDucks.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"BrassDucks.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"BrassDucks.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0052: Failed to install component TimerService
    Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.module.BrassDucks.BrassDucks.TimerService is already registered"},
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.unit.\"BrassDucks.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"BrassDucks.war\".beanmanager]",
        "jboss.deployment.unit.\"BrassDucks.war\".batch.environment is missing [jboss.deployment.unit.\"BrassDucks.war\".beanmanager]"
    ]
}
14:53:16,427 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "mysql-connector-java-5.1.39-bin.jar" (runtime-name : "mysql-connector-java-5.1.39-bin.jar")
14:53:16,477 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "BrassDucks.war" (runtime-name : "BrassDucks.war")
14:53:16,493 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.deployment.unit."BrassDucks.war".beanmanager (missing) dependents: [service jboss.deployment.unit."BrassDucks.war".batch.environment, service jboss.deployment.unit."BrassDucks.war".weld.weldClassIntrospector] 
WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."BrassDucks.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."BrassDucks.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "BrassDucks.war"

14:53:16,782 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:53:16,782 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:53:16,783 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) started (with errors) in 13851ms - Started 395 of 689 services (3 services failed or missing dependencies, 401 services are lazy, passive or on-demand)
14:53:16,887 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment BrassDucks.war (runtime-name: BrassDucks.war) in 60ms
14:53:17,087 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0009: Undeployed "BrassDucks.war" (runtime-name: "BrassDucks.war")
14:53:17,088 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."BrassDucks.war".INSTALL

14:53:21,595 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found BrassDucks.war in deployment directory. To trigger deployment create a file called BrassDucks.war.dodeploy

共 (1) 个答案

  1. # 1 楼答案

    尝试使用以下步骤:

    以下是我为解决这个问题而采取的步骤

    一,。停止服务器

    二,。转到部署路径

    三,。手动删除部署文件夹中的现有项目

    四,。重新启动服务器

    五,。再次部署应用程序

    因为从错误来看,服务器上似乎已经部署了“.BrassDucks.BrassDucks.TimerService”