无法构建 Hibernate SessionFactory - 无法实例化测试对象
Unable to build Hibernate SessionFactory - could not instantiate test object
我发生了一个非常奇怪的错误
我有一个在 Java WEB 中开发的程序,使用 Hibernate 连接到 MySQL 数据库
该程序在这里的几台计算机上都可以正常运行,但是有一台计算机该程序无法运行!
我已经尝试更改服务器的版本,JDK 甚至 IDE,但即便如此,该程序仍无法在这台计算机上运行
错误提到“无法实例化测试对象”,但我没有在项目运行的任何计算机上对任何 classes/对象进行任何测试
日志
14:42:36,750 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 87) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private@1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3@23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate@5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate@5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate@5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:36,800 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "SA2021.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:37,049 INFO [org.jboss.as.server] (ServerService Thread Pool -- 48) WFLYSRV0010: Deployed "SA2021.war" (runtime-name : "SA2021.war")
14:42:37,055 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
WFLYCTL0448: 142 additional services are down due to their dependencies being missing or failed
14:42:37,196 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
14:42:37,207 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 23.0.2.Final (WildFly Core 15.0.1.Final) started (with errors) in 22372ms - Started 683 of 1011 services (146 services failed or missing dependencies, 365 services are lazy, passive or on-demand)
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:42:52,501 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:52,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0019: Stopped Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:52,547 INFO [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 18) Stopping cache manager null on null
14:42:52,561 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment SA2021.war (runtime-name: SA2021.war) in 65ms
14:42:52,566 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "SA2021.war" (runtime-name: "SA2021.war")
14:42:54,989 INFO [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for SA2021PU
14:42:55,123 INFO [org.jipijapa] (MSC service thread 1-6) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:55,201 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:55,201 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 18) HHH000204: Processing PersistenceUnitInfo [
name: SA2021PU
...]
14:42:55,463 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0003: Processing weld deployment SA2021.war
14:42:56,114 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-6) No shutdown hook registered: Please call close() manually on application shutdown.
14:42:56,208 INFO [org.jipijapa] (MSC service thread 1-7) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:56,933 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 8.0)
14:42:57,250 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:57,294 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'SA2021.war#SA2021PU'
14:42:57,299 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 18) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
14:42:57,305 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 18) Envers integration enabled? : true
14:42:57,379 INFO [org.hibernate.orm.beans] (ServerService Thread Pool -- 18) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl@26cf2ff5
14:42:57,383 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 18) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private@1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3@23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate@5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate@5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate@5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:57,426 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:57,583 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "SA2021.war" with deployment "SA2021.war"
14:42:57,585 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
我的 Tabcadastro class
package model.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="tabcadastro")
public class Tabcadastro implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer Id;
@Column
private String nome;
@Column
private String email;
@Column
private Integer cep;
@Column
private Integer cpf;
@Column
private String senha;
public Integer getId() {
return Id;
}
public void setId(Integer Id) {
this.Id = Id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getCep() {
return cep;
}
public void setCep(Integer cep) {
this.cep = cep;
}
public Integer getCpf() {
return cpf;
}
public void setCpf(Integer cpf) {
this.cpf = cpf;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
我的Persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="SA2021PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>model.entity.Tabcadastro</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/bancodreambk?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
看起来 Tabcadastro
的构造函数抛出了 RuntimeException
。你重新编译你的代码了吗?您是否正在使用某种 Java 以某种方式转换构造函数的代理?
我最近 运行 遇到了一个类似的问题,在一个具有相对基本的 java 实体持久化代码的网络应用程序中,restful 网络服务和网络 UI 代码和支持文件,例如图像,用于测试 restful 服务。代码稳定并正常运行了几年,但是在升级环境和开发工具并重建后,我在部署到 wildfly 时开始出错。服务器产生了相同的堆栈跟踪 - 除了源自不同的实体 class - 在部署期间如本期所述,在 wildfly 22 和 23 上,以及在 wildfly 11 上出现类似但不相同的错误。
最后发现Netbeans自带的deploy函数失败了,但是建一个war文件手动部署到wildfly 23就成功了。具体来说,netbeans中的部署函数将项目部署为文件夹,projectname.war,而在wildfly中无法正常部署。将相同的项目源构建到 netbeans 中的 war 文件中,projectname.war,然后手动部署该 war 文件,只需将其放入独立部署文件夹即可成功。原post中报告的问题是否是由于类似问题难以确定。
p.s。这是我的案例的环境:
- windows 10
- Apache Netbeans 12.3
- adoptopenjdk 的 jdk-11.0.10.9-hotspot
- wildfly(测试多个版本)
- postgresql 13数据库运行同框
- postgresql jdbc 驱动程序 42.2.20
- minimal persistence.xml 引用在 wildfly 中配置的 jndi 数据源
我发生了一个非常奇怪的错误
我有一个在 Java WEB 中开发的程序,使用 Hibernate 连接到 MySQL 数据库 该程序在这里的几台计算机上都可以正常运行,但是有一台计算机该程序无法运行!
我已经尝试更改服务器的版本,JDK 甚至 IDE,但即便如此,该程序仍无法在这台计算机上运行
错误提到“无法实例化测试对象”,但我没有在项目运行的任何计算机上对任何 classes/对象进行任何测试
日志
14:42:36,750 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 87) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private@1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3@23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate@5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate@5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate@5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:36,800 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "SA2021.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:37,049 INFO [org.jboss.as.server] (ServerService Thread Pool -- 48) WFLYSRV0010: Deployed "SA2021.war" (runtime-name : "SA2021.war")
14:42:37,055 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
WFLYCTL0448: 142 additional services are down due to their dependencies being missing or failed
14:42:37,196 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
14:42:37,207 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 23.0.2.Final (WildFly Core 15.0.1.Final) started (with errors) in 22372ms - Started 683 of 1011 services (146 services failed or missing dependencies, 365 services are lazy, passive or on-demand)
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:42:52,501 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:52,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0019: Stopped Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:52,547 INFO [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 18) Stopping cache manager null on null
14:42:52,561 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment SA2021.war (runtime-name: SA2021.war) in 65ms
14:42:52,566 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "SA2021.war" (runtime-name: "SA2021.war")
14:42:54,989 INFO [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for SA2021PU
14:42:55,123 INFO [org.jipijapa] (MSC service thread 1-6) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:55,201 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:55,201 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 18) HHH000204: Processing PersistenceUnitInfo [
name: SA2021PU
...]
14:42:55,463 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0003: Processing weld deployment SA2021.war
14:42:56,114 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-6) No shutdown hook registered: Please call close() manually on application shutdown.
14:42:56,208 INFO [org.jipijapa] (MSC service thread 1-7) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:56,933 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 8.0)
14:42:57,250 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:57,294 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'SA2021.war#SA2021PU'
14:42:57,299 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 18) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
14:42:57,305 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 18) Envers integration enabled? : true
14:42:57,379 INFO [org.hibernate.orm.beans] (ServerService Thread Pool -- 18) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl@26cf2ff5
14:42:57,383 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 18) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private@1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3@23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa@23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate@5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate@5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate@5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate@5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate@5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate@5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate@5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:57,426 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:57,583 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "SA2021.war" with deployment "SA2021.war"
14:42:57,585 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
我的 Tabcadastro class
package model.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="tabcadastro")
public class Tabcadastro implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer Id;
@Column
private String nome;
@Column
private String email;
@Column
private Integer cep;
@Column
private Integer cpf;
@Column
private String senha;
public Integer getId() {
return Id;
}
public void setId(Integer Id) {
this.Id = Id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getCep() {
return cep;
}
public void setCep(Integer cep) {
this.cep = cep;
}
public Integer getCpf() {
return cpf;
}
public void setCpf(Integer cpf) {
this.cpf = cpf;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
我的Persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="SA2021PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>model.entity.Tabcadastro</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/bancodreambk?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
看起来 Tabcadastro
的构造函数抛出了 RuntimeException
。你重新编译你的代码了吗?您是否正在使用某种 Java 以某种方式转换构造函数的代理?
我最近 运行 遇到了一个类似的问题,在一个具有相对基本的 java 实体持久化代码的网络应用程序中,restful 网络服务和网络 UI 代码和支持文件,例如图像,用于测试 restful 服务。代码稳定并正常运行了几年,但是在升级环境和开发工具并重建后,我在部署到 wildfly 时开始出错。服务器产生了相同的堆栈跟踪 - 除了源自不同的实体 class - 在部署期间如本期所述,在 wildfly 22 和 23 上,以及在 wildfly 11 上出现类似但不相同的错误。
最后发现Netbeans自带的deploy函数失败了,但是建一个war文件手动部署到wildfly 23就成功了。具体来说,netbeans中的部署函数将项目部署为文件夹,projectname.war,而在wildfly中无法正常部署。将相同的项目源构建到 netbeans 中的 war 文件中,projectname.war,然后手动部署该 war 文件,只需将其放入独立部署文件夹即可成功。原post中报告的问题是否是由于类似问题难以确定。
p.s。这是我的案例的环境:
- windows 10
- Apache Netbeans 12.3
- adoptopenjdk 的 jdk-11.0.10.9-hotspot
- wildfly(测试多个版本)
- postgresql 13数据库运行同框
- postgresql jdbc 驱动程序 42.2.20
- minimal persistence.xml 引用在 wildfly 中配置的 jndi 数据源