Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Null pointer exception

Reply
Thread Tools

Null pointer exception

 
 
Roedy Green
Guest
Posts: n/a
 
      08-17-2005
On 17 Aug 2005 06:46:39 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote or quoted :

>- Does the 787 refer to a line number?
>- What's the best way to begin debugging this?


yes. See
http://mindprod.com/jgloss/runerrorm...INTEREXCEPTION
 
Reply With Quote
 
 
 
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      08-17-2005
(E-Mail Removed) writes:

> - Does the 787 refer to a line number?


Yes.

> - What's the best way to begin debugging this?


Look for uses of the . operator; something in front of a . is null.
Try adding some tests for null.
 
Reply With Quote
 
 
 
 
Babu Kalakrishnan
Guest
Posts: n/a
 
      08-17-2005
(E-Mail Removed) wrote:
> I am having similar error messages that look like this:
>
> java.lang.NullPointerException at euwPledge.doGet(Unknown Source) at
> javax.servlet.http.HttpServlet.service(HttpServlet .java:787)
>
> Being new to Java, I have a few questions:
>
> - Does the 787 refer to a line number?
> - What's the best way to begin debugging this?
> - What other information can I post here that would help get to the
> root of the problem?
>


Yes - 787 indeed refers to a line number - but unfortunately it doesn't
tell you where the real problem lies - so no point starting your
debugging from there.

Make sure you compile the application with debugging informaton enabled.
If you're using plain javac for the compilation, the -g switch ought to
do it. If you're using an IDE, you'll need to find out the exact means
to enable it by looking at the documentation. (Most IDEs have it turned
on by default)

In any case, the "Unknown source" message generally means that that the
compilation was done with debugging set to none, and that's something
you don't ever want to do in the development phase of a project. (Very
similar to the try{..some code..} catch (Exception e) {} stuff you see
in a lot of code. In my view, if an exception occurred, you want to know
what it was and figure out why it occurred - no point hiding it)

BK
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      08-17-2005
On Wed, 17 Aug 2005 22:55:17 +0530, Babu Kalakrishnan wrote:

> ...(Very
> similar to the try{..some code..} catch (Exception e) {} stuff you see
> in a lot of code. In my view, if an exception occurred, you want to know
> what it was and figure out why it occurred - no point hiding it)


Or, to put that in more words (with lots more colors) ..
<http://www.physci.org/codes/javafaq.jsp#stacktrace>

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"We're gonna' fuss and fight till daylight."
Koko Taylor 'Wang Dang Doodle'
 
Reply With Quote
 
Andrea Desole
Guest
Posts: n/a
 
      08-18-2005


(E-Mail Removed) wrote:
> I am having similar error messages that look like this:
>
> java.lang.NullPointerException at euwPledge.doGet(Unknown Source) at
> javax.servlet.http.HttpServlet.service(HttpServlet .java:787)
>
> Being new to Java, I have a few questions:
>
> - Does the 787 refer to a line number?


yes (as everyone else said already)

> - What's the best way to begin debugging this?


if you want to use a real debugger, that can be a bit difficult. You
basically have to debug the entire application server. I have never used
iPlanet, so I don't know how to do that exaactly. The easiest thing I
can recommend is to find in the documentation how to start iPlanet in
debug mode, or how to set the flags used by the server virtual machine
when it's started. If you don't know what flags to use, you can easily
find them in the JDK documentation (search for the Xdebug and Xrunjdwp
options for the java command). If you succeed in starting the virtual
machine with the debug options, you can attach a debugger to it. Which
debugger is your choice.
Anyway, for the moment I would use normal log messages, as you have been
doing so far.


> - What other information can I post here that would help get to the
> root of the problem?


1) John is right: a class cast doesn't affect the getClass method
2) I noticed that in the stack trace you have euwPledge.doGet, instead
of TestClass.foo. I also noticed that in your JSP you call c.foo()
instead of c.foo(String), which means you shouldn't even able to compile
your JSP

So, if I'm not missing anything, I think you should really look at your
code.
If I'm missing something (besides the fact that I would like to know
what) you can try to dump the following values:

((com.netscape.server.jdbc.ConnectionProxy)c).getC lass()
c.getClass()

they should give you the same value
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-20-2005
On Wed, 17 Aug 2005 22:55:17 +0530, Babu Kalakrishnan
<(E-Mail Removed)> wrote or quoted :

>In any case, the "Unknown source" message generally means that that the
>compilation was done with debugging set to none, and that's something
>you don't ever want to do in the development phase of a project.


