Reputation: 1723
I'm having some trouble configuring a timer in java. To be precise - I'm receiving the following error when trying to deploy my peripherial.war
.
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"peripherial.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"peripherial.war\".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type TimerService with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject public io.github.tastypenguinbacon.peripherial.heartbeat.service.PassiveHeartbeatService(Cache, TimerService)
at io.github.tastypenguinbacon.peripherial.heartbeat.service.PassiveHeartbeatService.<init>(PassiveHeartbeatService.java:0)
"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"peripherial.war\".WeldStartService"]}
The standalone.xml
file seems to be fine. The part (at least I'm expecting it to be) responsible for configuring the timer service seems also fine:
<timer-service thread-pool-name="default" default-data-store="default-file-store">
<data-stores>
<file-data-store name="default-file-store" path="timer-service-data" relative-to="jboss.server.data.dir"/>
</data-stores>
</timer-service>
I'm instantiating the TimerService through the @Inject
, using constructor based injection if it's somehow relevant.
I'm using wildfly-11.0.0.Alpha
. The only thing changed in the default standalone.xml
file is the IP addresses which are able to access the server.
Upvotes: 1
Views: 1041
Reputation: 40298
The TimerService
is a JEE application server resource. It is not automatically available to CDI to be @Inject
-ed. The way to obtain it (ref e.g. the JEE tutorial) is:
@Resource
TimerService timerService;
This might suit your purposes; if you really want it exposed as a CDI bean, it is fortunately trivial. Just make the @Resource
field a producer too - you can have a separate class for that:
@ApplicationScoped
public class TimerServiceProducer {
@Resource
@Produces
TimerService timerService;
}
I'm not sure if @ApplicationScoped
is absolutely necessary, but it won't hurt either.
Upvotes: 2