java.lang.NullPointerException

Oracle Community | 843798 | 7 years ago
  1. 0

    Can´t get my class loader working - throws NoClassDefFoundError

    Oracle Community | 7 years ago | 843798
    java.lang.NullPointerException
  2. 0

    Getting Exceptions from logs on *nix using sed/awk/whatever

    Stack Overflow | 2 years ago | WrRaThY
    java.lang.NullPointerException
  3. 0

    I've just upgraded from Hibernate 2.1.2 to Hibernate 2.1.3, and am experiencing an issue with a mapping for a Map with a composite-element. When doing an update on my parent object, an exception is thrown that didn't occur in version 2.1.2. However, this exception is only thrown if you use the saveOrUpdateCopy method on the session (which I need for another association, but has been deleted from my simple test case to try simplify the problem). The mapping document is as follows: [code] <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.qxlva.bo.Person" table="PERSON" dynamic-update="false" dynamic-insert="false"> <id name="id" column="PERSON_ID" type="int" unsaved-value="0"> <generator class="native"> </generator> </id> <property name="name" type="string" update="true" insert="true" access="property" column="FULL_NAME" length="20"/> <map name="ownedCars" table="OWNED_CARS" lazy="false" sort="unsorted" inverse="false" cascade="none"> <key column="PERSON_ID"/> <index-many-to-many class="com.qxlva.bo.Car" column="CAR_ID"/> <composite-element class="com.qxlva.bo.CarDetails"> <property name="numberPlate" type="string" update="true" insert="true" access="property" column="NUMBER_PLATE" length="10" not-null="true"/> <property name="colour" type="string" update="true" insert="true" access="property" column="COLOUR" length="20" not-null="true"/> <property name="carTaxDue" type="calendar" update="true" insert="true" access="property" column="CAR_TAX_DUE_DATE" not-null="true"/> <property name="secondHand" type="yes_no" update="true" insert="true" access="property" column="SECOND_HAND"/> </composite-element> </map> </class> </hibernate-mapping> [/code] My java code for updating is: [code] Session hibernateSession = factory.openSession(); Transaction trans = hibernateSession.beginTransaction(); if (updateWithCopy()) { hibernateSession.saveOrUpdateCopy(objectToUpdate); } else { hibernateSession.saveOrUpdate(objectToUpdate); } trans.commit(); hibernateSession.flush(); hibernateSession.close();[/code] The log with the stack trace of the exception is as follows (I've set hibernate.cglib.use_reflection_optimizer to false, to obtain the exception): [code] 12:06:02,671 DEBUG SQL:237 - select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=? Hibernate: select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=? 12:06:02,681 DEBUG BatcherImpl:241 - preparing statement 12:06:02,681 DEBUG IntegerType:46 - binding '55' to parameter: 1 12:06:02,691 DEBUG Loader:197 - processing result set 12:06:02,691 DEBUG Loader:405 - result row: 55 12:06:02,691 DEBUG Loader:536 - Initializing object from ResultSet: 55 12:06:02,701 DEBUG Loader:605 - Hydrating entity: com.qxlva.bo.Car#55 12:06:02,701 DEBUG StringType:68 - returning 'Punto 18' as column: CAR_NAME0_ 12:06:02,711 DEBUG StringType:68 - returning 'GTI Turbo 18' as column: MODEL0_ 12:06:02,711 DEBUG Loader:226 - done processing result set (1 rows) 12:06:02,731 DEBUG BatcherImpl:203 - done closing: 1 open PreparedStatements, 1 open ResultSets 12:06:02,731 DEBUG BatcherImpl:261 - closing statement 12:06:02,741 DEBUG Loader:239 - total objects hydrated: 1 12:06:02,741 DEBUG SessionImpl:2191 - resolving associations for [com.qxlva.bo.Car#55] 12:06:02,751 DEBUG SessionImpl:2215 - done materializing entity [com.qxlva.bo.Car#55] 12:06:02,761 DEBUG Loader:226 - done processing result set (2 rows) 12:06:02,761 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets 12:06:02,771 DEBUG BatcherImpl:261 - closing statement 12:06:02,771 DEBUG SessionImpl:3068 - 1 collections were found in result set 12:06:02,781 DEBUG SessionImpl:3086 - collection fully initialized: [com.qxlva.bo.Person.ownedCars#56] 12:06:02,781 DEBUG SessionImpl:3089 - 1 collections initialized 12:06:02,791 DEBUG SessionImpl:3260 - collection initialized 12:06:02,801 DEBUG Cascades:312 - id unsaved-value: 0 12:06:02,811 DEBUG SessionImpl:1975 - loading [com.qxlva.bo.Car#54] 12:06:02,811 DEBUG SessionImpl:2072 - attempting to resolve [com.qxlva.bo.Car#54] 12:06:02,821 DEBUG SessionImpl:2088 - resolved object in session cache [com.qxlva.bo.Car#54] java.lang.NullPointerException at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96) at net.sf.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:179) at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:205) at net.sf.hibernate.type.ComponentType.copy(ComponentType.java:285) at net.sf.hibernate.type.MapType.copy(MapType.java:52) at net.sf.hibernate.type.TypeFactory.copy(TypeFactory.java:284) at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:4033) at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3971) at com.qxlva.dao.BaseDao.update(BaseDao.java:81) at com.qxlva.dao.BaseDaoTest.testUpdate(BaseDaoTest.java:355) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(Unknown Source)[/code] The database is Oracle 9.2.0.4. I did a check to make sure it wasn't one of the utility JARs causing the problem, but the issue goes away if you use the 2.1.2 version of the Hibernate JAR file.

    Hibernate JIRA | 1 decade ago | Simon Knott
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I've just upgraded from Hibernate 2.1.2 to Hibernate 2.1.3, and am experiencing an issue with a mapping for a Map with a composite-element. When doing an update on my parent object, an exception is thrown that didn't occur in version 2.1.2. However, this exception is only thrown if you use the saveOrUpdateCopy method on the session (which I need for another association, but has been deleted from my simple test case to try simplify the problem). The mapping document is as follows: [code] <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.qxlva.bo.Person" table="PERSON" dynamic-update="false" dynamic-insert="false"> <id name="id" column="PERSON_ID" type="int" unsaved-value="0"> <generator class="native"> </generator> </id> <property name="name" type="string" update="true" insert="true" access="property" column="FULL_NAME" length="20"/> <map name="ownedCars" table="OWNED_CARS" lazy="false" sort="unsorted" inverse="false" cascade="none"> <key column="PERSON_ID"/> <index-many-to-many class="com.qxlva.bo.Car" column="CAR_ID"/> <composite-element class="com.qxlva.bo.CarDetails"> <property name="numberPlate" type="string" update="true" insert="true" access="property" column="NUMBER_PLATE" length="10" not-null="true"/> <property name="colour" type="string" update="true" insert="true" access="property" column="COLOUR" length="20" not-null="true"/> <property name="carTaxDue" type="calendar" update="true" insert="true" access="property" column="CAR_TAX_DUE_DATE" not-null="true"/> <property name="secondHand" type="yes_no" update="true" insert="true" access="property" column="SECOND_HAND"/> </composite-element> </map> </class> </hibernate-mapping> [/code] My java code for updating is: [code] Session hibernateSession = factory.openSession(); Transaction trans = hibernateSession.beginTransaction(); if (updateWithCopy()) { hibernateSession.saveOrUpdateCopy(objectToUpdate); } else { hibernateSession.saveOrUpdate(objectToUpdate); } trans.commit(); hibernateSession.flush(); hibernateSession.close();[/code] The log with the stack trace of the exception is as follows (I've set hibernate.cglib.use_reflection_optimizer to false, to obtain the exception): [code] 12:06:02,671 DEBUG SQL:237 - select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=? Hibernate: select car0_.CAR_ID as CAR_ID0_, car0_.CAR_NAME as CAR_NAME0_, car0_.MODEL as MODEL0_ from CAR car0_ where car0_.CAR_ID=? 12:06:02,681 DEBUG BatcherImpl:241 - preparing statement 12:06:02,681 DEBUG IntegerType:46 - binding '55' to parameter: 1 12:06:02,691 DEBUG Loader:197 - processing result set 12:06:02,691 DEBUG Loader:405 - result row: 55 12:06:02,691 DEBUG Loader:536 - Initializing object from ResultSet: 55 12:06:02,701 DEBUG Loader:605 - Hydrating entity: com.qxlva.bo.Car#55 12:06:02,701 DEBUG StringType:68 - returning 'Punto 18' as column: CAR_NAME0_ 12:06:02,711 DEBUG StringType:68 - returning 'GTI Turbo 18' as column: MODEL0_ 12:06:02,711 DEBUG Loader:226 - done processing result set (1 rows) 12:06:02,731 DEBUG BatcherImpl:203 - done closing: 1 open PreparedStatements, 1 open ResultSets 12:06:02,731 DEBUG BatcherImpl:261 - closing statement 12:06:02,741 DEBUG Loader:239 - total objects hydrated: 1 12:06:02,741 DEBUG SessionImpl:2191 - resolving associations for [com.qxlva.bo.Car#55] 12:06:02,751 DEBUG SessionImpl:2215 - done materializing entity [com.qxlva.bo.Car#55] 12:06:02,761 DEBUG Loader:226 - done processing result set (2 rows) 12:06:02,761 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets 12:06:02,771 DEBUG BatcherImpl:261 - closing statement 12:06:02,771 DEBUG SessionImpl:3068 - 1 collections were found in result set 12:06:02,781 DEBUG SessionImpl:3086 - collection fully initialized: [com.qxlva.bo.Person.ownedCars#56] 12:06:02,781 DEBUG SessionImpl:3089 - 1 collections initialized 12:06:02,791 DEBUG SessionImpl:3260 - collection initialized 12:06:02,801 DEBUG Cascades:312 - id unsaved-value: 0 12:06:02,811 DEBUG SessionImpl:1975 - loading [com.qxlva.bo.Car#54] 12:06:02,811 DEBUG SessionImpl:2072 - attempting to resolve [com.qxlva.bo.Car#54] 12:06:02,821 DEBUG SessionImpl:2088 - resolved object in session cache [com.qxlva.bo.Car#54] java.lang.NullPointerException at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:96) at net.sf.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:179) at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:205) at net.sf.hibernate.type.ComponentType.copy(ComponentType.java:285) at net.sf.hibernate.type.MapType.copy(MapType.java:52) at net.sf.hibernate.type.TypeFactory.copy(TypeFactory.java:284) at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:4033) at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3971) at com.qxlva.dao.BaseDao.update(BaseDao.java:81) at com.qxlva.dao.BaseDaoTest.testUpdate(BaseDaoTest.java:355) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(Unknown Source)[/code] The database is Oracle 9.2.0.4. I did a check to make sure it wasn't one of the utility JARs causing the problem, but the issue goes away if you use the 2.1.2 version of the Hibernate JAR file.

    Hibernate JIRA | 1 decade ago | Simon Knott
    java.lang.NullPointerException
  6. 0

    Confusing Error/NPE when @DataProvider method is non-static

    GitHub | 2 years ago | seanf
    java.lang.Error: Cannot explode 'ResourceUtilsTest.encodeDocIds' using 'urlPatterns' due to: Exception while invoking dataprovider method 'urlPatterns': null

    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. java.lang.NullPointerException

      No message provided

      at sun.reflect.NativeMethodAccessorImpl.invoke0()
    2. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames