gpt4 book ai didi

javax.persistence.PersistenceException : [PersistenceUnit: sapo] class or package not found

转载 作者:行者123 更新时间:2023-11-30 10:56:07 27 4
gpt4 key购买 nike

我知道 StackOverflow 中还有关于此主题的其他问题,我阅读了它们,但我无法摆脱这个错误。

我正在 JBoss-as-7.1.1 Final 中部署我的 Web 应用程序。这是一个 Maven 项目。

当我转到 sapo-ear 时,右键单击,运行 as,maven 安装,它说“构建成功”。然后我尝试在 JBoss 中完全发布它,然后它说:

23:59:26,009 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.persistenceunit."SAPo-ear.ear/SAPo-ejb.jar#sapo": org.jboss.msc.service.StartException in service jboss.persistenceunit."SAPo-ear.ear/SAPo-ejb.jar#sapo": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80-ea]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80-ea]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80-ea]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: sapo] class or package not found
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1400)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1047)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:692)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: java.lang.ClassNotFoundException: uy.edu.fing.tsi2.sapo.entities.Administrador from [Module "org.hibernate:main" from local module loader @beaed3 (roots: C:\Program Files\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_80-ea]
at java.lang.Class.forName(Class.java:278) [rt.jar:1.7.0_80-ea]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1317)
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1389)
... 11 more

据我所知,这可能是由于 persistence.xml 和 Adminstrador 类之间的不一致造成的。

这是我的 persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="sapo">
<jta-data-source>java:jboss/datasources/sapo</jta-data-source>
<class>sapo.entities.Administrador</class>
<class>sapo.entities.Almacen</class>
<class>sapo.entities.AtributoValor</class>
<class>sapo.entities.Comentario</class>
<class>sapo.entities.Estandar</class>
<class>sapo.entities.Mensaje</class>
<class>sapo.entities.Producto</class>
<class>sapo.entities.RolEnAlmacen</class>
<class>sapo.entities.CatCompleja</class>
<class>sapo.entities.ProductoGenerico</class>
<class>sapo.entities.TransaccionInterna</class>
<class>sapo.entities.TransaccionExterna</class>


<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>

这是我的管理员类

@Entity
public class Administrador extends Usuario {

public Administrador(){
}

public Administrador(String nick, String password, String nombre,
String mail, String direccion, Date fechaNacimiento,
String linkImagen) {
super(nick, password, nombre, mail, direccion, fechaNacimiento, linkImagen);
// TODO Auto-generated constructor stub
}


}

Usuario 是一个抽象类

@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Usuario {
@Id
@GeneratedValue(strategy=GenerationType.TABLE)
@Basic(optional = false)
private Long id;
//attribs, Getters setters and other methods
}

最奇怪的是来自 jboss 堆栈跟踪的这一行

java.lang.ClassNotFoundException: uy.edu.fing.tsi2.sapo.entities.Administrador

此目录全部更改为 sapo.entities.Administrador,长路径来自旧版本。我删除了这个旧项目并从 git 中再次克隆了它,我还删除了 C:\Program Files\jboss-as-7.1.1.Final\standalone\deployments 中的所有文件,但堆栈跟踪继续抛出这个旧路径。

我的团队成员正在使用相同的配置,从同一个 git 存储库克隆而我却堆积如山。

最佳答案

最后我解决了它,这是一个 pom.xml 中的 maven 项目配置问题,我们在 artefact 和 parents 的组 ID 方面遇到了一些问题。

我没有确切的答案,因为我的队友解决了这个问题,我会问她并稍后更新这个答案以提供更多细节。

关于javax.persistence.PersistenceException : [PersistenceUnit: sapo] class or package not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33093835/

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