Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro ao iniciar servidor

Estou com erro quando dou start no servidor

19:08:41,202 ERROR [org.jboss.as.ejb3.timer] (EJB default - 1) WFLYEJB0020: Error invoking timeout for timer: [id=6f421765-fe8a-44b7-be1c-e5acd6599b09 timedObjectId=agendamento-email-0.0.1-SNAPSHOT.agendamento-email-0.0.1-SNAPSHOT.AgendamentoEmailJob auto-timer?:true persistent?:true timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@87b4b4e previousRun=Thu Feb 17 19:08:40 BRST 2022 initialExpiration=null intervalDuration(in milli sec)=0 nextExpiration=Thu Feb 17 19:08:50 BRST 2022 timerState=IN_TIMEOUT info=null] ScheduleExpression [second=*/10;minute=*;hour=*;dayOfMonth=*;month=*;dayOfWeek=*;year=*;timezoneID=null;start=null;end=null]: javax.ejb.EJBException: java.lang.RuntimeException: javax.naming.NameNotFoundException: DefaultJMSConnectionFactory -- service jboss.naming.context.java.DefaultJMSConnectionFactory
    at org.jboss.as.ejb3@20.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:266)
    at org.jboss.as.ejb3@20.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:388)
    at org.jboss.as.ejb3@20.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:158)
    at org.jboss.invocation@1.5.2.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.invocation@1.5.2.Final//org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81)
    at org.jboss.as.weld.common@20.0.1.Final//org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
    at org.jboss.invocation@1.5.2.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ejb3@20.0.1.Final//org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

Meu código:

package br.com.alura.job;

import java.util.List;

import javax.annotation.Resource;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.inject.Inject;
import javax.jms.JMSConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.Queue;

import br.com.alura.entidade.AgendamentoEmail;
import br.com.alura.servico.AgendamentoEmailServico;

@Singleton
public class AgendamentoEmailJob {

    @Inject
    private AgendamentoEmailServico agendamentoEmailServico;

    @Inject
    @JMSConnectionFactory("java:/DefaultJMSConnectionFactory")
    private JMSContext context;

    @Resource(mappedName = "java:/jms/queue/EmailQueue")
    private Queue queue;

    @Schedule(hour = "*", minute = "*", second = "*/10")
    public void enviarEmail() {
        List<AgendamentoEmail> listarPorNaoAgendado = agendamentoEmailServico.listarPorNaoAgendado();
        listarPorNaoAgendado.forEach(emailNaoAgendado -> {
            context.createProducer().send(queue, emailNaoAgendado);
            agendamentoEmailServico.alterar(emailNaoAgendado);
        });
    }
}
1 resposta
solução!

Opa, esqueci de colocar o "jboss" na linha do @JMSConnectionFactory hehe. Ficando dessa forma:

@JMSConnectionFactory("java:jboss/DefaultJMSConnectionFactory")