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:
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.
Attribution to: Acuariano
Possible Suggestion/Solution #1
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.
Attribution to: Double A
Possible Suggestion/Solution #2
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:
But if you activate the Development mode it shows the place in code where the error occurs:
Attribution to: Sergej Utko
Possible Suggestion/Solution #3
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? [updated for Winter 17]
Attribution to: AlexandreJ
Possible Suggestion/Solution #4
Are you using the Developer Console? I believe it tracks controller errors for VF pages in the same session.
Attribution to: joshbirk
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30094