You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Brad <cf...@javawork.co.uk> on 2008/05/02 16:40:52 UTC

Intermittent NullPointerException in JAXRSUtils

Hi,

I'm seeing an intermittent problem where I get a NPE at JAXRSUtils:513:

        List<String> results = values.get(parameterName);
        if (values != null && values.size() > 0) {
            result = results.get(results.size() - 1);  <<<<<<<<<<<<<<<<<<here
        }

I've stepped through the code and it looks like its going to work but
then it goes round a second time and results is NULL. Here's my class:

@Path(value="/{domain}/{network}/{user}/mail")
public class MailService {

	@GET
	@ConsumeMime({"application/xml", "application/json"})
	@ProduceMime({"application/xml", "application/json"})
	public MailFolderDocument listMail(@PathParam("domain")String domain,
@PathParam("network")String network, @PathParam("user")String user,
@HeaderParam("token")String token){
            ....
        }

	@Path(value="{messageId}", limited=true)
	@GET
	@ConsumeMime({"application/xml", "application/json"})
	@ProduceMime({"application/xml", "application/json"})
	public MessageDocument readMessage(@PathParam("user")String user,
@PathParam("messageId")String messageId, @HeaderParam("token")String
token){
            ....
        }

}

When I hit http://localhost:8080/cxf/rest/test/domain/network/brad/mail
it hits the breakpoint and in the variables I can see path="/" and
parameterName=""user". It then hits that line again and this time
path="/", parameterName="messageId" and results=null.

I'm assuming there's something not quite right with my annotations
which is causing it to mix the methods up?

Thanks,
Brad.

Re: Intermittent NullPointerException in JAXRSUtils

Posted by Brad <cf...@javawork.co.uk>.
Issue create in JIRA with patch attached:

    http://issues.apache.org/jira/browse/CXF-1570

Brad

