The error occurs when making the call from the simple module to the modpersona module to access a database table.

Appreciate if anyone can shed light on why this error is thrown.

It is a MAVEN project.

OS FEDORA 32 ; NETBEANS 12.1 ; JAVA 15 ; JAVAFX 15 ; NETBEANS 12.1 ; MY SQL 8.0.21

Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) at java.base/java.lang.Thread.run(Thread.java:832)

Caused by: java.lang.IllegalAccessError: class com.mycompany.modpersona.PersonaDAO (in module com.mycompany.modpersona) cannot access class javax.persistence.Persistence (in unnamed module @0x21e018cc) because module com.mycompany.modpersona does not read unnamed module @0x21e018cc at com.mycompany.modpersona/com.mycompany.modpersona.PersonaDAO.(PersonaDAO.java:17) at com.mycompany.simple/com.mycompany.simple.App.start(App.java:21) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277) ... 1 more Exception running application com.mycompany.simple.App package com.mycompany.simple;

public void start(Stage stage) {
    System.out.println("hola new york");
    
    final PersonaDAO daoPersona = new PersonaDAO();
    Persona entPersona = daoPersona.getPersonaByCodigo("V00000000000");
    String strNombre = entPersona.getNombrePersona();
    System.out.println(strNombre);

public class PersonaDAO {

private final PersonaJPA personaController;
private final EntityManagerFactory emf;

public PersonaDAO() {
    emf = Persistence.createEntityManagerFactory("com.mycompany_modpersona_jar_1.0-SNAPSHOTPU");
    personaController = new PersonaJPA(emf);
}


<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>modpersona</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.core</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.asm</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.antlr</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
        <version>2.7.7</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>15</maven.compiler.source>
    <maven.compiler.target>15</maven.compiler.target>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>simple</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>15</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>modpersona</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.4</version>
            <configuration>
                <mainClass>com.mycompany.simple.App</mainClass>
            </configuration>
            <executions>
                <execution>
                    <!-- Default configuration for running -->
                    <!-- Usage: mvn clean javafx:run -->
                    <id>default-cli</id>
                </execution>
                <execution>
                    <!-- Configuration for manual attach debugging -->
                    <!-- Usage: mvn clean javafx:run@debug -->
                    <id>debug</id>
                    <configuration>
                        <options>
                            <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
                        </options>
                    </configuration>
                </execution>
                <execution>
                    <!-- Configuration for automatic IDE debugging -->
                    <id>ide-debug</id>
                    <configuration>
                        <options>
                            <option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
                        </options>
                    </configuration>
                </execution>
                <execution>
                    <!-- Configuration for automatic IDE profiling -->
                    <id>ide-profile</id>
                    <configuration>
                        <options>
            <option>${profiler.jvmargs.arg1}</option>
            <option>${profiler.jvmargs.arg2}</option>
            <option>${profiler.jvmargs.arg3}</option>
            <option>${profiler.jvmargs.arg4}</option>
            <option>${profiler.jvmargs.arg5}</option>
                        </options>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
0

There are 0 answers