2012-10-16 99 views
0

我有幾個實體的應用程序。在JBoss AS7部署期間,我發生下面列出的異常:部署期間JBoss休眠異常

使用想法11.1.3; Ubuntu 12.04; maven 3.0.3,如果需要,我可以顯示項目的pom文件。

17:24:00,770 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."kladr.ear/kladr-ejb-1.0-SNAPSHOT.jar#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."kladr.ear/kladr-ejb-1.0-SNAPSHOT.jar#primary": 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$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_35] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_35] 
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_35] 
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) 
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) 
    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: org.hibernate.MappingException: Duplicate property mapping of version found in com.kmware.ttk.kladr.model.KladrSettings 
    at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:486) 
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:476) 
    at org.hibernate.mapping.RootClass.validate(RootClass.java:268) 
    at org.hibernate.cfg.Configuration.validate(Configuration.java:1287) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729) 
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) 
    ... 9 more 

這裏是我的類代碼(不含進口):

@Entity 
@Table(name = "KLADR_SETTINGS",schema ="KLADR") 
public class KladrSettings extends RQObject implements Serializable{ 
    private static final long serialVersionUID = -8557672721736414960L; 
    private String id; 
    private String url; 
    private String pathName; 
    private String namePackage; 
    private int sizeArchive; 
    private Long version; 

    @Id 
    @Column(name = "KLADR_SETTINGS_ID") 
    public String getId() { 
     return id; 
    } 
    public void setId(String id) { 
     this.id = id; 
    } 

    @Column(name = "KLADR_SETTINGS_URL") 
    public String getUrl() { 
     return url; 
    } 
    public void setUrl(String url) { 
     this.url = url; 
    } 

    @Column(name = "KLADR_SETTINGS_PATHNAME") 
    public String getPathName() { 
     return pathName; 
    } 
    public void setPathName(String pathName) { 
     this.pathName = pathName; 
    } 

    @Column(name = "KLADR_SETTINGS_NAMEPACKAGE") 
    public String getNamePackage() { 
     return namePackage; 
    } 
    public void setNamePackage(String namePackage) { 
     this.namePackage = namePackage; 
    } 
    @Column(name = "KLADR_SETTINGS_SIZE_ARCHIVE") 
    public int getSizeArchive() { 
     return sizeArchive; 
    } 
    public void setSizeArchive(int sizeArchive) { 
     this.sizeArchive = sizeArchive; 
    } 

    @Column(name = "KLADR_SETTINGS_VERSION") 
    public Long getVersion() { 
     return version; 
    } 
    public void setVersion(Long version) { 
     this.version = version; 
    } 


    @Override public PortableEntity toPortableEntity(boolean loadCollections, boolean loadNested) { 

     PKladrSettings pentity = new PKladrSettings(getId(), getName(), getVersion(), 
       getDeleted()); 

     pentity.setId(getId()); 
     pentity.setNamePackage(getNamePackage()); 
     pentity.setPathName(getPathName()); 
     pentity.setSizeArchive(getSizeArchive()); 
     pentity.setUrl(getUrl()); 
     pentity.setVersion(getVersion()); 

     return pentity; 

    } 

    @Override public void fromPortable(PortableEntity pentity) { 
     PKladrSettings input = null; 
     if (pentity instanceof PKladrSettings){ 
      input = (PKladrSettings) pentity; 
     } 
     if(input!=null){ 
      this.setId(input.getId()); 
      this.setName(input.getDisplayName()); 
      this.setVersion(input.getVersion()); 
      this.setDeleted(input.isDeleted()); 

      this.setNamePackage(input.getNamePackage()); 
      this.setPathName(input.getPathName()); 
      this.setSizeArchive(input.getSizeArchive()); 
      this.setUrl(input.getUrl()); 

     } 
    } 

    @Override public void loadLazyCollections() { 

    } 
} 

是什麼意思duplicate property mapping

+0

基類RQObject是否也有版本屬性? –

+0

是的。 KLadrSettings覆蓋它 –

回答

5

它看起來像屬性private Long version;定義在超類和擴展類。將其從其中一箇中刪除,它應該可以工作。

+0

您的回答對我來說非常有用 –

+0

所以我不能這樣做:使用somePropery + getter/setter創建超類,然後擴展這個超類並在子類中再次覆蓋這個someProperty,例如爲了獲得不同的Bean驗證從同一個超類派生的不同子類中的約束? –