wood burning stoves*
The moose likes EJB and other Java EE Technologies and the fly likes NullPointerException while trying to access the entity's particular field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "NullPointerException while trying to access the entity Watch "NullPointerException while trying to access the entity New topic
Author

NullPointerException while trying to access the entity's particular field

yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
Hello all,

I have a table (BaseInfo) which has four fields called Id(primary key), Name, Age and Type. In this, "Type" field is Bigint datatype and it can hold 1 or 2 or null as value.
I have some another table (AdInfo) which refers the BaseInfo's Type field.

I inserted a record in BaseInfo table with the values (1, x, 28, (null)).

I can get the BaseInfo object by finding a record with the primary key "1" with the statement (em.find(BaseInfo.class, 1)).
And also i can print the values of that object except the "Type's value".

System.out.print(BaseInfoObj.getName()); --- Prints the value
System.out.print(BaseInfoObj.getAge()); ---- Prints the value

System.out.print(BaseInfoObj.getType()); ---- prints
javax.ejb.EJBException: java.lang.NullPointerException
ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

Any idea regarding this?

Thank you!


yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
Anybody having any idea about this?

This might be the basic thing but i don't know how to resolve this.
Palash Nandi
Ranch Hand

Joined: Jul 09, 2009
Posts: 34
Hi yuvaraj,
What kind of object is BaseInfoObj, does it have other references inside it, because as as shown by the previous statements its reference cannot be null. I think the method BaseInfoObj.getType() in internally calling some method of another internal reference object inside BaseInfoObj which is null.


A TubeBulb May light slowely... But it lights the Brightest..
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9912
    
158

And please post the entire exception stacktrace.

[My Blog] [JavaRanch Journal]
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
Thanks for your replies. Just now i found the problem (Casting). Fixed.
 
Consider Paul's rocket mass heater.
 
subject: NullPointerException while trying to access the entity's particular field
 
Similar Threads
Inheritance and hibernate mapping issue
EJB3 entity bean
How to do transaction with EJB/JPA and JDBC
Requesting help in connecting a DataSource(DSSDEV)
Two-Phase commit using CMT on JBoss and Oracle XE