Hi,
I have a situation where in i am getting a
java.lang.NullPointerException when the java script executes a doInvoke. The doInvoke however works in 4.6 . so where should i start looking to resolve this issue.
Check to see exactly where the NPE occurs. It could be in the doInvoke, or the service that it invokes. And I assume you don’t really mean “java script” but simply Java.
The NPE occurs inside doInvoke. However, I created a simple class (for testing purpose) with a func that invoked another service and was able to do so using doInvoke. However if i try to do the same from a class derived from EventSubscriber class (in the com.wm.util.event.* pkg) i encounter an error.
Yes i mean java… sorry for the incorrectly using java script instead.
Thanks
Prakash
Can you post the source of your service?
Thanks.
I have 2 sections of code . One is outside the developer and the other is inside the developer .
////////Code outside the developer////////////
public class MEvent extends Event{
private String fileName=“”;
private String fileDir=“”;
private String connectURL=“”;
private String checkSum=“”;
private String invokeService=“”;
private String invokeFolder=“”;
private String userid=“”;
private String password=“”;
public MEvent(Object obj){
super(obj);
}
public void setParams(String fName,String fDir,String cURL, String cSum,String serviceName,String folderName,String uid,String pwd)
{
fileName=fName;
fileDir=fDir;
connectURL=cURL;
checkSum=cSum;
invokeService=serviceName;
invokeFolder=folderName;
userid=uid;
}
//get methods for each of the members… omitted here
};
I get an Error in the ProcessEvent method of the class below
public class MEventSubscriber extends EventSubscriber {
public boolean processEvent(Event event){
MEvent evt=(MEvent)event;
try{
Session sesSource=(Session) evt.getSource();
IData data = IDataFactory.create();
IDataCursor dataCursor = data.getCursor();
dataCursor.last();
dataCursor.insertAfter(“fileName”,evt.getFileName());
dataCursor.insertAfter(“fileDir”,evt.getFileDir());
dataCursor.insertAfter(“connectURL”,evt.getConnectURL());
dataCursor.insertAfter(“checkSum”,evt.getCheckSum());
dataCursor.insertAfter(“userID”,evt.getUserid());
dataCursor.insertAfter(“password”,evt.getPassword());
if(sesSource!=null){
System.out.println("in the MEventSubsriber");
User sname=sesSource.getUser();
//System.out.println("after the sesSource sName="+sname.getName());
System.out.println(“MEventSubscriber:invokefolder=”+evt.getInvokeFolder()+" invoke service=“+ evt.getInvokeService()+”
user=“+evt.getUserid()+ " password=”+ evt.getPassword());
//THE doInvoke below THROWS AN EXCEPTION
IData outIData = Service.doInvoke(evt.getInvokeFolder(), evt.getInvokeService(),sesSource, data);
dataCursor.destroy();
System.out.println("after the idata dat="+outIData );
}
System.out.println("...event received .." +sesSource);
}catch(Exception e){
System.out.println("Error in invoking the webx --file pulling service:occured in the eventsubscriber...
" +e);
return true;
}
return true;
}
}
//////////////////////////////
Code in developer
MEvent evt=new MEvent(Service.getSession());
MEventSubscriber evtSub=new MEventSubscriber();
Cron crn=new Cron();
try{
evt.setParams(fileName,fileDir ,connectURL,checkSum,INVOKE_SERVICE,INVOKE_FOLDER,partnerUserId,partnerPassword);
AsyncEventQueue aq=new AsyncEventQueue(crn);
System.out.println("before the subscribe in the fireFileTransf
I discussed the problem with webMethods support . As the code uses private classes(Event, EventSubscriber, Cron and AsyncEventQueue) they will not be able to support the issue. I guess they have changed the implementation.
Thanks
Prakash
Have you been able to verify that all the parameters are non-null? I suspect that sesSource may be null for some reason.
Well, There is a check to see if sesSource is null or not null. However, I found out that if i do not extend the MEvent and
MEventSubscriber classes from Event and EventSubscriber and call the
processEvent method directly instead of accessing it via a sendEvent call the code works fine.
I dont know where the developer who wrote the code actually found the Event and EventSubscriber classes.
Thanks
Prakash
Oops. My bad. I misread where the closing brace on the if block was.
Glad you found a workable approach.