hi,
I am migrating my jBoss EAP 4.3.1 app to JBoss EAP 6.0.0.Beta2, there's a deploy error when I deploy my app on new server:
Code:
15:20:45,570 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.persistenceunit."persistence-common.jar#entityManagerCIS": org.jboss.msc.service.StartException in service jboss.persistenceunit."persistence-common.jar#entityManagerCIS": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_03]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_03]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: entityManagerCIS] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
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-redhat-1.jar:1.0.2.GA-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
... 3 more
Caused by: org.hibernate.MappingException: Unknown entity: com.synnex.orm.cis.common.customer.CustDocNote
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1190)
at org.hibernate.ejb.metamodel.AttributeFactory.getDeclarerEntityMetamodel(AttributeFactory.java:240)
at org.hibernate.ejb.metamodel.AttributeFactory.access$600(AttributeFactory.java:65)
at org.hibernate.ejb.metamodel.AttributeFactory$5.resolveMember(AttributeFactory.java:957)
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:442)
at org.hibernate.ejb.metamodel.AttributeFactory.buildIdAttribute(AttributeFactory.java:146)
at org.hibernate.ejb.metamodel.MetadataContext.applyIdMetadata(MetadataContext.java:250)
at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:179)
at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:85)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:103)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 9 more
Here I mapped class CustDocNote to 2 tables(current and history table) by different entity name
Code:
<hibernate-mapping>
<class name="com.synnex.orm.cis.common.customer.CustDocNote" table="cust_doc_notes"
catalog="CIS" entity-name="CurrentCustDocNote">
<id name="noteNo" type="integer">
<column name="note_no" />
<generator class="assigned" />
</id>
<property name="orderType" type="integer">
<column name="order_type" not-null="true"/>
</property>
<property name="orderNo" type="integer">
<column name="order_no" not-null="true" />
</property>
<property name="text1" type="string">
<column name="text1" not-null="true" />
</property>
<property name="text2" type="string">
<column name="text2" />
</property>
<property name="content" type="string">
<column name="content" />
</property>
<property name="entryDatetime" type="timestamp">
<column name="entry_datetime" length="23" not-null="true" />
</property>
<many-to-one name="entryUser" class="com.synnex.orm.cis.common.org.ManagerLightWeight">
<column name="entry_id" />
</many-to-one>
<property name="deleteDate" type="timestamp">
<column name="delete_date" length="23" />
</property>
<many-to-one name="deleteUser" class="com.synnex.orm.cis.common.org.ManagerLightWeight">
<column name="delete_id" />
</many-to-one>
<property name="notAllowCustomer" type="string">
<column name="not_allow_customer" length="1" not-null="true" />
</property>
<property name="custNo" type="integer">
<column name="cust_no" />
</property>
<property name="source" type="string">
<column name="source" length="10" />
</property>
</class>
<class name="com.synnex.orm.cis.common.customer.CustDocNote" table="his_cust_doc_notes"
catalog="CIS" entity-name="HistoryCustDocNote">
<id name="noteNo" type="integer">
<column name="note_no" />
<generator class="assigned" />
</id>
<property name="orderType" type="integer">
<column name="order_type" not-null="true" />
</property>
<property name="orderNo" type="integer">
<column name="order_no" not-null="true" />
</property>
<property name="text1" type="string">
<column name="text1" not-null="true" />
</property>
<property name="text2" type="string">
<column name="text2" />
</property>
<property name="content" type="string">
<column name="content" />
</property>
<property name="entryDatetime" type="timestamp">
<column name="entry_datetime" length="23" not-null="true" />
</property>
<many-to-one name="entryUser" class="com.synnex.orm.cis.common.org.ManagerLightWeight">
<column name="entry_id" />
</many-to-one>
<property name="deleteDate" type="timestamp">
<column name="delete_date" length="23" />
</property>
<many-to-one name="deleteUser" class="com.synnex.orm.cis.common.org.ManagerLightWeight">
<column name="delete_id" />
</many-to-one>
<property name="notAllowCustomer" type="string">
<column name="not_allow_customer" length="1" not-null="true" />
</property>
<property name="custNo" type="integer">
<column name="cust_no" />
</property>
<property name="source" type="string">
<column name="source" length="10" />
</property>
</class>
</hibernate-mapping>
I downloaded the source code of hibernate-entitymanager-4.1.3, and found a suspected bug in the code AttributeFactory.java:
Code:
private EntityMetamodel getDeclarerEntityMetamodel(IdentifiableType<?> ownerType) {
final Type.PersistenceType persistenceType = ownerType.getPersistenceType();
if ( persistenceType == Type.PersistenceType.ENTITY) {
return context.getSessionFactory()
.getEntityPersister( ownerType.getJavaType().getName() )
.getEntityMetamodel();
}
Should ownerType.getJavaType().getName() be CurrentCustDocNote instead of CustDocNote for this case? As there is no entity named CustDocNote in my app, just CurrentCustDocNote or HistoryCustDocNote.
Thanks in advance
Andy