Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Problema para iniciar o Wildfly após realizar a configuração necessária

Criando agora a dúvida na aula correta:

Mesmo após realizar todos os comandos do tópico 2 aula 4, ao iniciar o Wildfly é informado que o start do serviço do jboss falhou

Segue código:

Error: Failed to start service jboss.deployment.unit."agendamentoemail-0.0.1-SNAPSHOT.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."agendamentoemail-0.0.1-SNAPSHOT.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "agendamentoemail-0.0.1-SNAPSHOT.war"

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class br.com.alura.dao.AgendamentoEmailDao for component AgendamentoEmailDao has errors: WFLYJPA0033: Can't find a persistence unit named null in deployment "agendamentoemail-0.0.1-SNAPSHOT.war"

4 respostas

As suas classes e pom ficaram assim:

//classe AgendamentoEmailResource
package com.exampleJavaEJB.resources;


import java.util.List;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;


import com.exampleJavaEJB.business.AgendamentoEmailBusiness;

@Path("/agendamentoemail")
public class AgendamentoEmailResource {

    @Inject
    private AgendamentoEmailBusiness agendamentoEmailBusiness;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response listarAgendamentoEmail() {

        List<String> emails = agendamentoEmailBusiness.listaAgendamentoEmail();
        return Response.ok(emails).build();

    }
}

insira seu código aqui

//classe AgendamentoEmailBusiness
package com.exampleJavaEJB.business;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateless;

@Stateless
public class AgendamentoEmailBusiness {

    public List<String> listaAgendamentoEmail(){

        List<String> emails = new ArrayList();
        emails.add("email1@teste.com");
        emails.add("email2@teste.com");

        return emails;
    }


}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.exampleJavaEJB</groupId>
    <artifactId>agendamentoemail</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Java EE 8 Archetype</name>
    <url>http://rhuanrocha.net/</url>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <jakartaee>8.0</jakartaee>
        <junit>3.8.1</junit>
        <log4j-core>2.11.1</log4j-core>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${jakartaee}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j-core}</version>
        </dependency>
    </dependencies>
</project>

O meu está diferente, porquê terminei de realizar a aula 4 onde ele altera a List para realizar a consulta no banco de dados:

#AgendamentoEmailBusiness
package br.com.alura.business;

import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;

import br.com.alura.dao.AgendamentoEmailDao;
import br.com.alura.entity.AgendamentoEmail;

@Stateless
public class AgendamentoEmailBusiness {

    @Inject
    private AgendamentoEmailDao agendamentoEmailDao;

    public List<AgendamentoEmail> listarAgendamentosEmail(){

        return agendamentoEmailDao.listarAgendamentosEmail();
    }

}
#AgendamentoEmailResources
package br.com.alura.resources;

import java.util.List;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import br.com.alura.business.AgendamentoEmailBusiness;
import br.com.alura.entity.AgendamentoEmail;

@Path("/agendamentoemail")
public class AgendamentoEmailResource {

    @Inject
    private AgendamentoEmailBusiness agendamentoEmailBusiness;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response listarAgendamentosEmail() {

        List<AgendamentoEmail> emails = agendamentoEmailBusiness.listarAgendamentosEmail();
        return Response.ok(emails).build();
    }
}
#AgendamentoEmailDao
package br.com.alura.resources;

import java.util.List;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import br.com.alura.business.AgendamentoEmailBusiness;
import br.com.alura.entity.AgendamentoEmail;

@Path("/agendamentoemail")
public class AgendamentoEmailResource {

    @Inject
    private AgendamentoEmailBusiness agendamentoEmailBusiness;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response listarAgendamentosEmail() {

        List<AgendamentoEmail> emails = agendamentoEmailBusiness.listarAgendamentosEmail();
        return Response.ok(emails).build();
    }
}
solução!

Descobri o problema, faltava o arquivo persistente.xml que foi apagado de acordo com o tópico 1 aula 04.

Muito bom o material, fala para excluir, mas utiliza posteriormente sem nem uma aula explicando sobre =)

Legal.. Seu ponto era mais adiante mesmo, obrigada por compartilhar!

Pois é, esse curso deixou a desejar, didática fraca, explicação bem limitada.