Sriram
Sriram

Reputation: 511

com.sun.jdi.InvocationException occurred invoking method in "new Configuration().configure().buildSessionFactory()"

I am seeing NullPointerException when I try to buildSessionFactory. However, on clicking the exception object in Eclipse's debug mode, the message I see is com.sun.jdi.InvocationException occurred invoking method.

I am seeing this behavior only after having introduced a new Entity class. The table to which the class is bound, exists. There are no typos. hibernate.cfg.xml is parsed successfully too. A fatal exception is thrown after hibernate tries to bind the new class to the table.

  1. hibernate.cfg.xml
<?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; gives an output. So that confirms that the table exists.

  2. Console log

. . .
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. The newly added Entity class

PortAssignment.java. Was not able to post it inside this question as stackoverflow was giving me much grief with the formatting.

Upvotes: 1

Views: 2252

Answers (1)

Sriram
Sriram

Reputation: 511

I rewrote the new class and the error disappeared. I admit, I am embarrassed but I think there was a typo in the annotation Column(name=...) for one the properties.

I suppose this caused a NullPointerException in one of the internal classes of Hibernate (specifically org.hibernate.annotations.common.reflection.XClass.getDeclaredProperties).

Thanks Channa Jayamuni for your thoughts.

Upvotes: 0

Related Questions