0

从 simple 模块调用 modpersona 模块以访问数据库表时发生错误。

感谢是否有人可以阐明为什么会引发此错误。

这是一个 MAVEN 项目。

操作系统 FEDORA 32 ; 网豆 12.1 ; 爪哇15;JAVAFX 15 ; 网豆 12.1 ; 我的 SQL 8.0.21

在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) 的 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 的应用程序启动方法 java.lang.reflect.InvocationTargetException 中的异常) 在 java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.base/java.lang.reflect.Method.invoke(Method.java:564) 在 javafx.graphics/com。 sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) 在 javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) 在 java.base/jdk.internal.reflect。 NativeMethodAccessorImpl.invoke0(Native Method) 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) 在 java.base/jdk.internal.reflect。DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.base/java.lang.reflect.Method.invoke(Method.java:564) 在 java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java: 1071)原因:java.lang.RuntimeException:javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)的 javafx.graphics/com.sun.javafx 的应用程序启动方法中的异常。 application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) 在 java.base/java.lang.Thread.run(Thread.java:832)graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) 在 javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) 在 java.base /java.lang.Thread.run(Thread.java:832)graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) 在 javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) 在 java.base /java.lang.Thread.run(Thread.java:832)

原因:java.lang.IllegalAccessError:com.mycompany.modpersona.PersonaDAO 类(在模块 com.mycompany.modpersona 中)无法访问类 javax.persistence.Persistence(在未命名模块 @0x21e018cc 中),因为模块 com.mycompany.modpersona 没有在 com.mycompany.modpersona/com.mycompany.modpersona.PersonaDAO.(PersonaDAO.java:17) 在 com.mycompany.simple/com.mycompany.simple.App.start(App.java:21) 读取未命名模块 @0x21e018cc在 javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) 在 javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java: 455)在 javafx 的 java.base/java.security.AccessController.doPrivileged(AccessController.java:391) 的 javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)。图形/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 个异常运行应用程序 com.mycompany.simple.App 包 com.mycompany.simple;simple.App 包 com.mycompany.simple;simple.App 包 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);

公共类 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>
4

0 回答 0