com.sun.jdi.InvocationException在“new Configuration()。configure()。buildSessionFactory()”中调用方法。

时间:2015-10-10 17:56:17

标签: java hibernate

我在尝试NullPointerException时看到buildSessionFactory。但是,在Eclipse的调试模式中单击异常对象时,我看到的消息是com.sun.jdi.InvocationException occurred invoking method.

我在引入新的Entity类之后才看到这种行为。存在类所绑定的表。没有错别字。 hibernate.cfg.xml也已成功解析。在hibernate尝试将新类绑定到表之后抛出致命异常。

  1. hibernate.cfg.xml中
  2. <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@lvsspldb06.qa.xxxx.com:1556:ICMDBTST</property>
        <property name="hibernate.connection.username">ICMAPP</property>
        <property name="hibernate.connection.password">ICMAPP</property>
        <property name="show_sql">true</property>
        <mapping class="com.xxxx.top.entity.Release"></mapping>
        <mapping class="com.xxxx.top.entity.Package"></mapping>
        <mapping class="com.xxxx.top.entity.Top"></mapping>
        <mapping class="com.xxxx.top.entity.PortAssignment"></mapping>
      </session-factory>
    </hibernate-configuration>
    
    1. desc package_portassignment;提供输出。这样确认表存在。

    2. 控制台日志

    3. . . .
      22:03:02.239 [main] DEBUG org.hibernate.cfg.Configuration - Session-factory config [null] named class [com.xxxx.top.entity.Release] for mapping
      22:03:03.031 [main] DEBUG org.hibernate.cfg.Configuration - Session-factory config [null] named class [com.xxxx.top.entity.Package] for mapping
      22:03:03.589 [main] DEBUG org.hibernate.cfg.Configuration - Session-factory config [null] named class [com.xxxx.top.entity.Top] for mapping
      22:03:04.076 [main] DEBUG org.hibernate.cfg.Configuration - Session-factory config [null] named class [com.xxxx.top.entity.PortAssignment] for mapping
      22:03:04.080 [main] INFO  org.hibernate.cfg.Configuration - HHH000041: Configured SessionFactory: null
      . . .
      22:03:13.287 [main] DEBUG org.hibernate.cfg.Configuration - Processing hbm.xml files
      22:03:13.287 [main] DEBUG org.hibernate.cfg.Configuration - Process annotated classes
      22:03:13.305 [main] DEBUG org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: com.xxxx.top.entity.Release
      22:03:13.415 [main] DEBUG org.hibernate.cfg.Ejb3Column - Binding column: Ejb3DiscriminatorColumn{logicalColumnName'DTYPE', discriminatorTypeName='string'}
      22:03:13.422 [main] DEBUG org.hibernate.cfg.AnnotationBinder - No value specified for 'javax.persistence.sharedCache.mode'; using UNSPECIFIED
      22:03:13.450 [main] DEBUG o.h.cfg.annotations.EntityBinder - Import with entity name Release
      22:03:13.470 [main] DEBUG o.h.cfg.annotations.EntityBinder - Bind entity com.xxxx.top.entity.Release on table release_release
      22:03:13.567 [main] DEBUG org.hibernate.cfg.Ejb3Column - Binding column: Ejb3Column{table=org.hibernate.mapping.Table(release_release), mappingColumn=id, 
      . . .
      22:03:13.646 [main] DEBUG org.hibernate.cfg.Ejb3Column - Binding column: Ejb3DiscriminatorColumn{logicalColumnName'DTYPE', discriminatorTypeName='string'}
      22:03:13.646 [main] DEBUG org.hibernate.cfg.AnnotationBinder - No value specified for 'javax.persistence.sharedCache.mode'; using UNSPECIFIED
      22:03:13.646 [main] DEBUG o.h.cfg.annotations.EntityBinder - Import with entity name Package
      22:03:13.647 [main] DEBUG o.h.cfg.annotations.EntityBinder - Bind entity com.xxxx.top.entity.Package on table package_package
      . . .
      22:03:13.699 [main] DEBUG org.hibernate.cfg.AnnotationBinder - No value specified for 'javax.persistence.sharedCache.mode'; using UNSPECIFIED
      22:03:13.699 [main] DEBUG o.h.cfg.annotations.EntityBinder - Import with entity name Top
      22:03:13.700 [main] DEBUG o.h.cfg.annotations.EntityBinder - Bind entity com.xxxx.top.entity.Top on table top_top
      22:03:13.710 [main] DEBUG org.hibernate.cfg.Ejb3Column - Binding column: Ejb3Column{table=org.hibernate.mapping.Table(top_top), mappingColumn=id, insertable=true, updatable=true, unique=true}
      . . .
      22:03:13.719 [main] DEBUG org.hibernate.cfg.AnnotationBinder - No value specified for 'javax.persistence.sharedCache.mode'; using UNSPECIFIED
      22:03:13.719 [main] DEBUG o.h.cfg.annotations.EntityBinder - Import with entity name PortAssignment
      22:03:13.719 [main] DEBUG o.h.cfg.annotations.EntityBinder - Bind entity com.xxxx.top.entity.PortAssignment on table package_portassignment
      FATAL exception is thrown here
      
      1. 新添加的实体类
      2. PortAssignment.java。无法在这个问题中发布它,因为stackoverflow让我对格式化感到非常悲痛。

1 个答案:

答案 0 :(得分:0)

我重新编写了新类,错误消失了。我承认,我很尴尬,但我认为注释Column(name=...)中的一个属性存在拼写错误。

假设这导致Hibernate的一个内部类(特别是NullPointerException)中出现org.hibernate.annotations.common.reflection.XClass.getDeclaredProperties

感谢Channa Jayamuni的想法。

相关问题