3 Replies Latest reply on Jan 1, 2012 9:35 PM by sfcoy

    Can't map target entity property

    samwun9988

      Hi,

       

      With Jboss71, Hibernate 3, when I deploy a ejb module, jboss can't map my user-defined class to a target entity property.

       

      Here is the error:

       

       

      09:10:06,739 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-8) register: jboss.ws:context=category6-ws-web,endpoint=CategorySubcategoriesServiceImpl

      09:10:06,740 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-8) register: jboss.ws:context=category6-ws-web,endpoint=CategoryImagesServiceImpl

      09:10:06,759 INFO  [org.jboss.jpa] (MSC service thread 1-1) JBAS011402: Starting Persistence Unit Service 'category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU'

      09:10:06,839 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-1) HCANN000001: Hibernate Commons Annotations {4.0.0.CR2}

      09:10:06,842 INFO  [org.hibernate.Version] (MSC service thread 1-1) HHH00412:Hibernate Core {4.0.0.CR2}

      09:10:06,843 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH00206:hibernate.properties not found

      09:10:06,846 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH00021:Bytecode provider name : javassist

      09:10:06,858 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-1) HHH00204:Processing PersistenceUnitInfo [

              name: HousewareCategoryPU

              ...]

      09:10:06,897 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-8) Creating Service {http://service.category.houseware.ix/}CategorySubcategoriesServiceImplService from class ix.houseware.category.service.CategorySubcategoriesService

      09:10:06,977 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": Failed to start service

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [:1.6.0_07]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [:1.6.0_07]

              at java.lang.Thread.run(Thread.java:619) [:1.6.0_07]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: HousewareCategoryPU] Unable to build EntityManagerFactory

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:908)

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)

              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:145)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:78)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

              ... 3 more

      Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: ix.houseware.category.entity.CategoryImages.categorySubcategories in ix.houseware.category.entity.CategorySubcategories.categoryImagesCollection

              at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:665)

              at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:625)

              at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)

              at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1573)

              at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1346)

              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1711)

              at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)

              ... 9 more

       

       

       

      CategoryImages.java class:

       

      @Entity

      @Table(name = "category_images", catalog = "houseware", schema = "")

      @XmlRootElement

      @NamedQueries({

          @NamedQuery(name = "CategoryImages.findAll", query = "SELECT c FROM CategoryImages c"),

          @NamedQuery(name = "CategoryImages.findByImageId", query = "SELECT c FROM CategoryImages c WHERE c.imageId = :imageId"),

          @NamedQuery(name = "CategoryImages.findByImageTitle", query = "SELECT c FROM CategoryImages c WHERE c.imageTitle = :imageTitle"),

          @NamedQuery(name = "CategoryImages.findByImageType", query = "SELECT c FROM CategoryImages c WHERE c.imageType = :imageType")})

      public class CategoryImages implements Serializable {

          private static final long serialVersionUID = 1L;

          @Id

          @Basic(optional = false)

          @NotNull

          @Column(name = "image_id", nullable = false)

          private Integer imageId;

          @Size(max = 64)

          @Column(name = "image_title", length = 64)

          private String imageTitle;

          @Size(max = 5)

          @Column(name = "image_type", length = 5)

          private String imageType;

          @Lob

          @Column(name = "image_data")

          private byte[] imageData;

          @Id

          @JoinColumn(name = "category_id", referencedColumnName = "category_id", nullable = false)

          @ManyToOne(optional = false)

          private CategorySubcategories categoryId;

       

       

          public CategoryImages() {

          }

       

       

          public CategoryImages(Integer imageId) {

              this.imageId = imageId;

          }

       

       

          public Integer getImageId() {

              return imageId;

          }

       

       

          public void setImageId(Integer imageId) {

              this.imageId = imageId;

          }

       

       

          public String getImageTitle() {

              return imageTitle;

          }

       

       

          public void setImageTitle(String imageTitle) {

              this.imageTitle = imageTitle;

          }

       

       

          public String getImageType() {

              return imageType;

          }

       

       

          public void setImageType(String imageType) {

              this.imageType = imageType;

          }

       

       

          public byte[] getImageData() {

              return imageData;

          }

       

       

          public void setImageData(byte[] imageData) {

              this.imageData = imageData;

          }

       

       

          public CategorySubcategories getCategoryId() {

              return categoryId;

          }

       

       

          public void setCategoryId(CategorySubcategories categoryId) {

              this.categoryId = categoryId;

          }

       

       

      CategorySubcategories.java class:

       

      @Entity

      @Table(name = "category_subcategories", catalog = "houseware", schema = "")

      @XmlRootElement

      @NamedQueries({

          @NamedQuery(name = "CategorySubcategories.findAll", query = "SELECT c FROM CategorySubcategories c"),

          @NamedQuery(name = "CategorySubcategories.findByCategoryId", query = "SELECT c FROM CategorySubcategories c WHERE c.categoryId = :categoryId"),

          @NamedQuery(name = "CategorySubcategories.findByCategoryName", query = "SELECT c FROM CategorySubcategories c WHERE c.categoryName = :categoryName"),

          @NamedQuery(name = "CategorySubcategories.findByLft", query = "SELECT c FROM CategorySubcategories c WHERE c.lft = :lft"),

          @NamedQuery(name = "CategorySubcategories.findByRgt", query = "SELECT c FROM CategorySubcategories c WHERE c.rgt = :rgt"),

          @NamedQuery(name = "CategorySubcategories.findImmediateParentByChild", query =

               "SELECT parent FROM CategorySubcategories node, CategorySubcategories parent " +

               "WHERE node.lft >  parent.lft AND node.lft < parent.rgt AND node.categoryName = :childNode ORDER BY parent.lft desc"),

          @NamedQuery(name = "CategorySubcategories.findByCategoryNamePaging", query = "SELECT c FROM CategorySubcategories c WHERE c.categoryName LIKE :categoryName ORDER BY c.lft")

      })

      public class CategorySubcategories implements Serializable {

          private static final long serialVersionUID = 1L;

          @Id

          @Basic(optional = false)

          @Column(name = "category_id")

          private Integer categoryId;

          @Column(name = "category_name")

          private String categoryName;

          @Column(name = "lft")

          private Integer lft;

          @Column(name = "rgt")

          private Integer rgt;

          @Lob

          @Column(name = "category_desc")

          private String categoryDesc;

          @OneToMany(cascade = CascadeType.ALL, mappedBy = "categorySubcategories")

          private Collection<CategoryImages> categoryImagesCollection;

       

       

          public CategorySubcategories() {

          }

       

       

          public CategorySubcategories(Integer categoryId) {

              this.categoryId = categoryId;

          }

       

       

          public Integer getCategoryId() {

              return categoryId;

          }

       

       

          public void setCategoryId(Integer categoryId) {

              this.categoryId = categoryId;

          }

       

       

          public String getCategoryName() {

              return categoryName;

          }

       

       

          public void setCategoryName(String categoryName) {

              this.categoryName = categoryName;

          }

       

       

          public Integer getLft() {

              return lft;

          }

       

       

          public void setLft(Integer lft) {

              this.lft = lft;

          }

       

       

          public Integer getRgt() {

              return rgt;

          }

       

       

          public void setRgt(Integer rgt) {

              this.rgt = rgt;

          }

       

       

          public String getCategoryDesc() {

              return categoryDesc;

          }

       

       

          public void setCategoryDesc(String categoryDesc) {

              this.categoryDesc = categoryDesc;

          }

       

       

          @XmlTransient

          public Collection<CategoryImages> getCategoryImagesCollection() {

              return categoryImagesCollection;

          }

       

       

          public void setCategoryImagesCollection(Collection<CategoryImages> categoryImagesCollection) {

              this.categoryImagesCollection = categoryImagesCollection;

          }

       

       

      Any suggestion would be very appreciated.

      Thanks

      Sam

        • 1. Re: Can't map target entity property
          sfcoy

          This

              @Id
              @JoinColumn(name = "category_id", referencedColumnName = "category_id", nullable = false)
              @ManyToOne(optional = false)
              private CategorySubcategories categoryId;

          does not look right. Get rid of the @Id.

          • 2. Re: Can't map target entity property
            samwun9988

            Hi

            After commented out the @Id annotation, it still thrown a similar error:

             

             

            23:02:53,919 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-5) register: jboss.ws:context=category6-ws-web,endpoint=CategorySubcategoriesServiceImpl

            23:02:53,921 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-5) register: jboss.ws:context=category6-ws-web,endpoint=CategoryImagesServiceImpl

            23:02:53,939 INFO  [org.jboss.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service 'category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU'

            23:02:54,018 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-3) HCANN000001: Hibernate Commons Annotations {4.0.0.CR2}

            23:02:54,022 INFO  [org.hibernate.Version] (MSC service thread 1-3) HHH00412:Hibernate Core {4.0.0.CR2}

            23:02:54,023 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH00206:hibernate.properties not found

            23:02:54,024 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH00021:Bytecode provider name : javassist

            23:02:54,037 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) HHH00204:Processing PersistenceUnitInfo [

                    name: HousewareCategoryPU

                    ...]

            23:02:54,081 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://service.category.houseware.ix/}CategorySubcategoriesServiceImplService from class ix.houseware.category.service.CategorySubcategoriesService

            23:02:54,155 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": Failed to start service

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [:1.6.0_07]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [:1.6.0_07]

                    at java.lang.Thread.run(Thread.java:619) [:1.6.0_07]

            Caused by: javax.persistence.PersistenceException: [PersistenceUnit: HousewareCategoryPU] Unable to build EntityManagerFactory

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:908)

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)

                    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:145)

                    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:78)

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                    ... 3 more

            Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: ix.houseware.category.entity.CategoryImages.categorySubcategories in ix.houseware.category.entity.CategorySubcategories.categoryImagesCollection

                    at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:665)

                    at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:625)

                    at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)

                    at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1573)

                    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1346)

                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1711)

                    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)

                    ... 9 more

             

             

            23:02:54,605 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be http://localhost:8080/category6-ws-web/CategoryServices

            23:02:54,707 INFO  [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-5) WSDL published to: file:/usr/local/users/jboss/jboss71A2/standalone/data/wsdl/category6-ws-ear.ear/catetory6-ws-web.war/CategorySubcategoriesServiceImplService.wsdl

            23:02:54,712 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://service.category.houseware.ix/}CategoryImagesServiceImplService from class ix.houseware.category.service.CategoryImagesService

            23:02:54,760 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be http://localhost:8080/category6-ws-web/CategoryImagesServices

            23:02:54,779 INFO  [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-5) WSDL published to: file:/usr/local/users/jboss/jboss71A2/standalone/data/wsdl/category6-ws-ear.ear/catetory6-ws-web.war/CategoryImagesServiceImplService.wsdl

            23:02:54,853 INFO  [org.jboss.as.webservices.service.EndpointService] (MSC service thread 1-6) Starting service jboss.ws.endpoint.category6-ws-web.CategoryImagesServiceImpl

            23:02:54,854 INFO  [org.jboss.as.webservices.service.EndpointService] (MSC service thread 1-5) Starting service jboss.ws.endpoint.category6-ws-web.CategorySubcategoriesServiceImpl

            23:02:54,865 INFO  [org.jboss.web] (MSC service thread 1-1) registering web context: /category6-ws-web

            23:02:55,068 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployment of "category6-ws-ear.ear" was rolled back with failure message {"Failed services" => {"jboss.persistenceunit.\"category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU\": Failed to start service"}}

            23:02:55,069 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) Service status report

              Services which failed to start:

                  service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."category6-ws-ear.ear/category6-ws-ejb.jar#HousewareCategoryPU": Failed to start service

             

            CategoryImages.java class:

            @Entity

            @Table(name = "category_images", catalog = "houseware", schema = "")

            @XmlRootElement

            @NamedQueries({

                @NamedQuery(name = "CategoryImages.findAll", query = "SELECT c FROM CategoryImages c"),

                @NamedQuery(name = "CategoryImages.findByImageId", query = "SELECT c FROM CategoryImages c WHERE c.imageId = :imageId"),

                @NamedQuery(name = "CategoryImages.findByImageTitle", query = "SELECT c FROM CategoryImages c WHERE c.imageTitle = :imageTitle"),

                @NamedQuery(name = "CategoryImages.findByImageType", query = "SELECT c FROM CategoryImages c WHERE c.imageType = :imageType")})

            public class CategoryImages implements Serializable {

                private static final long serialVersionUID = 1L;

                @Id

                @Basic(optional = false)

                @NotNull

                @Column(name = "image_id", nullable = false)

                private Integer imageId;

                @Size(max = 64)

                @Column(name = "image_title", length = 64)

                private String imageTitle;

                @Size(max = 5)

                @Column(name = "image_type", length = 5)

                private String imageType;

                @Lob

                @Column(name = "image_data")

                private byte[] imageData;

            //    @Id

                @JoinColumn(name = "category_id", referencedColumnName = "category_id", nullable = false)

                @ManyToOne(optional = false)

                private CategorySubcategories categoryId;

             

             

                public CategoryImages() {

                }

             

             

                public CategoryImages(Integer imageId) {

                    this.imageId = imageId;

                }

             

             

                public Integer getImageId() {

                    return imageId;

                }

             

             

                public void setImageId(Integer imageId) {

                    this.imageId = imageId;

                }

             

             

                public String getImageTitle() {

                    return imageTitle;

                }

             

             

                public void setImageTitle(String imageTitle) {

                    this.imageTitle = imageTitle;

                }

             

             

                public String getImageType() {

                    return imageType;

                }

             

             

                public void setImageType(String imageType) {

                    this.imageType = imageType;

                }

             

             

                public byte[] getImageData() {

                    return imageData;

                }

             

             

                public void setImageData(byte[] imageData) {

                    this.imageData = imageData;

                }

             

             

                public CategorySubcategories getCategoryId() {

                    return categoryId;

                }

             

             

                public void setCategoryId(CategorySubcategories categoryId) {

                    this.categoryId = categoryId;

                }

             

            • 3. Re: Can't map target entity property
              sfcoy

              You should probably be asking this over at https://forum.hibernate.org/

                  @OneToMany(cascade = CascadeType.ALL, mappedBy = "categoryId")
                  private Collection categoryImagesCollection;