On Fri, May 2, 2008 at 5:37 PM, Sergey Beryozkin
<se...@iona.com> wrote:
> Many thanks Brad, if you don't get a chance to to do early next week then
> I'll do it once I set up an account, there're delays there due to the apache
> team working with hardware failures..
>
>
>  Cheers, Sergey
>
>
>
>  ----- Original Message ----- From: "Brad" <cf...@javawork.co.uk>
>  To: "Sergey Beryozkin" <se...@iona.com>
>  Sent: Friday, May 02, 2008 5:03 PM
>
>
>  Subject: Re: Intermittent NullPointerException in JAXRSUtils
>
>
>
> > Sergey,
> >
> > sure, no problem. It will have to wait until Monday but happy to do it.
> >
> > Cheers,
> > Brad.
> >
> > On Fri, May 2, 2008 at 4:47 PM, Sergey Beryozkin
> > <se...@iona.com> wrote:
> >
> > > Hi Brad,
> > >
> > >
> > >
> > > > well spotted. I made the change locally and it all works fine now.
> > > >
> > >
> > >  Fancy creating a patch :-) ? If you're on windows then there's an
> option
> > > there 'CreatePatch' so you create it and then attach it to a newly
> created
> > > JIRA. I can do this fix myself, but I guess it would be better if people
> who
> > > found the issue and fixed it, like yourself in this case, started
> > > accumulating patch points...I don't think tests are even needed in this
> > > case...
> > >
> > >  Let me know please if you can create a patch...If you're busy, then
> it's
> > > fine, I'll do it myself in the next few weeks, I still haven't set up my
> > > commiter account though...
> > >
> > >  Cheers, Sergey
> > >
> > >  ----- Original Message ----- From: "Brad" <cf...@javawork.co.uk>
> > >  To: "Sergey Beryozkin" <se...@iona.com>
> > >  Sent: Friday, May 02, 2008 4:14 PM
> > >  Subject: Re: Intermittent NullPointerException in JAXRSUtils
> > >
> > >
> > >
> > >
> > >
> > > > Hi Sergey,
> > > >
> > > > well spotted. I made the change locally and it all works fine now.
> > > >
> > > > Always good to finish the week with a success :-)
> > > >
> > > > Cheers,
> > > > Brad.
> > > >
> > > > On Fri, May 2, 2008 at 3:58 PM, Sergey Beryozkin
> > > > <se...@iona.com> wrote:
> > > >
> > > > > Hi Brad
> > > > >
> > > > >
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I'm seeing an intermittent problem where I get a NPE at
> > > JAXRSUtils:513:
> > > > > >
> > > > > >       List<String> results = values.get(parameterName);
> > > > > >       if (values != null && values.size() > 0) {
> > > > > >           result = results.get(results.size() - 1);
> > > > > <<<<<<<<<<<<<<<<<<here
> > > > > >       }
> > > > > >
> > > > >
> > > > >
> > > > >  This code looks a bit broken  :-) Seems like 'values' needs to be
> > > replaced
> > > > > with 'results' in the 'if' loop,
> > > > >  it probably works just by chance at the moment. Can you please try
> and
> > > > > update the 'if' loop and recompile ?
> > > > >
> > > > >  I'll update this code on the trunk later anyway...
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > >
> > > > > > I've stepped through the code and it looks like its going to work
> but
> > > > > > then it goes round a second time and results is NULL. Here's my
> class:
> > > > > >
> > > > > > @Path(value="/{domain}/{network}/{user}/mail")
> > > > > > public class MailService {
> > > > > >
> > > > > > @GET
> > > > > > @ConsumeMime({"application/xml", "application/json"})
> > > > > > @ProduceMime({"application/xml", "application/json"})
> > > > > > public MailFolderDocument listMail(@PathParam("domain")String
> domain,
> > > > > > @PathParam("network")String network, @PathParam("user")String
> user,
> > > > > > @HeaderParam("token")String token){
> > > > > >           ....
> > > > > >       }
> > > > > >
> > > > >
> > > > >  This method seems fine...
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > >
> > > > > > @Path(value="{messageId}", limited=true)
> > > > > > @GET
> > > > > > @ConsumeMime({"application/xml", "application/json"})
> > > > > > @ProduceMime({"application/xml", "application/json"})
> > > > > > public MessageDocument readMessage(@PathParam("user")String user,
> > > > > > @PathParam("messageId")String messageId,
> @HeaderParam("token")String
> > > > > > token){
> > > > > >
> > > > >
> > > > >
> > > > >  should be fine too, provided that
> > > > >
> > > > >  /{domain}/{network}/{user}/mail/{messageId} requests are targeted
> at
> > > this
> > > > > method, somethink like
> > > > >  /aDomain/aNetwork/foo/mail/12345...
> > > > >
> > > > >
> > > > >
> > > > > >           ....
> > > > > >       }
> > > > > >
> > > > > > }
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > >
> > > > > > When I hit
> > > http://localhost:8080/cxf/rest/test/domain/network/brad/mail
> > > > > > it hits the breakpoint and in the variables I can see path="/" and
> > > > > > parameterName=""user". It then hits that line again and this time
> > > > > > path="/", parameterName="messageId" and results=null.
> > > > > >
> > > > > > I'm assuming there's something not quite right with my annotations
> > > > > > which is causing it to mix the methods up?
> > > > > >
> > > > >
> > > > >  Most likely there's something not quite right with the above code
> in
> > > > > JAXRSUtils :-)
> > > > >
> > > > >  Thanks, Sergey
> > > > >
> > > > >
> > > > > >
> > > > > > Thanks,
> > > > > > Brad.
> > > > > >
> > > > >
> > > > >  ----------------------------
> > > > >  IONA Technologies PLC (registered in Ireland)
> > > > >  Registered Number: 171387
> > > > >  Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> > > Ireland
> > > > >
> > > > >
> > > >
> > >
> > >  ----------------------------
> > >  IONA Technologies PLC (registered in Ireland)
> > >  Registered Number: 171387
> > >  Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> Ireland
> > >
> > >
> >
>
>  ----------------------------
>  IONA Technologies PLC (registered in Ireland)
>  Registered Number: 171387
>  Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>

Re: Intermittent NullPointerException in JAXRSUtils

Posted by Sergey Beryozkin <se...@iona.com>.
Hi Brad

> Hi,
> 
> I'm seeing an intermittent problem where I get a NPE at JAXRSUtils:513:
> 
>        List<String> results = values.get(parameterName);
>        if (values != null && values.size() > 0) {
>            result = results.get(results.size() - 1);  <<<<<<<<<<<<<<<<<<here
>        }