Another explanation is that it occurred in Sun's code. You have to
look where you called sun's code. You likely passed it a null
parameter.

Someone pointed out recently that the JDK private JRE has debug turned
on and the public one has it turned off.
 
Reply With Quote
 
dennishancy@eaton.com
Guest
Posts: n/a
 
      08-29-2005
In my continued attempts to figure out what's wrong with this, I've
noticed something else.

If I am logged into my application, then I get that nullPointer java
error when I click on the link.

However, if I am Not logged in, and key in the URL of the link directly
into my browser, the information shows up as expected.

Not sure what this means, but thought it might be useful information in
trying to figure this out.

Something is being set when logging out that enables the link to work.
But what could that be??


Dennis


Andrea Desole wrote:
> (E-Mail Removed) wrote:
> > I am having similar error messages that look like this:
> >
> > java.lang.NullPointerException at euwPledge.doGet(Unknown Source) at
> > javax.servlet.http.HttpServlet.service(HttpServlet .java:787)
> >
> > Being new to Java, I have a few questions:
> >
> > - Does the 787 refer to a line number?

>
> yes (as everyone else said already)
>
> > - What's the best way to begin debugging this?

>
> if you want to use a real debugger, that can be a bit difficult. You
> basically have to debug the entire application server. I have never used
> iPlanet, so I don't know how to do that exaactly. The easiest thing I
> can recommend is to find in the documentation how to start iPlanet in
> debug mode, or how to set the flags used by the server virtual machine
> when it's started. If you don't know what flags to use, you can easily
> find them in the JDK documentation (search for the Xdebug and Xrunjdwp
> options for the java command). If you succeed in starting the virtual
> machine with the debug options, you can attach a debugger to it. Which
> debugger is your choice.
> Anyway, for the moment I would use normal log messages, as you have been
> doing so far.
>
>
> > - What other information can I post here that would help get to the
> > root of the problem?

>
> 1) John is right: a class cast doesn't affect the getClass method
> 2) I noticed that in the stack trace you have euwPledge.doGet, instead
> of TestClass.foo. I also noticed that in your JSP you call c.foo()
> instead of c.foo(String), which means you shouldn't even able to compile
> your JSP
>
> So, if I'm not missing anything, I think you should really look at your
> code.
> If I'm missing something (besides the fact that I would like to know
> what) you can try to dump the following values:
>
> ((com.netscape.server.jdbc.ConnectionProxy)c).getC lass()
> c.getClass()
>
> they should give you the same value


 
Reply With Quote
 
Andrea Desole
Guest
Posts: n/a
 
      08-29-2005


(E-Mail Removed) wrote:
> In my continued attempts to figure out what's wrong with this, I've
> noticed something else.
>
> If I am logged into my application, then I get that nullPointer java
> error when I click on the link.
>
> However, if I am Not logged in, and key in the URL of the link directly
> into my browser, the information shows up as expected.
>
> Not sure what this means, but thought it might be useful information in
> trying to figure this out.
>
> Something is being set when logging out that enables the link to work.
> But what could that be??


If I'm not wrong this is the first time you mention log in and log out,
and a link. What's the value of the url of the link? How does the
application find out what the url is? And waht kind of information is
expected?
The information you gave is a bit incomplete and inconsistent. The
example you gave seems a good idea, but it just doesn't match. Even
assuming that this euwPledge you are calling is something internal in
iPlanet, you are still calling a method from your JSP that doesn't
exist. That might mean that you posted the wrong code, but also that you
have some problems with your classpath.
Maybe you should give one easy, clear, correct, readable piece of code,
with the necessary information.
And, to answer your last question: the way I look at it a relationship
with a log in/log out procedure looks unlikely, but, since I don't know
what is going on, I might (very roughly) guess that something is wrong
in processing some session scoped information that is added when someone
logs in, and is used to get the url that is used to build the link.
 
Reply With Quote
 
John Currier
Guest
Posts: n/a
 
      08-30-2005
Did you ever look at what's at line 29 of
helper.DBConnectionHelper.java? As I said on July 26th, that's the
line that you should be looking at.

John Currier
http://schemaspy.sourceforge.net

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to pointer intialize to NULL but still point to NULL Christopher C++ 4 07-09-2011 12:35 AM
Null pointer (NULL array pointer is passed) aneuryzma C++ 3 06-16-2008 05:48 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
NULL macro vs. 0 as null pointer? Ken C++ 69 07-31-2004 04:45 AM
Followup: NULL macro vs. 0 as null pointer? Ken C++ 5 07-24-2004 04:05 PM



Advertisments