我知道StackOverflow中有关于此主题的其他问题,我读过它们但我无法摆脱这个错误。
我在JBoss-as-7.1.1 Final中部署我的Web应用程序。这是一个Maven项目。
当我进入sapo-ear,rigth click,run as,maven install,它说" buildsufulfull"。然后我尝试在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>
这是我的Administrador类
@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存储库克隆而没有任何问题,而我已经堆积了这个。
答案 0 :(得分:1)
最后我解决了它,这是pom.xml中maven项目配置中的一个问题,我们遇到了来自artefact和parent的组ID的问题。
我没有确切的答案,因为我的队友是谁解决了它,我会问她并稍后更详细地更新这个答案。
答案 1 :(得分:0)
如果您的xml文件中有条目以及相应类的注释,那么有时它会导致问题。尝试删除相应类的注释或xml条目之一,然后再次运行。希望这会有所帮助。