karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schneider <ch...@die-schneider.net>
Subject Re: Karaf Issue - Web services not getting called (not working as expected)
Date Wed, 28 Oct 2015 14:05:10 GMT
If the control goes to the caller method in the mid of a method then 
this is a clear sign that an exception happens.
So add a try catch and log the exception.

Especially in an BundleActivator.start method I made the experience that 
exceptions are not logged by default by the framework.

Christian

On 28.10.2015 14:47, abhilashb wrote:
> Hello,
>
> Thank you for the reply.
>
> Below is the sample code that i am using -
> 	
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpMethod;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.auth.AuthScope;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.PutMethod;
> 		
>    	public static void main(String[] args) {
> 				
> 		   		private static HttpClient httpClient;
>
> 		   		httpClient = getHttpSesssion(); // Getting the authentication for the
> application by using username/password
> 		   		StringBuffer fetchURL = new StringBuffer(ConnectionConstants.SCHEME);
> 		   		fetchURL.append(HOST);
> 		   		fetchURL.append(REPOSITORY);
> 		   		fetchURL.append(QUESTIONMARK);		   		
> 		   		fetchURL.append("oslc.where=domain:=DOMAIN . . . .);
>
> // Forming the web service url to be called (fetchURL)
>
> 		   		HttpMethod method = new GetMethod(fetchURL.toString());
> 		   				   		try {
> 		   				   			System.out.println("Setting header info...");
> 		   				   			method.addRequestHeader("Accept", "application/json");
> 		   				   			method.addRequestHeader("OSLC-Core-Version", "2.0");
> 		   				   			
> 		   				   			executeMethod = httpClient.executeMethod(method);
> 		   				   			
> 		   				   			System.out.println("Response Code :::" +
> method.getStatusCode());
>
> 		   				   			String response = method.getResponseBodyAsString();
> 		   				   			
> 		   				   			
> 		   				   		
> 		   				   		}catch(Exception e){
> 		   				   			//Wrap the exception					
> 		   				   		}finally{
> 		   				   			
> 		   				   		}
>
> 		   		
> 			}
> 		   	
>
>
> When the control reaches " executeMethod =
> httpClient.executeMethod(method);"
>
> It doesnt goahead and instead it stops/ goes back to the caller method
> without any response.
>
> In Karaf, i have installed httpClient -
>
> 103 | Active    |  50 | 3.1.0.7  | Apache ServiceMix :: Bundles ::
> commons-httpclient
>
> My manifest import statement -
>
> Import-Package:
> org.osgi.framework,org.apache.camel,org.apache.commons.httpclient,org.apache.commons.httpclient.auth
>
> Anything is missing?
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Issue-Web-services-not-getting-called-not-working-as-expected-tp4043195p4043200.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Mime
View raw message