gpt4 book ai didi

java - 在 JPA 实体内实例化 JavaFX 属性会导致 "Unable to load class"错误

转载 作者:行者123 更新时间:2023-12-02 12:57:27 24 4
gpt4 key购买 nike

我在 war 中有以下类(class)。它也是唯一具有任何 JPA 注释的类:

@MappedSuperclass
public abstract class BaseEntity {
protected ObjectProperty<Object> loc3 = new SimpleObjectProperty<>();
}

当我部署 war 时,出现以下错误:

ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 65) MSC000001: Failed to start service jboss.persistenceunit."DevCrowd.war#prod": org.jboss.msc.service.StartException in service jboss.persistenceunit."DevCrowd.war#prod": org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [pl.devcrowd.virtual.business.state.entity.BaseEntity]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:121)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [pl.devcrowd.virtual.business.state.entity.BaseEntity]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:232)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.<init>(AnnotationMetadataSourceProcessorImpl.java:103)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.<init>(MetadataBuildingProcess.java:147)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:141)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:161)
... 7 more
Caused by: java.lang.NoClassDefFoundError: javafx/beans/property/ObjectProperty
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:226)
... 14 more
Caused by: java.lang.ClassNotFoundException: javafx.beans.property.ObjectProperty from [Module "deployment.DevCrowd.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 17 more

但是如果我删除实例化

@MappedSuperclass
public abstract class BaseEntity {
protected ObjectProperty<Object> loc3;
}

它有效。这也适用于 IntegerProperty。

没有 javafx beans 的比较:

@MappedSuperclass
public abstract class BaseEntity {
Object loc3 = new Object();
}

无论有没有初始化都可以工作。这是为什么?

编辑 - 运行时配置:

enter image description here

类路径条目:

enter image description here

最佳答案

根据我读到的评论 Class Loading in WildFly根据访问JDK类下的内容,我将此jboss-deployment-struction.xml添加到我的src\main\webapp\WEB-INF 文件夹:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="javafx/beans/property"/>
<path name="javafx/beans/binding"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>

即使属性位于 javafx.beans.property 下,这两个属性也是必需的,可能是因为它们的父类(super class)位于 .binding 中。

关于java - 在 JPA 实体内实例化 JavaFX 属性会导致 "Unable to load class"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44380328/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com