Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NullPointerException

843842Jan 12 2009 — edited Jan 13 2009
Hi Everyone,

my programming experience is from the era that Pascal still was a populair language and object oriented wasn't invented. So you can say that I'm completely illiterate to anything more advanced than an if ... then statement. I am currently trying to get a linux (tomcat-web) server running and up until now it all seemed to work. I've got the following configuration running (among a few other components):
Fedora 10
Apache HTTP 2.2
Tomcat 6
JRE 1.6

After that I started working through a book called "Beginning JSP, JSF and Tomcat Web Development". I managed to compile the java bean and the servlet that's in the first chapter. Now, here's the problem. During compilation of the servlet there was 1 warning.Here it is:
ShoppingServlet.java:20: warning: [unchecked] unchecked cast
found   : java.lang.Object
required: java.util.Vector<ebookshop.Book>
                Vector<Book> shoplist = (Vector<Book>)session.getAttribute("ebookshop.cart");
                                                                          ^
Maybe wrong allready, but I chose to ignore that one. After that I pulled up the application in my webbrowser and pushed the "add to cart" button of my first webapp it gave an error message in my browser:
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
	ebookshop.ShoppingServlet.getBook(ShoppingServlet.java:87)
	ebookshop.ShoppingServlet.doPost(ShoppingServlet.java:58)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
Apache Tomcat/6.0.18
I've tried looking into the code to make some sense of this, but I'm really stuck here. Anyone who wants to offer some help would be more than welcome.

Regards,

Martijn
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2009
Added on Jan 12 2009
6 comments
209 views