java.lang.reflect.InvocationTargetException

Hibernate JIRA | louie | 8 years ago
  1. 0

    Hibernate EJB configuration failed in the case of single-table inheritance strategy for relational entities. Here is the use case: @Entity public class User { @Id @SequenceGenerator(name = "user", sequenceName = "user_id") @GeneratedValue(generator = "user") private int id; private String name; @OneToMany(mappedBy = "user") private List<ExcludedGroupUser> excludedUsers; @OneToMany(mappedBy = "user") private List<IncludedGroupUser> includedUsers; ... } @Entity public class Group { @Id @SequenceGenerator(name = "group", sequenceName = "group_id") @GeneratedValue(generator = "group") private int id; private String name; @ManyToOne(fetch = FetchType.EAGER) private Group underlying; /** list of user belong to underlying group, but not belongs to this group */ @OneToMany(mappedBy = "group") private List<ExcludedGroupUser> excludedUsers; /** list of user belong to this group **/ @OneToMany(mappedBy = "group") private List<IncludedGroupUser> includedUsers; ... } The main relational entity: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="groupType",discriminatorType=DiscriminatorType.STRING, length=1) public class GroupUser { @Id @SequenceGenerator(name = "groupUser", sequenceName = "groupUser_id") @GeneratedValue(generator = "groupUser") private int id; @ManyToOne private Group group; @ManyToOne private User user; ... } The subclasses: @Entity @DiscriminatorValue("I") public class IncludedGroupUser extends GroupUser{ } and @Entity @DiscriminatorValue("E") public class ExcludedGroupUser extends GroupUser { } The build output error message: C:\workspaces\test-case\test-case>ant -verbose Apache Ant version 1.6.5 compiled on June 2 2005 Buildfile: build.xml Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.6.0_05\jre Detected OS: Windows XP parsing buildfile C:\workspaces\test-case\test-case\build.xml with URI = file:///C:/workspaces/test- case/test-case/build.xml Project base dir set to: C:\workspaces\test-case\test-case Build sequence for target(s) `compile' is [clean, copy-resources, compile] Complete build sequence is [clean, copy-resources, compile, ] clean: [delete] Deleting directory C:\workspaces\test-case\test-case\bin [delete] Deleting C:\workspaces\test-case\test-case\bin\META-INF\persistence.xml [delete] Deleting directory C:\workspaces\test-case\test-case\bin\META-INF [delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\ExcludedGroupUser.class [delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\Group.class [delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\GroupUser.class [delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\IncludedGroupUser.class [delete] Deleting C:\workspaces\test-case\test-case\bin\notWorking\User.class [delete] Deleting directory C:\workspaces\test-case\test-case\bin\notWorking [delete] Deleting C:\workspaces\test-case\test-case\bin\working\Employee.class [delete] Deleting C:\workspaces\test-case\test-case\bin\working\FullTimeEmployee.class [delete] Deleting C:\workspaces\test-case\test-case\bin\working\PartTimeEmployee.class [delete] Deleting directory C:\workspaces\test-case\test-case\bin\working [delete] Deleting directory C:\workspaces\test-case\test-case\bin [mkdir] Created dir: C:\workspaces\test-case\test-case\bin copy-resources: [copy] META-INF\persistence.xml added as META-INF/persistence.xml doesn't exist. [copy] omitted as is up to date. [copy] META-INF added as META-INF doesn't exist. [copy] notWorking added as notWorking doesn't exist. [copy] working added as working doesn't exist. [copy] Copying 1 file to C:\workspaces\test-case\test-case\bin [copy] Copying C:\workspaces\test-case\test-case\src\META-INF\persistence.xml to C:\workspaces\ test-case\test-case\bin\META-INF\persistence.xml [copy] Copied 3 empty directories to 2 empty directories under C:\workspaces\test-case\test-cas e\bin compile: [javac] META-INF\persistence.xml skipped - don't know how to handle it [javac] notWorking\ExcludedGroupUser.java added as notWorking/ExcludedGroupUser.class doesn't ex ist. [javac] notWorking\Group.java added as notWorking/Group.class doesn't exist. [javac] notWorking\GroupUser.java added as notWorking/GroupUser.class doesn't exist. [javac] notWorking\IncludedGroupUser.java added as notWorking/IncludedGroupUser.class doesn't ex ist. [javac] notWorking\User.java added as notWorking/User.class doesn't exist. [javac] working\Employee.java added as working/Employee.class doesn't exist. [javac] working\FullTimeEmployee.java added as working/FullTimeEmployee.class doesn't exist. [javac] working\PartTimeEmployee.java added as working/PartTimeEmployee.class doesn't exist. [javac] Compiling 8 source files to C:\workspaces\test-case\test-case\bin [javac] Using modern compiler [javac] Compilation arguments: [javac] '-d' [javac] 'C:\workspaces\test-case\test-case\bin' [javac] '-classpath' [javac] 'C:\workspaces\test-case\test-case\bin;C:\workspaces\test-case\test-case\lib\antlr-2.7.6 .jar;C:\workspaces\test-case\test-case\lib\commons-collections-3.1.jar;C:\workspaces\test-case\test- case\lib\commons-logging-1.1.1.jar;C:\workspaces\test-case\test-case\lib\dom4j-1.6.1.jar;C:\workspac es\test-case\test-case\lib\freemarker.jar;C:\workspaces\test-case\test-case\lib\hibernate-annotation s.jar;C:\workspaces\test-case\test-case\lib\hibernate-commons-annotations.jar;C:\workspaces\test-cas e\test-case\lib\hibernate-entitymanager.jar;C:\workspaces\test-case\test-case\lib\hibernate-tools.ja r;C:\workspaces\test-case\test-case\lib\hibernate3.jar;C:\workspaces\test-case\test-case\lib\javassi st-3.6.0.GA.jar;C:\workspaces\test-case\test-case\lib\jboss-archive-browsing.jar;C:\workspaces\test- case\test-case\lib\log4j-1.2.15.jar;C:\workspaces\test-case\test-case\lib\ojdbc14.jar;C:\workspaces\ test-case\test-case\lib\persistence-api.jar;C:\workspaces\test-case\test-case\lib\slf4j-api-1.4.2.ja r;C:\workspaces\test-case\test-case\lib\slf4j-log4j12-1.5.2.jar;C:\apache-ant-1.6.5\lib\ant-launcher .jar;C:\workspaces\test-case\test-case;C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip;C:\apach e-ant-1.6.5\lib\ant-antlr.jar;C:\apache-ant-1.6.5\lib\ant-apache-bcel.jar;C:\apache-ant-1.6.5\lib\an t-apache-bsf.jar;C:\apache-ant-1.6.5\lib\ant-apache-log4j.jar;C:\apache-ant-1.6.5\lib\ant-apache-oro .jar;C:\apache-ant-1.6.5\lib\ant-apache-regexp.jar;C:\apache-ant-1.6.5\lib\ant-apache-resolver.jar;C :\apache-ant-1.6.5\lib\ant-commons-logging.jar;C:\apache-ant-1.6.5\lib\ant-commons-net.jar;C:\apache -ant-1.6.5\lib\ant-icontract.jar;C:\apache-ant-1.6.5\lib\ant-jai.jar;C:\apache-ant-1.6.5\lib\ant-jav amail.jar;C:\apache-ant-1.6.5\lib\ant-jdepend.jar;C:\apache-ant-1.6.5\lib\ant-jmf.jar;C:\apache-ant- 1.6.5\lib\ant-jsch.jar;C:\apache-ant-1.6.5\lib\ant-junit.jar;C:\apache-ant-1.6.5\lib\ant-netrexx.jar ;C:\apache-ant-1.6.5\lib\ant-nodeps.jar;C:\apache-ant-1.6.5\lib\ant-starteam.jar;C:\apache-ant-1.6.5 \lib\ant-stylebook.jar;C:\apache-ant-1.6.5\lib\ant-swing.jar;C:\apache-ant-1.6.5\lib\ant-trax.jar;C: \apache-ant-1.6.5\lib\ant-vaj.jar;C:\apache-ant-1.6.5\lib\ant-weblogic.jar;C:\apache-ant-1.6.5\lib\a nt-xalan1.jar;C:\apache-ant-1.6.5\lib\ant-xslp.jar;C:\apache-ant-1.6.5\lib\ant.jar;C:\apache-ant-1.6 .5\lib\jaxws-tools.jar;C:\apache-ant-1.6.5\lib\xercesImpl.jar;C:\apache-ant-1.6.5\lib\xml-apis.jar;C :\Program Files\Java\jdk1.6.0_05\lib\tools.jar' [javac] '-sourcepath' [javac] 'C:\workspaces\test-case\test-case\src' [javac] '-g:none' [javac] [javac] The ' characters around the executable and arguments are [javac] not part of the command. [javac] Files to be compiled: [javac] C:\workspaces\test-case\test-case\src\notWorking\ExcludedGroupUser.java [javac] C:\workspaces\test-case\test-case\src\notWorking\Group.java [javac] C:\workspaces\test-case\test-case\src\notWorking\GroupUser.java [javac] C:\workspaces\test-case\test-case\src\notWorking\IncludedGroupUser.java [javac] C:\workspaces\test-case\test-case\src\notWorking\User.java [javac] C:\workspaces\test-case\test-case\src\working\Employee.java [javac] C:\workspaces\test-case\test-case\src\working\FullTimeEmployee.java [javac] C:\workspaces\test-case\test-case\src\working\PartTimeEmployee.java Property ${libraries} has not been set [hibernatetool] Executing Hibernate Tool with a JPA Configuration dropping C:\workspaces\test-case\test-case\${libraries} from path as it doesn't exist [hibernatetool] 1. task: hbm2ddl (Generates database schema) [hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Ver sion). [hibernatetool] log4j:WARN Please initialize the log4j system properly. [hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema) [hibernatetool] To get the full stack trace run ant with -verbose [hibernatetool] Problems in creating a configuration for JPA. Have you remembered to add hibernate E ntityManager jars to the classpath ? [hibernatetool] java.lang.reflect.InvocationTargetException [hibernatetool] javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.ex cludedUsers [hibernatetool] org.hibernate.AnnotationException: mappedBy reference an unknown target entity prope rty: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers BUILD FAILED C:\workspaces\test-case\test-case\build.xml:28: Problems in creating a configuration for JPA. Have y ou remembered to add hibernate EntityManager jars to the classpath ? at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java :57) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java :43) ... 16 more Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude dUsers at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258) ... 21 more Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder. java:576) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java: 319) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246) ... 21 more --- Nested Exception --- java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java :43) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy refer ence an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.exclude dUsers at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258) ... 21 more Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder. java:576) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java: 319) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246) ... 21 more Total time: 2 seconds

    Hibernate JIRA | 8 years ago | louie
    java.lang.reflect.InvocationTargetException
  2. 0

    @Embeddable Issue with Spring and Hibernate3

    Stack Overflow | 4 years ago | Ben Dol
    org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: nz.co.doltech.ims.project.server.entities.CategoryEntity.incidentCategoryJoins[nz.co.doltech.ims.project.server.entities.IncidentCategoryJoin]
  3. 0

    AnnotationException: A Foreign key refering has the wrong number of column. should be 2

    Stack Overflow | 2 years ago | ELĂ­as Vargas
    org.hibernate.AnnotationException: A Foreign key refering com.modulos.pvs.acceso.datos.entity.Provincia from com.modulos.pvs.acceso.datos.entity.Ciudad has the wrong number of column. should be 2
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Apply generic class @MappedSuperclass as targetEntity.Error: @ManyToOne on models.Unit.parent references an unknown entity: models.GenericHierarchic

    Stack Overflow | 2 years ago
    org.hibernate.AnnotationException: @OneToOne or @ManyToOne on models.Unit.parent references an unknown entity: models.GenericHierarchicalDictionary
  6. 0

    Should Hibernate be able to handle overlapping foreign keys?

    Stack Overflow | 6 years ago | Kawu
    javax.persistence.PersistenceException: [PersistenceUnit: geoinfo] Unable to configure EntityManagerFactory

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.AnnotationException

      mappedBy reference an unknown target entity property: notWorking.ExcludedGroupUser.user in notWorking.User.excludedUsers

      at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass()
    2. Hibernate
      Configuration.buildMappings
      1. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:576)
      2. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
      3. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
      4. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1140)
      5. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:319)
      6. org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
      6 frames
    3. Hibernate EJB
      Ejb3Configuration.configure
      1. org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
      2. org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
      3. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
      4. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
      5. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
      5 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. A Hibernate O/RM Module
      HibernateToolTask.execute
      1. org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:43)
      2. org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)
      3. org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
      4. org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
      5. org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
      5 frames
    6. Ant
      Main.startAnt
      1. org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      2. org.apache.tools.ant.Task.perform(Task.java:364)
      3. org.apache.tools.ant.Target.execute(Target.java:341)
      4. org.apache.tools.ant.Target.performTasks(Target.java:369)
      5. org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      6. org.apache.tools.ant.Project.executeTarget(Project.java:1185)
      7. org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
      8. org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      9. org.apache.tools.ant.Main.runBuild(Main.java:668)
      10. org.apache.tools.ant.Main.startAnt(Main.java:187)
      10 frames
    7. Apache Ant Launcher
      Launcher.main
      1. org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
      2. org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
      2 frames