找不到类错误引用无效的包名称

时间:2017-02-07 03:18:13

标签: maven netbeans javafx build

我在NetBeans 8.2中创建了一个JavaFX Maven项目。当我创建初始启动项目时,它将运行没有错误。然后,我从数据库生成实体类,并计划将数据库表绑定到应用程序中的各种视图。我还没有使用任何生成的实体类,但是当我尝试运行应用程序时,它现在失败了。我可以通过Build Success 清理和构建项目。但是,当我尝试使用运行选项时,构建失败并且应用程序无法启动。

我认为我有两个问题,但无法弄清楚如何纠正它们。

  1. “引起:java.lang.ClassNotFoundException:com.mycompany.synergyixs.ingestor.FXMLController” - 没有com.mycompany.synergyixs.ingestor包,FXMLController在com.IXS.synergyixs.ingestor
  2. “引起:javafx.fxml.LoadException: file:/Users/eugenefallon/NetBeansProjects/SynergyIXS-Ingestor/target/SynergyIXS-Ingestor-1.0-SNAPSHOT.jar!/fxml/Scene.fxml:9“ - 我不明白为什么没找到。我试过/ fxml /Scene.fxml以及fxml / Scene.fxml
  3. 非常感谢任何帮助。我对NetBeans相当陌生,可能会遗漏一些明显的东西。

    以下是我尝试运行时的控制台输出:

    > cd /Users/eugenefallon/NetBeansProjects/SynergyIXS-Ingestor; JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home "/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/java/maven/bin/mvn" "-Drunfx.args=-jar '${project.build.directory}/${project.build.finalName}.jar'" org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
    Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
    Scanning for projects...
    
    ------------------------------------------------------------------------
    Building SynergyIXS-Ingestor 1.0-SNAPSHOT
    ------------------------------------------------------------------------
    
    --- exec-maven-plugin:1.2.1:exec (default-cli) @ SynergyIXS-Ingestor ---
    Exception in Application start method
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
    Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
        at com.sun.javafx.application.LauncherImpl$$Lambda$51/326549596.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: javafx.fxml.LoadException: 
    file:/Users/eugenefallon/NetBeansProjects/SynergyIXS-Ingestor/target/SynergyIXS-Ingestor-1.0-SNAPSHOT.jar!/fxml/Scene.fxml:9
    
        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
        at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:918)
        at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
        at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
        at com.IXS.synergyixs.ingestor.MainApp.start(MainApp.java:15)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
        at com.sun.javafx.application.LauncherImpl$$Lambda$54/1753339148.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl$$Lambda$47/1915503092.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
        at com.sun.javafx.application.PlatformImpl$$Lambda$49/305815329.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
        at com.sun.javafx.application.PlatformImpl$$Lambda$48/1567581361.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    Caused by: java.lang.ClassNotFoundException: com.mycompany.synergyixs.ingestor.FXMLController
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:916)
        ... 23 more
    Exception running application com.IXS.synergyixs.ingestor.MainApp
    ------------------------------------------------------------------------
    BUILD FAILURE
    ------------------------------------------------------------------------
    Total time: 1.340s
    Finished at: Mon Feb 06 22:02:30 EST 2017
    Final Memory: 6M/245M
    ------------------------------------------------------------------------
    Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project SynergyIXS-Ingestor: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
    
    To see the full stack trace of the errors, re-run Maven with the -e switch.
    Re-run Maven using the -X switch to enable full debug logging.
    
    For more information about the errors and possible solutions, please read the following articles:
    [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    

    这是我的pom.xml

    <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.IXS</groupId>
        <artifactId>SynergyIXS-Ingestor</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>SynergyIXS-Ingestor</name>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <mainClass>com.IXS.synergyixs.ingestor.MainApp</mainClass>
        </properties>
    
        <organization>
            <!-- Used as the 'Vendor' for JNLP generation -->
            <name>SynergyIXS</name>
        </organization>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.6</version>
                    <executions>
                        <execution>
                            <id>unpack-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>unpack-dependencies</goal>
                            </goals>
                            <configuration>
                                <excludeScope>system</excludeScope>
                                <excludes>META-INF/*.SF</excludes>
                                <excludes>META-INF/*.DSA</excludes>
                                <excludes>META-INF/*.RSA</excludes>
                                <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.2.1</version>
                    <executions>
                        <execution>
                            <id>unpack-dependencies</id>
    
                            <phase>package</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>${java.home}/../bin/javapackager</executable>
                                <arguments>
                                    <argument>-createjar</argument>
                                    <argument>-nocss2bin</argument>
                                    <argument>-appclass</argument>
                                    <argument>${mainClass}</argument>
                                    <argument>-srcdir</argument>
                                    <argument>${project.build.directory}/classes</argument>
                                    <argument>-outdir</argument>
                                    <argument>${project.build.directory}</argument>
                                    <argument>-outfile</argument>
                                    <argument>${project.build.finalName}.jar</argument>
                                </arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>default-cli</id>
                            <goals>
                                <goal>exec</goal>                            
                            </goals>
                            <configuration>
                                <executable>${java.home}/bin/java</executable>
                                <commandlineArgs>${runfx.args}</commandlineArgs>
                            </configuration>
                        </execution>
                    </executions>  
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <compilerArguments>
                            <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                        </compilerArguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.16</version>
                    <configuration>
                        <additionalClasspathElements>
                            <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                        </additionalClasspathElements>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>eclipselink</artifactId>
                <version>2.5.2</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
                <version>2.5.2</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
        <reporting>
            <plugins>
    
            </plugins>
        </reporting>
    </project>
    

0 个答案:

没有答案