Gal Lisha
Gal Lisha

Reputation: 51

Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base' -- how to solve?

I try to add some class of java RMI that works fine in separate project. When i added the classes to my java fx project , i have got this error:

Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'

this is my pom.xml:enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>FXtest</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>FXtest</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.8.1</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.1</version>

        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-web</artifactId>
            <version>17.0.1</version>
        </dependency>

  <dependency>
            <groupId>org.controlsfx</groupId>
            <artifactId>controlsfx</artifactId>
            <version>11.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.dlsc.formsfx</groupId>
            <artifactId>formsfx-core</artifactId>
            <version>11.3.2</version>
            <exclusions>
                <exclusion>
                    <groupId>org.openjfx</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.synedra</groupId>
            <artifactId>validatorfx</artifactId>
            <version>0.1.13</version>
            <exclusions>
                <exclusion>
                    <groupId>org.openjfx</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-javafx</artifactId>
            <version>12.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.bootstrapfx</groupId>
            <artifactId>bootstrapfx-core</artifactId>
            <version>0.4.0</version>
        </dependency>
        <dependency>
            <groupId>eu.hansolo</groupId>
            <artifactId>tilesfx</artifactId>
            <version>11.48</version>
            <exclusions>
                <exclusion>
                    <groupId>org.openjfx</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>com.example.fxtest/com.example.fxtest.HelloApplication</mainClass>
                            <launcher>app</launcher>
                            <jlinkZipName>app</jlinkZipName>
                            <jlinkImageName>app</jlinkImageName>
                            <noManPages>true</noManPages>
                            <stripDebug>true</stripDebug>
                            <noHeaderFiles>true</noHeaderFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

this is the console error i get when i run my rmi-server:

Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make public abstract void com.example.fxtest.shared.CardgameServer.toUpperCase(java.lang.String,com.example.fxtest.shared.CardgameClient) throws java.rmi.RemoteException accessible: module com.example.fxtest does not "exports com.example.fxtest.shared" to module java.rmi
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at java.rmi/sun.rmi.server.UnicastServerRef$HashToMethod_Maps$1.run(UnicastServerRef.java:598)
    at java.rmi/sun.rmi.server.UnicastServerRef$HashToMethod_Maps$1.run(UnicastServerRef.java:596)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at java.rmi/sun.rmi.server.UnicastServerRef$HashToMethod_Maps.computeValue(UnicastServerRef.java:595)
    at java.rmi/sun.rmi.server.UnicastServerRef$HashToMethod_Maps.computeValue(UnicastServerRef.java:574)
    at java.rmi/sun.rmi.server.WeakClassHashMap.get(WeakClassHashMap.java:74)
    at java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:236)
    at java.rmi/java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:475)
    at java.rmi/java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:360)
    at com.example.fxtest/com.example.fxtest.server.ServerImpl.<init>(ServerImpl.java:13)
    at com.example.fxtest/com.example.fxtest.server.RunServer.main(RunServer.java:15)

i addad a photo of my module-info.java where the error is found.

any adivce will be appreciated! thanks

Upvotes: 0

Views: 118

Answers (2)

jewelsea
jewelsea

Reputation: 159536

To address the issue reported in the exception trace in the question body:

java.rmi.RemoteException accessible: module com.example.fxtest does not "exports com.example.fxtest.shared" to module java.rmi

you need to do what the message says.

Add to the module-info.java:

exports com.example.fxtest.shared to java.rmi;

Related question:


For the question in the title:

Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'

There is not enough information in the question to do more than speculate on the reason for that. It is likely related to an error in your local development environment or in some aspect of your project setup. It could be that:

  • you are using a Java runtime that includes a different version of JavaFX

    OR

  • have dependencies transitively on different versions of JavaFX

    OR

  • you have some manual command-line switches to modules configured incorrectly

    OR

  • you added a JavaFX SDK version that clashes with your dependencies

    OR

  • you may have manually added incompatible versions of the JavaFX library manually in the IDE

    OR

  • some 3rd party libraries you use are bundling JavaFX framework code inside them (which they should not do).

Which it is, I don’t know, but I offer the information in case it is needed.

Upvotes: 1

swoocn
swoocn

Reputation: 1

Curious what sort of troubleshooting you attempted. Have you tried removing the javafx-controls dependency? I think javafx-web contains javafx.controls as a transitive dependency so it may not be needed according to https://openjfx.io/javadoc/18/javafx.web/module-summary.html. Otherwise, https://openjfx.io/openjfx-docs/#maven may be a noteworthy guide.

Upvotes: 0

Related Questions