File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts2: Servlet.service() NullPointer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: Servlet.service() NullPointer" Watch "Struts2: Servlet.service() NullPointer" New topic

Struts2: Servlet.service() NullPointer

Sam Gardner
Ranch Hand

Joined: Jul 22, 2008
Posts: 48
Hey everyone,

I am getting a really bizzare null pointer error, perhaps someone can point me in the right direction here.

this is my Register.action class execute() method:

It throws the error at dbIO.writeUser(...,...) line.

It craps out at the newConnection line, but I have no idea why it would (I've been using the connection code on other projects and it works fine).

Here's the full exception info thrown. I don't know enough about struts yet to figure out why it's doing this, so if anyone could give me a hand I'd much appreciate it.
I'm using the latest Tomcat 6.x build, and deploying with the newest Eclipse Ganymede release.

David Newton

Joined: Sep 29, 2008
Posts: 12617

You don't mention where in the newConnection method it bombs out, not that this is Struts-related at all.

(Not sure why you'd be using the old o.g.m.m.Driver classname, although I know it still works--it's been com.mysql.jdbc.Driver for years now.)
Sam Gardner
Ranch Hand

Joined: Jul 22, 2008
Posts: 48
Ah, I figured it out. You are correct, it wasn't Struts at all - I saw all of the webworks stuff in the exception and assumed incorrectly.

Turns out I forgot to initialize my writer object - it's been a while since I've used java.

Thanks anyway for taking a look,

I agree. Here's the link:
subject: Struts2: Servlet.service() NullPointer
It's not a secret anymore!