| | |
object reference not set to instance of object+axis2
![]() |
•
•
Join Date: Jul 2008
Posts: 1
Reputation:
Solved Threads: 0
HI,
I’m getting the following messages when I run my java client which is invoking a WCF service.The service is converted to java stubs using axis2.
then when i run my client i get following messages.
Can anyone help me in finding the root of the problem.
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
org.apache.axis2.AxisFault: Object reference not set to an instance of an object.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.tempuri.CheckInServiceStub.CheckIn(CheckInServiceStub.java:183)
at stubInvoker.CheckInServiceClient.main(CheckInServiceClient.java:40)
The client is given below.
I’m getting the following messages when I run my java client which is invoking a WCF service.The service is converted to java stubs using axis2.
then when i run my client i get following messages.
Can anyone help me in finding the root of the problem.
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
org.apache.axis2.AxisFault: Object reference not set to an instance of an object.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.tempuri.CheckInServiceStub.CheckIn(CheckInServiceStub.java:183)
at stubInvoker.CheckInServiceClient.main(CheckInServiceClient.java:40)
The client is given below.
Java Syntax (Toggle Plain Text)
package stubInvoker; import java.rmi.RemoteException; import org.apache.axis2.AxisFault; import org.tempuri.CheckInServiceStub; public class CheckInServiceClient { public static void main(String []args){ try { //Instantiate the stub CheckInServiceStub checkin =new CheckInServiceStub(); CheckInServiceStub.CheckIn req=new CheckInServiceStub.CheckIn(); // set the "req" checkin object with the data req.setSessionId("Here SessionId"); //create new entity obj CheckInServiceStub.NewEntityObject newObj = new CheckInServiceStub.NewEntityObject(); //assign property // newObj.setUUID(vctargs.elementAt(0).toString()); //newObj.setEntityType(vctargs.elementAt(1).toString()); //newObj.setMessage(vctargs.elementAt(2).toString()); //newObj.setEntityName(vctargs.elementAt(3).toString()); //assign props newObj.setUUID("e1"); newObj.setEntityType("activity"); newObj.setMessage("entity type is activity"); newObj.setEntityName("Entity"); req.setNewEntityObject(newObj); CheckInServiceStub.CheckInResponse resp=new CheckInServiceStub.CheckInResponse(); //using the response object to retrieve the output resp=checkin.CheckIn(req); String[] result=resp.getCheckInResult().getString(); //for(int i=0;i<result.length ;i++) // { // vctReturn.add(result[i]); //} } catch (AxisFault e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } //return } } The stub is given as follows . /** * CheckInServiceStub.java * * This file was auto-generated from WSDL * by the Apache Axis2 version: 1.4 Built on : Apr 26, 2008 (06:24:30 EDT) */ package org.tempuri; /* * CheckInServiceStub java implementation */ public class CheckInServiceStub extends org.apache.axis2.client.Stub { protected org.apache.axis2.description.AxisOperation[] _operations; //hashmaps to keep the fault mapping private java.util.HashMap faultExceptionNameMap = new java.util.HashMap(); private java.util.HashMap faultExceptionClassNameMap = new java.util.HashMap(); private java.util.HashMap faultMessageMap = new java.util.HashMap(); private static int counter = 0; private static synchronized Object getUniqueSuffix(){ // reset the counter if it is greater than 99999 if (counter > 99999){ counter = 0; } counter = counter + 1; return Long.toString(System.currentTimeMillis()) + "_" + counter; } private void populateAxisService() throws org.apache.axis2.AxisFault { //creating the Service with a unique name _service = new org.apache.axis2.description.AxisService("CheckInService" + getUniqueSuffix()); addAnonymousOperations(); //creating the operations org.apache.axis2.description.AxisOperation __operation; _operations = new org.apache.axis2.description.AxisOperation[1]; __operation = new org.apache.axis2.description.OutInAxisOperation(); __operation.setName(new javax.xml.namespace.QName("http://tempuri.org/", "CheckIn")); _service.addOperation(__operation); _operations[0]=__operation; } //populates the faults private void populateFaults(){ } /** *Constructor that takes in a configContext */ public CheckInServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { this(configurationContext,targetEndpoint,false); } /** * Constructor that takes in a configContext and useseperate listner */ public CheckInServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, java.lang.String targetEndpoint, boolean useSeparateListener) throws org.apache.axis2.AxisFault { //To populate AxisService populateAxisService(); populateFaults(); serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service); configurationContext = _serviceClient.getServiceContext().getConfigurationContext(); _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference( targetEndpoint)); _serviceClient.getOptions().setUseSeparateListener(useSeparateListener); } /** * Default Constructor */ public CheckInServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext) throws org.apache.axis2.AxisFault { this(configurationContext,"http://hydhtc33007.ad.infosys.com/InfluxServices/InfluxCheckInService.svc" ); } /** * Default Constructor */ public CheckInServiceStub() throws org.apache.axis2.AxisFault { this("http://hydhtc33007.ad.infosys.com/InfluxServices/InfluxCheckInService.svc" ); } /** * Constructor taking the target endpoint */ public CheckInServiceStub(java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { this(null,targetEndpoint); } /** * Auto generated method signature * * @see org.tempuri.CheckInService#CheckIn * @param checkIn0 */ public org.tempuri.CheckInServiceStub.CheckInResponse CheckIn( org.tempuri.CheckInServiceStub.CheckIn checkIn0) throws java.rmi.RemoteException { org.apache.axis2.context.MessageContext _messageContext = null; try{ org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("http://tempuri.org/ICheckInService/CheckIn"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); // create a message context _messageContext = new org.apache.axis2.context.MessageContext(); // create SOAP envelope with that payload org.apache.axiom.soap.SOAPEnvelope env = null; env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), checkIn0, optimizeContent(new javax.xml.namespace.QName("http://tempuri.org/", "CheckIn"))); //adding SOAP soap_headers _serviceClient.addHeadersToEnvelope(env); // set the message context with that soap envelope _messageContext.setEnvelope(env); // add the message contxt to the operation client _operationClient.addMessageContext(_messageContext); //execute the operation client _operationClient.execute(true); org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext( org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); java.lang.Object object = fromOM( _returnEnv.getBody().getFirstElement() , org.tempuri.CheckInServiceStub.CheckInResponse.class, getEnvelopeNamespaces(_returnEnv)); return (org.tempuri.CheckInServiceStub.CheckInResponse)object; }catch(org.apache.axis2.AxisFault f){ org.apache.axiom.om.OMElement faultElt = f.getDetail(); if (faultElt!=null){ if (faultExceptionNameMap.containsKey(faultElt.getQName())){ //make the fault by reflection try{ java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); java.lang.Exception ex= (java.lang.Exception) exceptionClass.newInstance(); //message class java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); java.lang.Class messageClass = java.lang.Class.forName(messageClassName); java.lang.Object messageObject = fromOM(faultElt,messageClass,null); java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", new java.lang.Class[]{messageClass}); m.invoke(ex,new java.lang.Object[]{messageObject}); throw new java.rmi.RemoteException(ex.getMessage(), ex); }catch(java.lang.ClassCastException e){ // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.ClassNotFoundException e) { // we cannot intantiate the class - throw the original Axis fault throw f; }catch (java.lang.NoSuchMethodException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.reflect.InvocationTargetException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.IllegalAccessException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } catch (java.lang.InstantiationException e) { // we cannot intantiate the class - throw the original Axis fault throw f; } }else{ throw f; } }else{ throw f; } } finally { _messageContext.getTransportOut().getSender().cleanup(_messageContext); } } /** * Auto generated method signature for Asynchronous Invocations * * @see org.tempuri.CheckInService#startCheckIn * @param checkIn0 */ public void startCheckIn( org.tempuri.CheckInServiceStub.CheckIn checkIn0, final org.tempuri.CheckInServiceCallbackHandler callback) throws java.rmi.RemoteException{ org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("http://tempuri.org/ICheckInService/CheckIn"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); // create SOAP envelope with that payload org.apache.axiom.soap.SOAPEnvelope env=null; final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); //Style is Doc. env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), checkIn0, optimizeContent(new javax.xml.namespace.QName("http://tempuri.org/", "CheckIn"))); // adding SOAP soap_headers _serviceClient.addHeadersToEnvelope(env); // create message context with that soap envelope _messageContext.setEnvelope(env); // add the message context to the operation client _operationClient.addMessageContext(_messageContext); _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { public void onMessage(org.apache.axis2.context.MessageContext resultContext) { try { org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); java.lang.Object object = fromOM(resultEnv.getBody().getFirstElement(), org.tempuri.CheckInServiceStub.CheckInResponse.class, getEnvelopeNamespaces(resultEnv)); callback.receiveResultCheckIn( (org.tempuri.CheckInServiceStub.CheckInResponse)object); } catch (org.apache.axis2.AxisFault e) { callback.receiveErrorCheckIn(e); } } public void onError(java.lang.Exception error) { if (error instanceof org.apache.axis2.AxisFault) { org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; org.apache.axiom.om.OMElement faultElt = f.getDetail(); if (faultElt!=null){ if (faultExceptionNameMap.containsKey(faultElt.getQName())){ //make the fault by reflection try{ java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); java.lang.Exception ex= (java.lang.Exception) exceptionClass.newInstance(); //message class java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); java.lang.Class messageClass = java.lang.Class.forName(messageClassName); java.lang.Object messageObject = fromOM(faultElt,messageClass,null); java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
Last edited by Tekmaven; Jul 26th, 2008 at 2:15 pm. Reason: Code tags
![]() |
Other Threads in the Java Forum
- Previous Thread: Need TypeReader to PDF batch program
- Next Thread: GUIdancer 2.2 Automates Failure Retires
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working





