Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm having a problem that I think has something to do with recent version because I don't remember having this problem before. Basically, when I have an error in a Visualforce page, I don't see the error in the Debug Log. I get an email with the error description, but it sometimes takes a long time to send it, so it's not very useful for debugging.

Any clues why an error in a Visualforce page is not showing in the debug log?

Error message example:

enter image description here

I added a System.debug('>>> fails here'); to understand the log better. This is the log from that point on:

13:50:49.723 (1723177000)|USER_DEBUG|[10]|DEBUG|>>> failing here
13:50:49.723 (1723184000)|SYSTEM_METHOD_EXIT|[10]|System.debug(ANY)
13:50:49.723 (1723261000)|SYSTEM_METHOD_ENTRY|[11]|MAP<String,Schema.DescribeSObjectResult>.put(Object, Object)
13:50:49.723 (1723288000)|SYSTEM_METHOD_EXIT|[11]|MAP<String,Schema.DescribeSObjectResult>.put(Object, Object)
13:50:49.723 (1723313000)|SYSTEM_METHOD_ENTRY|[12]|Schema.DescribeSObjectResult.getFields()
13:50:49.723 (1723354000)|SYSTEM_METHOD_EXIT|[12]|Schema.DescribeSObjectResult.getFields()
13:50:49.723 (1723376000)|SYSTEM_METHOD_ENTRY|[12]|Schema.SObjectTypeFields.getMap()
13:50:49.723 (1723581000)|SYSTEM_METHOD_EXIT|[12]|Schema.SObjectTypeFields.getMap()
13:50:49.723 (1723638000)|CONSTRUCTOR_EXIT|[106]|01pi00000059Qyc|<init>(LIST<String>)
13:50:49.723 (1723647000)|SYSTEM_MODE_EXIT|false
13:50:49.723 (1723847000)|CODE_UNIT_FINISHED|MeetingMaterialsController <init>
13:50:50.275 (1933543000)|CUMULATIVE_LIMIT_USAGE
13:50:50.275|LIMIT_USAGE_FOR_NS|(default)|

I can't understand why it doesn't show the null pointer exception or why the log is marked as "success". I used to get a stack at the point of the error inside the log.

share|improve this question
    
Are you monitoring the user for debug logs or are your replicating the problem yourself? –  Daniel Hoechst Mar 13 at 14:16
    
are you getting all the other debug for the request/error, but not the actual cause of this null pointer? –  Simon Lawrence Mar 13 at 14:19
    
Monitoring the user. And yes, the getting all the debug statements until the point of failure, but nothing about the error. See the edit above. –  Acuariano Mar 14 at 21:03
    
I had a similiar issue today where I stripped everything out of my VF page except apex:page and it still claiming it was a VF error 'deref null object' with no message and a successful log –  Phil B Oct 27 at 15:30

4 Answers 4

up vote 9 down vote accepted

There is an good trick to be able to see where the error null pointer occurs:

  • activate Development Mode in your profile

Without Development mode the system shows only the error message:

enter image description here

But if you activate the Development mode it shows the place in code where the error occurs:

enter image description here

share|improve this answer
1  
Although that helps, I still can't see why the log fails to show the error. See me edit for what I mean. –  Acuariano Mar 14 at 20:55

Salesforce VF pages will not create a log. It's the controller themselves that create a log file.

This is letting your know you are trying to access and object's fields and your object is null.

IE an Sobject such as Opportunity and if the opportunity instance is null, when you try to access Opportunity.Name on the VF page it will throw you this exception. Same thing can be said for custom objects / wrappers. Maybe you aren't initializing your objects correctly prior to requesting the information on your page?

Depending on how complex your visualforce page is, I would recommend either doing a system debug on your apex class each time you request information from your controller / extension, or just commenting out your page and enabling sections of it to figure out what getter is causing you this issue.

share|improve this answer
    
I think the question was regarding why errors that are reported via visualforce pages arn't also appearing in the debug log. The example message given then is just an example VF error..? –  Simon Lawrence Mar 13 at 14:28
    
Yes. Salesforce VF pages will not create a log. It's the controller themselves that create a log file. –  Double A Mar 13 at 14:29
    
Well, whilst that is true, I still interpret this question as to being where the debug is from the VF/controller coupling.. rather than the actual meaning of the "de-reference null object" example. (I may well, of course be wrong in that, only the asker knows!) –  Simon Lawrence Mar 13 at 14:34
    
That's correct. Although the "Developer Mode" really helps in my case (and I assume most cases), the log shows all debug lines but fails to show what happens that produces the error. Mark that the error was inside the controller. See my edit for more information. –  Acuariano Mar 14 at 20:54

To see the debug logs, you need to add a monitored user. you can do this going in

Setup->monitor->Logs->Debug Logs and Add a user to the Monitored users.

In the case of a visualforce page for internal users, you can choose yourself as a user, or the user causing problems.

In the case of an external page accessible through sites, you will need to add the site user as a (anonymous) to determine the name of the Username of the anonymous/guest user is through this path:

Setup > Develop > Sites > [click on site label] > Public Access Settings (button) > Assigned Users (button)

You can also see this related Question/Answer @Shane McLaughlin : How can I get a debug log for the sites guest user/public profile?

share|improve this answer

Are you using the Developer Console? I believe it tracks controller errors for VF pages in the same session.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.