about my problem, I have seen other questions but none has been able to solve my problem. Before going on I want to clarify that I am new to the subject and I am watching a tutorial on JAVA EE.
The technologies I use are:
- JPA
- JTA
- Mysql as database
- Glassfish 5.0 (Coimencé provandolo with 4.1.2 but I ended up installing the 5 to see if the error was by the version but not)
- Netbeans
- Maven
My problem is this:
I can not access a resource located in my glassfish JDBC Resources. In my programming I have the following code:
persistence.xml:
<persistence
version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
>
<persistence-unit name="PersonaPU" transaction-type="JTA">
<jta-data-source>jdbc/PersonaDb</jta-data-source>
</persistence-unit>
</persistence>
My pom.xml is this:
<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>mx.com.gm.sga</groupId>
<artifactId>sga-jee</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<glassfish.embedded-static-shell.jar>
C:\AppServers\glassfish\glassfish5\glassfish\lib\embedded\glassfish-embedded-static-shell.jar
</glassfish.embedded-static-shell.jar>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-static-shell</artifactId>
<version>5.0</version>
<scope>system</scope>
<systemPath>${glassfish.embedded-static-shell.jar}</systemPath>
</dependency>
<dependency>
<groupId>org.glassfish.main.appclient</groupId>
<artifactId>gf-client</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
</project>
and this is my Testing Class, my UnitTest:
package test;
import static org.junit.Assert.*;
import java.util.List;
import javax.ejb.embeddable.EJBContainer;
import mx.com.gm.sga.domain.Persona;
import mx.com.gm.sga.servicio.PersonaService;
import org.junit.Before;
import org.junit.Test;
public class PersonaServiceTest {
private PersonaService personaService;
@Before
public void setUp() throws Exception {
EJBContainer contenedor = EJBContainer.createEJBContainer();
personaService = (PersonaService)
contenedor.getContext().lookup
("java:global/classes/PersonaServiceImpl!mx.com.gm.sga.servicio.PersonaService");
}
@Test
public void testEJBPersonaService() {
System.out.println("Iniciando test EJB PersonaService");
assertTrue(personaService != null);
assertEquals(2, personaService.listarPersonas().size());
System.out.println("El no. de personas es igual a:" + personaService.listarPersonas().size());
this.desplegarPersonas(personaService.listarPersonas());
System.out.println("Fin test EJB PersonaService");
}
private void desplegarPersonas(List<Persona> personas) {
for (Persona persona : personas) {
System.out.println(persona);
}
}
}
The only thing I want to do is to list a list of people stored in my database. In my glassfish I have already added my JDBC Resources and my JDBC Connection Pool. I put a IMAGE to see. (He even pings the database from the glassfish)
and At the moment of executing it with the glassfish client (from netbeans) I get this error:
I hope you can help me! I've been stuck here for 4 days and I'm still trying to find out what the error is. Thanks in advance!