You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by James Black <jb...@ieee.org> on 2004/01/01 17:22:13 UTC

RE: null pointer problem in both 1.1 and 1.2alpha

> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Wednesday, December 31, 2003 3:21 PM
> To: axis-user@ws.apache.org
> Subject: Re: null pointer problem in both 1.1 and 1.2alpha
> 
> Just a follow-up to this...
> 
> I did a test with a web service I've verified to work.  Basically, it is
> the
> same as one would create after following this tutorial...
> http://www.relevancellc.com/hands-on/MagicBall/
> 
> It's one and only service method is askQuestion(String).  It takes a
> String and
> returns and String.  Like I said, this works fine.
> 
> I then modified it to take two int parameters in addition to the String.
> I do
> nothing with them except add them to the interface.  So now I have
> askQuestion
> (String, int, int).  Just to be safe, I deleted my previous Axis webapp
> and put
> a fresh one in webapps and restarted Tomcat5.  I deployed the service
> fine, but
> then when I tried to access the service with my client, I got exactly the
> same
> exception as I originally reported.  This is entirely consistent the error
> in
> my other web service since it also took a String a two int parameters.
> 
> So, what's the deal?  Can't I pass int's as parameters in a web service?
> Am I
> missing something here?

  What do you pass as the string input?

  Are you using Junit to test your client side, and have you already done
unit tests on the server stub to ensure that that is working? The problem
may be happening on the server side and you are just picking up the null
pointer exception.

" Work like you don't need the money, love like you've never been hurt, and
dance like no one is watching." 
            --- Satchel Paige 



RE: null pointer problem in both 1.1 and 1.2alpha

Posted by James Black <jb...@ieee.org>.
> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Friday, January 02, 2004 12:02 PM
> To: axis-user@ws.apache.org
> Subject: RE: null pointer problem in both 1.1 and 1.2alpha
> 
> Actually, the only unit test I used was the one provided by the tutorial.
> I
> have not written a unit test for anything else.  My observation is
> strictly
> limited to my manual testing of the web service.  askQuestion(String)
> works
> perfectly, and askQuestion(String, int) fails with the null pointer
> exception
> that I posted when running a simple client that I wrote.

  You should write a unit test for the server stub, and then one for the
client side, as that way you can get better info as to what is going on.

> Is it possible that differences in options I provide to java2wsdl and
> wsdl2java
> ant tasks might make a difference?  Would it help if I posted the wsdl
> generated by Axis?  I really have very little idea of where to look for
> the
> cause of this issue as I am pretty new to Axis and webservices in general
> and I
> am not doing anything fancy here anyway.

  It would depend on how different the options you pass are.

  I haven't tried 1.2alpha yet as I finally got everything working with
jdk1.5alpha and ant1.6. I figure next week I will try axis 1.2 and see if
all my unit tests pass.

" Work like you don't need the money, love like you've never been hurt, and
dance like no one is watching." 
            --- Satchel Paige


RE: null pointer problem in both 1.1 and 1.2alpha

Posted by Jacob Kjome <ho...@visi.com>.
Quoting James Black <jb...@ieee.org>:

> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: Thursday, January 01, 2004 1:33 PM
> > To: axis-user@ws.apache.org
> > Subject: RE: null pointer problem in both 1.1 and 1.2alpha
> >
> > Based on the fact that the service works perfectly with
> > askQuestion(String)
> > but fails with a null pointer exceptions simply by using
> > askQuestion(String, int), the only conclusion I can draw is that Axis
> > doesn't support int parameters.  But that just can't be true, can
> > it?  Someone out there has to be using int parameters in their webservice
> > methods.  I've got to be missing something glaringly obvious.... or Axis
> > has a serious bug, but I would think it would have bitten a lot of people
> > so that the answer to my question would be obvious by now.  Any further
> > help is very much appreciated!
> 
>   I know that axis supports ints as my web services use them. <g>
> 
>   I use junit extensively in my development, and one thing I found very
> helpful is to write a separate unit test for the server stub, then for the
> client side (the client side actually connects to the server).  It sounds
> like you sre using httpunit for the client side, and you may want to use
> junit.
> 
>   Your project is actually something that would be very useful, so I hope
> this problem can be figured out.
> 
>   Is it possible that httpunit could be causing the problem? You may want to
> explain more about your test procedure, and perhaps include the source code
> for unit test that is causing the problem.
>   I have never tried using httpunit for testing the client side, but that
> would imply that you are using some sort of cgi program, which wouldn't make
> sense, since we are using webservices.
> 

Actually, the only unit test I used was the one provided by the tutorial.  I 
have not written a unit test for anything else.  My observation is strictly 
limited to my manual testing of the web service.  askQuestion(String) works 
perfectly, and askQuestion(String, int) fails with the null pointer exception 
that I posted when running a simple client that I wrote.

Is it possible that differences in options I provide to java2wsdl and wsdl2java 
ant tasks might make a difference?  Would it help if I posted the wsdl 
generated by Axis?  I really have very little idea of where to look for the 
cause of this issue as I am pretty new to Axis and webservices in general and I 
am not doing anything fancy here anyway.

Well, I'll go ahead and attach a zip file with the full working build and 
copies of both generated wsdl files.  
Maybe someone will see something that looks like it might be suspect.

