This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Null pointer Exception when insert new record to database using struts2 and hibernate3
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Hello every one,
My problem is that , when i am insert a new record to database using struts2 and hibernate3 a null pointer exception is given because my database one id is generate when new record insert which is auto increment when insert new record null id pass and same time file upload to drive successful but record not insert into a Mysql 5.0.5 database my tomcat server gives exception is as follow:
My jsp is:
My struts.xml file is:
My hibernate.cfg.xml is:
My Action class is TenderAction.java
My bean class Tender.java is :
My DAO i.e. database connectivity TenderDAOImpl.java class is:
Please give me solution i am facing that problem from 3 days
Thank you
The stack trace says the problem occurred on line 29 of TenderDAOImpl:
The code you've given us for that class shows a close brace on line 29. Either your code or your stack trace are out of date. Can you give us the current code/stack trace?
In TenderDAOImpl.java i am add candition if (transaction != null) the stack trace or Apache tomcat 7.0 not gives any error but struts.xml file <result name="input"> tag gives same page with no error my dao changes and stack trace/Console is follows
i am past all my code previous post see that and my jar file see then attachement
Never ever Ever EVER do this. If an exception occurs, you'll never know. At the very least, invoke e.printStackTrace().
I'm not sure what I'm supposed to derive from the image that you posted.
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Thank you Joe Ess for reply,
I am write catch() code for exception handling but i am replace that code and write previous but exception is occured as:
joe My TenderDAOImpl.java class is as follow but exception occured at line 29 which transaction.rollback(); i know way error is occured because id which is auto generated when new record is
pass to session.saveOrUpdate(tender); the null id i.e. primary key is passed but when new record insert into database auto increment key is genrated that is reason but how can solve this problem
joe My TenderDAOImpl.java class is as follow but exception occured at line 29 which transaction.rollback();
Then why doesn't transaction.rollback() appear in the stack trace? I still think you have the wrong line.
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Sorry Joe you are right actually some changes in my TenderDAOImpl class so line number 30 is exception occured.
Joe please explain me why this error is occured because same program logic use in that file create to drive not use and my post code drive create file logic use but whithout file create insert record successfully but Posted program not run and gives exception in line number 30
Please reply me.
sudarshan jadhav wrote:
Joe please explain me why this error is occured
This is the third time I'll say it: you haven't shown us the code that corresponds to the error. We can't help you without that.
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
thank you joe for reply,
already i am send to you my exception on jsp page not exception on tomcat console again i am paste jsp page exception and tomcat 7.0 console:
jsp page exception is:
sudarshan jadhav wrote:
Joe please explain me why this error is occured
This is the third fourth time I'll say it: you haven't shown us the code that corresponds to the error. We can't help you without that.
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Hello Joe i am post hole code but some changes into struts.xml file so that new runtime exception show on tomcat console is as follow but my hole code is same but only changes in xml :
My struts.xml is follow:
please please joe see my hole post with exception,java code , jsp and xml mapping file
This used to be a problem with the devmode flag (see here) but should be fixed. Are you using a recent version of Struts?
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Thank you Joe firstly for reply,
i am using struts2.1.6 and hibernate 3.0 i am attaching jar image file with a previous post please see it is right jar file for that version
please reply me for null pointer exception in struts2 . I am setting id with default value but runtime exception is shown on console
If you would have followed the link I posted earlier, you would see that the version of Struts with the devmode problem is 2.1.6, the same version you are running. I recommend you upgrade.
As for the null pointer exception, you STILL haven't shown us the code where the error takes place.
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Thank you joe for link you have suggested to me , but how to upgrade or add that patch file to my jar file please reply me urgently.
Hello Joe still null pointer exception i am added new jar file which are shown me on post attachement file and error code is as:
See my struts.xml file is as:
please joe help me all other code are as previous i am post on it. please suggest some idea because my code right on lt is a any one mapping or jar file missing or not please tell me what is the reason to exception
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
sorry my jar file is as see attachement:
sudarshan jadhav
Ranch Hand
Joined: May 28, 2012
Posts: 41
posted
0
Thank you Joe. my program is run and record insert into database with file upload at a drive. I am remove interceptor tag in struts.xml my record is inserted successfully
But suggest me for file upload 20mb (or file more then 20mb upto the maximum size allowed) to server drive and fileupload tag is required for struts.xml
Please joe reply me