hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39339] New: - java nullpointer exception in URI class as part of call to PostMethod(URI)
Date Tue, 18 Apr 2006 18:12:44 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39339>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39339

           Summary: java nullpointer exception in URI class as part of call
                    to PostMethod(URI)
           Product: HttpClient
           Version: 3.0 Final
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HttpClient
        AssignedTo: httpclient-dev@jakarta.apache.org
        ReportedBy: Mary.Ann.Griffin@mutualofomaha.com


I'm attempting to upgrade to the 3.0 jar.  When I bring this in, I see where 
the classes and methods I'm using are deprecated...but they still exist.  I 
started making coding changes to remove the deprecated classes and when I was 
running I kept getting the error above when I do a PostMethod new PostMethod
(uri) call. I then went back to the original code...no changes to remove 
deprecated classes...and I still get the same error.

The code that is being executed when the error occurs is:

public HttpMethodBase(String uri) 
        throws IllegalArgumentException, IllegalStateException {

        try {

            // create a URI and allow for null/empty uri values
            if (uri == null || uri.equals("")) {
                uri = "/";
            }
            setURI(new URI(uri, true));

It does not appear, from using debug that it ever makes it into the URI class, 
but, rather blows up on the call to the class.

The code I'm executing prior to set up Post Method call is as follows:

public boolean runExecute()
	{
		
		HttpClient	httpClient	= null;
		PostMethod	postMethod	= null;
		if (xmlInput.length() < 1) {
			//if the xmlInput was not set explicitly, we need the 
Stored Procedure name to build the calling xml.
			if (this.storeProcedureName.length() < 0) { 
				this.methodWithError = methodWithError + " 
runExecute() ";
				errorMessage.append("Stored Procedure name was 
not set by implementing class, so no call can be made.\n");
				this.status = false;
				return (this.status);
			}
			if (this.extuId.length() < 1) {
				this.methodWithError = methodWithError + " 
runExecute() ";
				errorMessage.append("Extu_id was not set by 
implementing class, so no call can be made.\n");
				this.status = false;
				return (this.status);
			}
			else {
				this.buildXML();
			}
		}
		
		try
		{
				
			httpClient = getHTTPClientConnection( 
HttpConnectTimeout, HttpResponseTimeout );
			postMethod = getPostMethod( xmlInput );
			postMethod.setDoAuthentication( true );
			httpClient.executeMethod( postMethod );
			
			httpStatus = postMethod.getStatusText();
			
			httpStatusCode = postMethod.getStatusCode();	
			
			if (httpStatusCode == 200)
			{	
				getResults( postMethod );
				this.status = true;
				
			} else {
				// http error occurred calling eFacets
				this.methodWithError = this.methodWithError + " 
runExecute() ";
				errorMessage.append("HTTP error connecting to 
eFacets.  HTTPstatus code = " + httpStatusCode + ": " + httpStatus);
				this.status = false;
			}
		}
/*
 *		MoException (thrown from class methods) 		
 *		HttpException
 *		IOException
 */
		catch ( HttpException e )
		{
			methodWithError = methodWithError + " runExecute() ";
			errorMessage.append("HttpException caught: (Efacets 
connection error)" + e.getMessage() + "\n");
			this.status = false;
		}
		catch ( IOException e )
		{
			methodWithError = methodWithError + " runExecute() ";
			errorMessage.append("IOException caught: " + 
e.getMessage() + "\n");
			this.status = false;
		}
		catch ( Exception e )
		{
			methodWithError = methodWithError + " runExecute() ";
			errorMessage.append("Exception caught: " + e.getMessage
() + "\n");
			this.status = false;
		}
		finally
		{
		    postMethod.releaseConnection();
		}
		
		return this.status;
	}

The code for getHTTPClientConnection is as follows:

private HttpClient getHTTPClientConnection( int aConnectionTimeout, int 
aResponseTimeout ) throws Exception
	{
		try
		{
		    HttpClient aClient = new HttpClient();
   		    aClient.setConnectionTimeout( aConnectionTimeout );
		    aClient.setTimeout( aResponseTimeout );
		    //System.out.println(efacetsAuthUserId + 
efacetsAuthPassword + efacetsAuthHost + efacetsAuthDomain);
		    
			aClient.getState().setCredentials( null, null, new 
NTCredentials( 
efacetsAuthUserId,efacetsAuthPassword,efacetsAuthHost,efacetsAuthDomain ) );
		    return aClient;
		}
		catch ( Exception e )
		{
			methodWithError = methodWithError + " 
getHTTPClientConnection() ";
			errorMessage.append("Exception caught: " + e.getMessage
() + "\n");
		    throw e;
		}
	}

And for getPostMethod:

private PostMethod getPostMethod( String aXMLRequest ) throws Exception
	{
		try
		{
		    PostMethod aPost = new PostMethod( efacetsURL );
	    
		    String content = "XML_BODY=" + URLEncoder.encode( 
aXMLRequest );
		    aPost.setRequestBody( content );
		    if ( content.length() < Integer.MAX_VALUE )
		    {
		    	aPost.setRequestContentLength( (int) content.length() );
		    } 
		    else
		    {
		        aPost.setRequestContentLength( 
EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED );
		    }
		    aPost.setRequestHeader( "Content-Type", "application/x-www-
form-urlencoded" );	
	
			return aPost;
		}
		catch ( Exception e )
		{
			methodWithError = methodWithError + " getPostMethod() ";
			errorMessage.append("Exception caught: " + e.getMessage
() + "\n");
		    throw e;
	
		}
	}
	

I know there have been some API changes between 2.0.2 and 3.0 and maybe I'm 
getting burned on this, but with the classes being deprecated vs. removed all 
together I would think I could bring in the new jar and things would work.  
I've also tried recoding everything per the code example for the PostMethod, 
but that is not working either.   

The URL I'm sending is:  http://omahcad29/eFacets411/brokerhttpform.asp

I've read thru the encoding stuff and can't see where this URL is an issue and 
I've verified that this does actually exist in the URL variable as the URI 
class is called.

Any guidance would be appreciated.

Thanks,
Mary Ann

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Mime
View raw message