This code looks a bit broken  :-) Seems like 'values' needs to be replaced with 'results' in the 'if' loop,
it probably works just by chance at the moment. Can you please try and update the 'if' loop and recompile ?
 
I'll update this code on the trunk later anyway...



> 
> I've stepped through the code and it looks like its going to work but
> then it goes round a second time and results is NULL. Here's my class:
> 
> @Path(value="/{domain}/{network}/{user}/mail")
> public class MailService {
> 
> @GET
> @ConsumeMime({"application/xml", "application/json"})
> @ProduceMime({"application/xml", "application/json"})
> public MailFolderDocument listMail(@PathParam("domain")String domain,
> @PathParam("network")String network, @PathParam("user")String user,
> @HeaderParam("token")String token){
>            ....
>        }

This method seems fine...


> 
> @Path(value="{messageId}", limited=true)
> @GET
> @ConsumeMime({"application/xml", "application/json"})
> @ProduceMime({"application/xml", "application/json"})
> public MessageDocument readMessage(@PathParam("user")String user,
> @PathParam("messageId")String messageId, @HeaderParam("token")String
> token){


should be fine too, provided that

/{domain}/{network}/{user}/mail/{messageId} requests are targeted at this method, somethink like
/aDomain/aNetwork/foo/mail/12345...
 
>            ....
>        }
> 
> }


> 
> When I hit http://localhost:8080/cxf/rest/test/domain/network/brad/mail
> it hits the breakpoint and in the variables I can see path="/" and
> parameterName=""user". It then hits that line again and this time
> path="/", parameterName="messageId" and results=null.
> 
> I'm assuming there's something not quite right with my annotations
> which is causing it to mix the methods up?

Most likely there's something not quite right with the above code in JAXRSUtils :-)

Thanks, Sergey

> 
> Thanks,
> Brad.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: Intermittent NullPointerException in JAXRSUtils

Posted by Brad <cf...@javawork.co.uk>.
If it helps, here's my request from TCPMon

GET /cxf/rest/test/domain/network/brad/mail HTTP/1.1
User-Agent: curl/7.18.1 (i386-pc-win32) libcurl/7.18.1 OpenSSL/0.9.8g
zlib/1.2.3 libssh2/0.18
Host: localhost:8081
Accept: application/xml
Content-type: application/xml
token: brad:secret:expiry:type

Service monitoring

Posted by "Shaw, Richard A" <ri...@atkinsglobal.com>.
I have a service which contains a quartz timer and and everytime it fires it requests data from another CXF service. Sometimes it starts reporting connection errors when talking to the service or simply stops alltogether. 

My question is - what is the best way to monitor that my service is still running ? 

Requesting the WSDL tells me something is still alive but not necessarily the complete service.  

I can trap the connection errors and send a message (or write to DB) when this occurs and monitor that. But I don't think this will get all my failures.

I could update a timestamp in a DB after every execution and monitor the DB for lack of update.

Any ideas ? Is there something else I could do ?

BTW my error is usually "sun.reflect.GeneratedMethodAccessor19 invoke
WARNING: dispatch failed!" And I haven't been able to discover what it means - I asked you guys before and nobody else knew either.



Richard Shaw

¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤

Richard Shaw  
Technical Design Authority - Information Solutions Consultancy  
Intelligent Transport Systems 

Atkins Highways and Transportation 
Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW

Tel: +44 (0) 1372 756407 
Fax: +44 (0) 1372 740055
Mob: 07740 817586 
E-mail: richard.shaw@atkinsglobal.com

www.atkinsglobal.com/its


This email and any attached files are confidential and copyright protected. If you are not the addressee, any dissemination of this communication is strictly prohibited. Unless otherwise expressly agreed in writing, nothing stated in this communication shall be legally binding.

The ultimate parent company of the Atkins Group is WS Atkins plc.  Registered in England No. 1885586.  Registered Office Woodcote Grove, Ashley Road, Epsom, Surrey KT18 5BW. A list of wholly owned Atkins Group companies registered in the United Kingdom can be found at http://www.atkinsglobal.com/terms_and_conditions/index.aspx

Consider the environment. Please don't print this e-mail unless you really need to.