This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 21, 2012, 8:03 AM
9 Posts

Understanding Java errors

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: null pointer error java
  • Replies: 6
 I have been working on a big application for some time, trying to bring stability to it as it was forever generating errors. I have introduced code on the custom error page that is shown to a user so that it emails me the stack trace (mainly so I can keep an eye on how frequently this happens). 
 
Is there anywhere on the internet that is a good source for being able to understand these errors? I am getting good with XPages but I haven't got a clue what this means (this is an example of an error that came out this morning - any help with it would be really appreciated!)  
 
By the way - the system on its own seems pretty reliable. Most of the time that I try and reproduce the errors that are reported to me I can't. It used to crash all the time but we moved it to a new server and this happens a lot less frequently. I can't understand why code would fail 1 in 10 times and work every other time - is it down to the server? Is the JVM that unstable on an 8.5.3 server?  
 
Help please: 
 
java.lang.NullPointerException: null

com.ibm.xsp.component.UIDataPanelBase.encodeEnd(UIDataPanelBase.java:280)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:856)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1267)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1251)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272) 
Mar 21, 2012, 9:24 AM
56 Posts
Re: Understanding Java errors
Hi Richard,
 
what you see are , in most of the cases, JSF stacktraces. Maybe this helps you get some information on particular error messages, instead of searching for these error messages on XPages context. I have tried to find such a website you asked for, but nothing at the first shot. I'm afraid you have to look for each error message, one by one. But in most cases, the first line of the strack trace is important, because in most of the cases we don't have influence on the underlying JSF code.
 
To your error message, I only can tell you that NullPointer Exception means that you try to use an object which is not initialized. This is certainly the most common error message a Java developer will encounter in his life =)
It could have a million reasons to occur, but without seeing your code.
 
Maybe you simply forgot to initialize something, meybe you have a nasty recycling misbehavior (remember, all objects are only used once in the api, if you have in two different places an object for one document, and you recycle it, the object in the other place used will be destroyed, too) Recycling misbehavior could be an explanation for the error are not reproducable in all cases.
 
Please show us the code which throws the error, then we can help you.
Mar 21, 2012, 10:09 AM
9 Posts
Re: Understanding Java errors
 Hi Matthias,
 
Thanks for replying. The problem is most of the time I don't know what is causing the errors. Like I said, the same action 9 times out of 10 works fine but every now and then for a seemingly random reason it fails with an error like above. I have resorted to writing lots of code in the system all over the place to try and code around these problems. The most common one I get is when a user clicks a workflow button that triggers querySave code to validate the doc in SSJS (rather than the validators you can define against each field in designer). If this function returns true, I then call a function to save the document. Originally the code started off with simply currentDocument.save() but in an attempt to find out what was going on I added logging and more  complex code just to do the save.  
 
I log EVERYTHING that the user does now to try and fault find, so this is a typical log entry when something has gone wrong: 
 
(22-Feb-2012 09:42:30:375)... CURRENT UNID: D5933D802C2CA4FFC12579AC002FD630
(22-Feb-2012 09:42:30:640)... --> myUser.getCurrentDocument(): NotesXspDocument
(22-Feb-2012 09:42:30:640)... Problem Saving doc: Exception occurred calling method NotesXspDocument.getDocument(boolean)
null
(22-Feb-2012 09:42:30:640)... saveCurrentDocument returning: false
 
myUser is a managed bean about the user. The only recycling I do manually in the system is in the bean when it gets a record about the user to find out certain bits of information like their department, their roles, their team leader etc.  
 
So the 4 entries above are generated by the following code:  
 
1. The User clicks a workflow button and this calls the caseQuerySave function to validate. That has returned true so the function to save the document is called:
 
