JavaFX 和 JPA2 不编译

JavaFX and JPA2 don't compile

我正在尝试使用 JPA2 来持久化 classes 并使用 javaFX 编写 GUI。但是在编译时我得到这个错误(使用 EclipseLink 库):

    An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.RuntimeException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for sun.util.logging.PlatformLogger not found
    at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:407)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access00(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.main.Main.compile(Main.java:381)
    at com.sun.tools.javac.main.Main.compile(Main.java:370)
    at com.sun.tools.javac.main.Main.compile(Main.java:361)
    at com.sun.tools.javac.Main.compile(Main.java:56)
    at sun.reflect.GeneratedMethodAccessor487.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
    at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1159)
    at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:935)
    at org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:145)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor368.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor368.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor368.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor368.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for sun.util.logging.PlatformLogger not found
/home/bolet/cole/M02.BDD/JPA_PracticaFXML/nbproject/jfx-impl.xml:3438: The following error occurred while executing this line:
/home/bolet/cole/M02.BDD/JPA_PracticaFXML/nbproject/build-impl.xml:924: The following error occurred while executing this line:
/home/bolet/cole/M02.BDD/JPA_PracticaFXML/nbproject/build-impl.xml:264: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

我也尝试过使用不同的持久性库,使用 Hibernate 我得到了他的一个:

error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor could not be instantiated: java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/sessions/AbstractSession

我在更改库时重新编写了 persistence.xml 文件... 也许他们不兼容?我不这么认为...

这是我的坚持class:

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Sensor {

    @Id
    @Column(name="CODI")
    //@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
    private String codi; 
    @Column(name="PREU")
    private Double preu;

    public Sensor() {
    }

    public Sensor(String codi, Double preu) {
        this.codi = codi;
        this.preu = preu;
    }

    }
}

提前TY!

我在这里找到了解决方案: https://netbeans.org/bugzilla/show_bug.cgi?id=241616 和这里: http://tutoriales.stock-zero.com/2014/05/javafx-y-jpa-problemas.html

您必须转到并打开 <>/nbproject/project.properties。然后你必须找到以下行:

 javac.processorpath=\
     ${javac.classpath}:\
     ${libs.eclipselinkmodelgen.classpath}

并将其替换为另一个:

javac.processorpath=\
    ${javac.classpath}

然后你必须在项目的库中重新添加 jdbc 和 eclipse link 驱动程序 完成!