Note again, that this is all based on the tutorial at...
http://www.relevancellc.com/hands-on/MagicBall/

The build assumes that a "axis-1_2alpha" directory exists in the root of the 
buld so you'll have to provide that (or change the axis.home property to point 
to your copy of 1.1 or 1.2alpha).  To generate the wsdl and java, compile, and 
deploy the web service, just type "ant deploy-server".  Then you'll need to 
build the client by typing "ant compile-client".  Then run the class located 
in "client/classes" (source is in "client/src") and supply the information it 
requests.  You should see the null pointer exception that I posted previously.  

To see it working, just modify the MagicBall classes to not take the extra int 
parameter.  Do an "ant clean" and all the above again and it should now work 
perfectly.

It would be excellent if someone with more knowlege of Axis could verify this 
problem.  Again, maybe I'm just missing something painfully obvious to a more 
experienced user.

Thanks,

Jake

RE: null pointer problem in both 1.1 and 1.2alpha

Posted by James Black <jb...@ieee.org>.
> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Thursday, January 01, 2004 1:33 PM
> To: axis-user@ws.apache.org
> Subject: RE: null pointer problem in both 1.1 and 1.2alpha
> 
> Based on the fact that the service works perfectly with
> askQuestion(String)
> but fails with a null pointer exceptions simply by using
> askQuestion(String, int), the only conclusion I can draw is that Axis
> doesn't support int parameters.  But that just can't be true, can
> it?  Someone out there has to be using int parameters in their webservice
> methods.  I've got to be missing something glaringly obvious.... or Axis
> has a serious bug, but I would think it would have bitten a lot of people
> so that the answer to my question would be obvious by now.  Any further
> help is very much appreciated!

  I know that axis supports ints as my web services use them. <g>

  I use junit extensively in my development, and one thing I found very
helpful is to write a separate unit test for the server stub, then for the
client side (the client side actually connects to the server).  It sounds
like you sre using httpunit for the client side, and you may want to use
junit.

  Your project is actually something that would be very useful, so I hope
this problem can be figured out.

  Is it possible that httpunit could be causing the problem? You may want to
explain more about your test procedure, and perhaps include the source code
for unit test that is causing the problem.
  I have never tried using httpunit for testing the client side, but that
would imply that you are using some sort of cgi program, which wouldn't make
sense, since we are using webservices.

" Work like you don't need the money, love like you've never been hurt, and
dance like no one is watching." 
            --- Satchel Paige


RE: null pointer problem in both 1.1 and 1.2alpha

Posted by Jacob Kjome <ho...@visi.com>.
At 11:22 AM 1/1/2004 -0500, you wrote:
> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: Wednesday, December 31, 2003 3:21 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: null pointer problem in both 1.1 and 1.2alpha
> >
> > Just a follow-up to this...
> >
> > I did a test with a web service I've verified to work.  Basically, it is
> > the
> > same as one would create after following this tutorial...
> > http://www.relevancellc.com/hands-on/MagicBall/
> >
> > It's one and only service method is askQuestion(String).  It takes a
> > String and
> > returns and String.  Like I said, this works fine.
> >
> > I then modified it to take two int parameters in addition to the String.
> > I do
> > nothing with them except add them to the interface.  So now I have
> > askQuestion
> > (String, int, int).  Just to be safe, I deleted my previous Axis webapp
> > and put
> > a fresh one in webapps and restarted Tomcat5.  I deployed the service
> > fine, but
> > then when I tried to access the service with my client, I got exactly the
> > same
> > exception as I originally reported.  This is entirely consistent the error
> > in
> > my other web service since it also took a String a two int parameters.
> >
> > So, what's the deal?  Can't I pass int's as parameters in a web service?
> > Am I
> > missing something here?
>
>   What do you pass as the string input?
>
>   Are you using Junit to test your client side, and have you already done
>unit tests on the server stub to ensure that that is working? The problem
>may be happening on the server side and you are just picking up the null
>pointer exception.
>

As I said before, When I had my service take only a String parameter, it 
worked perfectly fine.  The Unit test worked and actually running the web 
service worked.  I would pass a yes/no question such as "Are you cool?" and 
it would spit back one of its various magic ball answers (eg.  "yes", "no", 
"maybe", etc....).  I had no problems whatsoever until...

I added an int parameter to the askQuestion() method so it now looks like 
askQuestion(String, int).  I changed all references to this to pass "1" 
(less the quotes, of course).  I then called it just as explained above 
with the only difference being that I'm passing an int value (that I'm not 
even using inside the web service).  And then *bang*, I get the null 
pointer exception reported.

BTW, the stack trace was copied from the server log, not the client so, 
yes, it is definitely happening server-side and, from what I can tell, 
somewhere inside the guts of Axis or the VM.  The service method doesn't 
even get called.

Based on the fact that the service works perfectly with askQuestion(String) 
but fails with a null pointer exceptions simply by using 
askQuestion(String, int), the only conclusion I can draw is that Axis 
doesn't support int parameters.  But that just can't be true, can 
it?  Someone out there has to be using int parameters in their webservice 
methods.  I've got to be missing something glaringly obvious.... or Axis 
has a serious bug, but I would think it would have bitten a lot of people 
so that the answer to my question would be obvious by now.  Any further 
help is very much appreciated!

thanks,

Jake