function saveCurrentDocument() {
try {
var success:boolean = false;
A: writeToLog("CURRENT UNID: " + myUser.setCurrentDocument());
var d:NotesXspDocument = myUser.getCurrentDocument();
B: writeToLog("--> myUser.getCurrentDocument(): " + typeof myUser.getCurrentDocument());
if (typeof d.getDocument(true)==null) {
sessionScope.informationMessage = "Problem saving the case: myUser.getCurrentDocument()" + " returned null. Please try saving again.";
}
else if (myUser.getShortName() == "") {
sessionScope.informationMessage = "Something has gone wrong with the myUser object, it's not set. Please try saving again.";
}
else {
writeToLog("Saving doc: " + d.getDocument().getUniversalID());
d.save();
success=true;
sessionScope.informationMessage = "Document saved...";
}
}
catch(e){
success = false;
C: writeToLog("Problem Saving doc: " + e);
sessionScope.informationMessage = "There was a problem saving the document for user " + myUser.getShortName() + ": " + e;
}
finally {
writeToLog("saveCurrentDocument returning: " + success.toString());
return success;
}
 
 
Line A above is the 1st message being written to the log. myUser.setCurrentDocument returns the UNID of the document that is being edited and has clearly worked as the UNID is displayed in the log message.
 
Line B - I'm not sure if this would prove that the myUser.getCurrentDocument() function has worked worked or not when the function is set to return a NotesXspDocument? 
 
Line C is the error that is generated when d.save()
 
myUser.getCurrentDocument looks like this: 
 
public DominoDocument getCurrentDocument(){
try {
myDoc = (DominoDocument)FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(), "document1");
if (myDoc == null || (String)myDoc.getDocument(true).getUniversalID()=="") {
emailError("XPageUser.getCurrentDocument(): CurrentDocument is null  - current User is " + shortName);
Log.writeLine("Getting Current Doc: " + setCurrentDocument());
throw new Exception("There was a problem getting the current document, please contact support.");
}        
}catch(Exception e){
emailError("XPageUser.getCurrentDocument() Error: " + e.toString() + "  - current User is " + shortName);
Log.writeLine("XPageUser.getCurrentDocument() Error: " + e.toString());
}finally {
return myDoc;
}
    }
 
I don't ever receive the email to say the current document was null, yet the next time when it is used in the save document function further above, it generates an error. 
 
This code is used many times a day without incident - is there anything in there that you can see that would be dodgy? and why would it work most of the time and just fail every now and then?  
 
Really appreciate your help with this! 
Mar 21, 2012, 11:33 AM
56 Posts
Re: Understanding Java errors
Hmm, not sure...
 
But look at the line bwlow line B. You write: if(typeof d.getDocument(true)==null)
 
I think, maybe you forgot a bracket behind typeof. Also I am quite sure that typeof  never returns null, you should try typeof(d.getDocument).equals("undefined") or .equals("")
 
Maybe the error is raised because of the missing bracket, but I will look into your functions a bit deeper.
 
Also, your second method, the getDocument function, why are you using the facesContext and not a dataSource itself? The reason for this method may be helpful for the solution.
Mar 21, 2012, 2:28 PM
9 Posts
Re: Understanding Java errors
 Thanks!
 
I'm not sure where the missing bracket behind typeof is on the following line though: 
 
if (typeof d.getDocument(true)==null) {
sessionScope.informationMessage = "Problem saving the case: myUser.getCurrentDocument()" + " returned null. Please try saving again.";
}
 
 
 I will make the change you mentioned  however to check it's not undefined or "". 
 
As for why it was written this way, it's another example of me trying to code around the problem. We were getting the null document errors when trying to Save a datasource so I thought if I added some code to try and re-establish the connection to the data source it might help. I previously just had currentDocument.save() instead of a call to this function to try and return the document and then save it. Maybe now we have the new server (that seems more stable) I should be reverting the code back to the simple way of doing things and hope that it helps ?  
 
 
  
Mar 21, 2012, 2:57 PM
56 Posts
Re: Understanding Java errors
Hi,
 
the missiong bracket is there:
 
 
As for your other problem, maybe you can try a simple "Save Document" action on a button. You can pass on a parameter of which datasource you want to save (its: <xp:saveDocument var="myDoc" />). Maybe this the error, that your application doesn't have a current Document or don't get the correct one.
 
Mar 28, 2012, 7:01 AM
9 Posts
Re: Understanding Java errors
 Hi Matthias, 
Thanks for the tip. I am going through the code to remove all the complicated workarounds I was forced to put in the system now that we apparently have a stable(ish) server :-)  

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal