/AndroidRuntime: FATAL EXCEPTION: main                   Process: com.example.anil.mynewapp, PID: 408                   java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.example.anil.mynewapp.SignupAuthentication.signupAuthentication(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)' on a null object reference                       at com.example.anil.mynewapp.Second$1.onClick(Second.java:40)                       at android.view.View.performClick(View.java:6294)
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
7315
Recently, apps that are fine an hour ago now crash when I open them. The crash report message seems to be caused by a null pointer exception (NPE) in com.google.android.trichromelibrary. Apps affected for me:  Gmail Dashlane  Is it just me, or is there actually something wrong with the library? How can I fix these affected apps? Crash report: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'Xiaomi/polaris/polaris:10/QKQ1.190828.002/20.9.4:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: ... pid: ..., tid: ..., name: com.dashlane &gt;&gt;&gt; com.dashlane &lt;&lt;&lt; uid: ... signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference          ...  backtrace:     #00 pc 00000000038621f0 /data/app/ com.google.android.trichromelibrary 438909034-YaxP9ttrIDcQBfleP5vm7Q==/base.apk! libmonochrome_64.so (offset 0x646000) (BuildId: ... )  (click  for the screenshot of the bug report)
57036
When I used to create the record in Event object it is showing error like:     Error: Invalid Data.   Apex trigger General_Event_Trigger caused an unexpected exception, contact your administrator: General_Event_Trigger: execution of BeforeINsert caused by: System.NullPointerException: Attempt to de-reference a null object: Class.EventClass.updateNewCustomFieldsEvent: line 369, column 1   Trigger code:  trigger General_Event_Trigger on Event (...) {     if (trigger.isBefore)     {         if (trigger.isInsert)         {             EventClass.updateNewCustomFieldsEvent(trigger.new);         }         else if (trigger.isUpdate)         {             EventClass.updateNewCustomFieldsEvent(trigger.new);         }     } }   Apex class:  public static void updateNewCustomFieldsEvent(List&lt;Event&gt; eventList) {     for (Event eve : eventList)     {         if (Administrators__c.getInstance().Update_field_Last_Modified_End_User__c)         {             String userIdString = eve.LastModifiedById;             eve.Last_Modified_By_End_User__c = userIdString.subString(0, 15);             eve.Last_Modified_Date_End_User__c = eve.LastModifiedDate;         }     } }
65747
I'm running a REST API which is returning the below:  "id" : "fdgsdgsdsdgsdg",    "pageevents" : [ {        "name" : "test",        "number" : "0123442",        "homepage" : "www.test.com"     } ],     "goals" : [ {        "name" : "test",        "number" : "0123442",        "homepage" : "www.test.com"     } ] } ]   Im using the below code to de-serialize it, so i can display it as a pageblocktable on a visualforce page however im getting the error :      System.JSONException: Illegal value for primitive   public List&lt;maMoments&gt; getMomentsActivity() {     Id contactId;     if (contactId == null) {         contactId = '0030O00001sqXJr';     }      String contactIdString = String.valueOf(contactId);     String jsonResponse = this.AutomationDetailsMoments(contactIdString);     system.debug(jsonResponse);     List&lt;maMoments&gt; mAutomation = (List&lt;maMoments&gt;) JSON.deserialize(jsonResponse, List&lt;maMoments&gt;.class);     system.debug(mAutomation);     for(maMoments emailStructure : mAutomation){      }      return mAutomation; }  public string AutomationDetailsMoments(String contactId) {     contactId = '0030O00001sqXJr';     Http h = new Http();     HttpRequest req = new HttpRequest();     req.setEndpoint('https://virtserver.swaggerhub.com/mickjdavies/Example/1.0.0/interestingmoments');     req.setMethod('POST');     req.setBody(contactId);      // Send the request, and return a response     HttpResponse res = h.send(req);     system.debug(res.getBody());     return res.getBody(); }  private class maMoments {     public String contactId;     public String id;     public List&lt;String&gt; goals;     public String name;     public String homepage;     public String phone; }
78730
When writing a controller for a Lightning Component, it is convenient to add the data transfer object classes as inner classes of the controller. This works fine for sending data to the client but I get a gack that includes a java.lang.UnsupportedOperationException when sending from client to server:     An internal server error has occurred\nError ID: 2066801247-4851   (-1600101374)\n\norg.auraframework.throwable.AuraExecutionException:   apex://LifePaymentsController:   java.lang.UnsupportedOperationException\n\tat   .(apex://LifePaymentsController)\n\tat   ui.services.facades.CoreLightningComponentFacadeImpl.runApexAction(CoreLightningComponentFacadeImpl.java:233) ...   Here is what the server-side looks like (the save1 method fails):  public class SaveRequest {     @AuraEnabled public Payee[] newPayees;     @AuraEnabled public Payment[] payments; }  ...  // Fails @AuraEnabled public static void save1(SaveRequest saveRequest) {     System.debug(JSON.serializePretty(saveRequest)); }  // Works @AuraEnabled public static void save2(String jsonString) {     SaveRequest r = (SaveRequest) JSON.deserializeStrict(jsonString, SaveRequest.class);     System.debug(JSON.serializePretty(r)); }   and the client-side:  // Fails var action = servicesComponent.get("c.save1") action.setParams({      "saveRequest": saveRequest });  // Works var action = servicesComponent.get("c.save2"); action.setParams({      "jsonString": JSON.stringify(saveRequest) });   The save2 alternative method (where deserialization is explicitly coded) works.  I interpret these results to mean that inner classes are still (April 2017) not fully supported in @AuraEnabled methods. Is that the case?
38112
Here's the scenario...    if (entry.Properties["something"].Value != null)   attribs.something = entry.Properties["something"].Value.ToString();   While effective and working correctly, this looks ugly to me.  If I don't check for a null before performing the ToString() then it throws an exception if the property was null.  Is there a better way to handle this scenario?  Much appreciated!
8114
I have same exception can please   The previous post issue is resolved.  Exception: :System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out  Visualforce Page   &lt;apex:page controller="Controller" action="{!init}" showHeader="false" sidebar="false"&gt;     &lt;center&gt;         &lt;apex:pageBlock title="Request Listener"&gt;&lt;/apex:pageBlock&gt;               &lt;/center&gt; &lt;/apex:page&gt;   Controller :            PUBLIC with sharing class Controller {        PUBLIC String fromNumber      = ApexPages.currentPage().getParameters().get('From');     PUBLIC String toNumber        = ApexPages.currentPage().getParameters().get('To');     PUBLIC String body            = ApexPages.currentPage().getParameters().get('Body');        PUBLIC PageReference init()     {                    System.debug('From Phone Number :' +fromNumber);         System.debug('To phone NUmber :' + toNumber);         System.debug('Message Body :' + body);          TwilioRestClient Client = TwilioAPI.getDefaultClient();                                                                SYSTEM.DEBUG('FROM AND To  Number is NOT NULL');                      String formattedNumber='+919876543210';                 IF(body != NULL)                 body = body;             ELSE                 body = '';             Case c = NEW Case (Subject = formattedNumber,Description = body,Origin = 'Phone');             INSERT c;                               Map&lt;String,String&gt; params1 = new Map&lt;String,String&gt;             {                'To'   =&gt; fromNumber,                'From' =&gt; '+1908280****',                'Body' =&gt; 'Conformation to customer'             };             TwilioMessage message = client.getAccount().getMessages().create(params1); /* Valid conformation SMS sent to the Customer.*/                                            return null ;     } }   While loin as admin then click preview on visualforce page executed but case is not created.I have checked the the debug log it throw the exception.
37422
I'm getting this error every few days. I won't see the error for a few days then I'll get a flurry of 20 or so all with in a minute or so.  I've been very thorough going throw my code so that I'm using this basic setup for my DB access.  try {   myConnection.Open();   mySqlDataAdapter.Fill(myDataTable);   myConnection.Close(); } Catch (Exception err) {   if (myConnection.State != ConnectionState.Closed) myConnection.Close();   throw err; }   The way I understand it this should execute my queries and immediately release the connection back to the pool but if something goes wrong with the query then I catch the excpetion close my connection then throw the error up, which eventually gets trapped at the application level and logs and emails me the error.  Even using this throughout my code I'm still running across the issue. What can I do to diagnose the root cause of the issue?
18236
Steps to Reproduce   Tap faster on the code. or Tap once on a huge code.   but happens only when  setupForGeneric() is called, might be a bug related to   private void setupForCode()   { String str = getIntent().getStringExtra("com.stackexchange.marvin:code_block"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.setPostBody("&lt;pre&gt;&lt;code&gt;" + TextUtils.htmlEncode(str) + "&lt;/pre&gt;&lt;/code&gt;", false); localPrettyWebView.setBackgroundColor("#eeeeee"); }  private void setupForGeneric() { String str = getIntent().getStringExtra("com.stackexchange.marvin:web_url"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.getSettings().setBuiltInZoomControls(true); localPrettyWebView.getSettings().setLoadWithOverviewMode(true); localPrettyWebView.getSettings().setUseWideViewPort(true); localPrettyWebView.loadUrl(str); localPrettyWebView.setBackgroundColor("#eeeeee"); }   Log  09-05 03:54:30.312: E/AndroidRuntime(26264): FATAL EXCEPTION: WebViewCoreThread  09-05 03:09:39.522: E/Crittercism(18318): java.lang.NullPointerException: [v0.1.22]  09-05 03:09:39.522: E/Crittercism(18318):   at android.content.ComponentName.&lt;init&gt;(ComponentName.java:75) 09-05 03:09:39.522: E/Crittercism(18318):   at android.content.Intent.&lt;init&gt;(Intent.java:3156) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.ViewPopupActivity.showCode(ViewPopupActivity.java:25) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.question.QuestionFragment$1.onCodeClicked(QuestionFragment.java:67) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.common.PrettyWebView$WebAppInterface.codeClicked(PrettyWebView.java:197) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.access$4000(WebViewCore.java:59) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1449) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Handler.dispatchMessage(Handler.java:99) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Looper.loop(Looper.java:137) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:790) 09-05 03:09:39.522: E/Crittercism(18318):   at java.lang.Thread.run(Thread.java:856)
44999
I am trying to write a test class for the Apex Class with try - catch block and this is my first time coding test classes. The Apex Class is like below which has trycatch   public class updateCaseRecord {          @AuraEnabled     public static void updateCheck(String caseId){         String msg = '';         try         {         List&lt;Case&gt; records = [select id,Status from Case WHERE Id = :caseId];         for (Case record : records)         {             record.Status = 'Closed';         }         update records;          }         catch(DmlException e)              {                for (Integer i = 0; i &lt; e.getNumDml(); i++) {                     msg =+ e.getDmlMessage(i) +  '\n' ;                     System.debug('getDmlFieldNames=' + e.getDmlFieldNames(i));                    System.debug('getDmlMessage=' + e.getDmlMessage(i));                   }                 throw new AuraHandledException(msg);             }             catch(Exception e)             {             throw new AuraHandledException(e.getMessage());             }             finally { }           }}   And I wrote my test class like   @IsTest public class updateCaseRecordTest { @IsTest static void testIsUpdateCheck() {      ID parentRecType = '012U0000000PqA9IAK';     ID csRecType     = '012U0000000QGv4IAG';       Account pa = new Account(Name='Test Parent Account', recordTypeId=parentRecType);     insert pa;      Account testAccount = new Account(Name='test', Industry='Biotech',Territory__c='EUR',BillingCity='Test',BillingCountry='Germany',ParentId=pa.id);     insert testAccount;       Contact c = new Contact(LastName='Test',LeadSource='Customer Service',AccountId=testAccount.Id);     insert c;      Case newCase1 = new Case();     newCase1.Subject = 'testStatusClosed';     newCase1.Status = 'New';     newCase1.Category__c = 'Inquiry';     newCase1.Sub_Category__c = 'Other';     newCase1.AccountId = testAccount.Id;     newCase1.ContactId = c.id;     newCase1.recordTypeId=csRecType;     insert newCase1;       Test.startTest(); try     {     updateCaseRecord.updateCheck(newCase1.Id);     List&lt;Case&gt; lCases = [SELECT Id,Status,OwnerId FROM Case WHERE Id =: newCase1.Id];     System.assertEquals('Closed', lCases[0].Status);      System.assertEquals(UserInfo.getUserId(), lCases[0].OwnerId);     }      catch(DMLException e) {         System.assertEquals(e.getMessage(), e.getMessage());     }      Test.stopTest();    }}   I thought I captured the try catch but when I run the test class it has only 57% code coverage and shows like below    Following one of the answers here
323
I'm having issues with creating a pretty simple test Utility Class. I want to create two records: an account and a related child contact. The error I see in the developer console is:     Variable does not exist: a.ID   My code, based on the Salesforce Apex Workbook, is as follows. I've played around with various things, but it's not working. Where am I going wrong? Thanks in advance.  @isTest public class AccountSaveTestSuite {      public static Account createOneAccount(){           Account testAccount = createAcct('ABC Computing inc.');              Contact testContact = createContact();          return testAccount;             }      // Helper methods //     //        private static Account createAcct(string accountName) {          Account a = new Account(             Name=accountName);         insert a;         return a;     }      private static Contact createContact(){         Contact c = new Contact (             FirstName = 'Jane'              , LastName = 'Smith'             , Account = a.ID); // *** Error is here ***         insert c;         return c;      }  }
121233
I'm trying to run an application downloaded from the internet (e.g., Jabref) but it seems that it fails silently. When I try to open it by double clicking it, nothing happens. When I use the terminal I get the following message:     LSOpenURLsWithRole() failed with error -10810 for the file .../xxxx.app   I tried several suggestions that I found here like changing permissions and modifying the Info.plist file, but nothing works.  Because it's a Java application, I tried to run it through terminal using      java -cp "CLASSPATH" MAINCLASS    and it works fine.  Just to mention that I get this error not only with this app, but for a few other applications.  Thanks in advance.
72722
getRealPath() is returning the actual path in the local system, but returns null when deployed with a .war file.  &lt;%@ page import="java.io.*" %&gt; &lt;%@ page contentType="text/html;charset=ISO-8859-1" %&gt;  &lt;% int iLf = 10; char cLf = (char)iLf; String a= application.getResource("/"); //String myfile = application.getRealPath("/")+ "generate.xml"; //String myfile = request.getContextPath()+"generate.xml"; //String myfile = request.getRealPath("/")+"generate.xml";  out.println(myfile);     File outputFile = new File(myfile); outputFile.createNewFile(); FileWriter outfile = new FileWriter(outputFile); outfile.write(" &lt;?xml version='1.0' encoding='UTF-8'?&gt; "+cLf); outfile.write(" &lt;playlist version='1' xmlns = 'http://xspf.org/ns/0/' &gt; " +cLf); outfile.write(" &lt;title&gt;My Band Rocks Your Socks&lt;/title&gt; "+cLf);  outfile.write("&lt;trackList&gt;"+cLf);  %&gt;  &lt;%! String[] sports; %&gt;  &lt;%     sports = request.getParameterValues("sports");      out.println("&lt;html&gt;&lt;body&gt;&lt;h1&gt;hello&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;");      if (sports != null)     {           for (int i = 0; i &lt; sports.length; i++)          {                // outfile.writeln (sports[i]);                String total=sports[i];               String[] sa=total.split("[,]");               // String[] sub=new String();               outfile.write("&lt;track&gt;"+cLf);               for (int j=0;j&lt;sa.length;j++)               {                 // outfile.writeln(sa[j]);                 // outfile.writeln("sa["+j+"]="+sa[j]);                 if( j == 0)                 {                      outfile.write("&lt;location&gt;" + sa[0] +"&lt;/location&gt;"+cLf);                  }                 else if (j == 1)                      {                         outfile.write("&lt;image&gt;" + sa[1] +"&lt;/image&gt;"+cLf);                       }                      else if( j==2)                           {                             outfile.write("&lt;title&gt;" + sa[2] +"&lt;/title&gt;"+cLf);                           }                 }// end of inner for loop()                       outfile.write("&lt;/track&gt;"+cLf);          //outfile.writeln();       }// end of outer for()     }      //else outfile.writeln ("&lt;b&gt;none&lt;b&gt;");    outfile.write(" &lt;/trackList&gt; "+cLf);   outfile.write(" &lt;/playlist&gt; "+cLf);   outfile.close();    %&gt; &lt;object type="application/x-shockwave-flash" width="400" height="170"           data="xspf_player.swf?playlist_url=generate.xml"&gt;           &lt;param name="movie" value="xspf_player.swf?playlist_url=generate.xml" /&gt;  &lt;/object&gt;   Can anyone provide me with an alternative for this? It would be very helpful if you showed some sample code too.
32438
I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example:  package com.android.hello;  import android.app.Activity; import android.os.Bundle; import android.widget.TextView;  public class HelloAndroid extends Activity {    private TextView mTextView = null;    /** Called when the activity is first created. */   @Override   public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      mTextView = new TextView(this);      if (savedInstanceState == null) {        mTextView.setText("Welcome to HelloAndroid!");     } else {        mTextView.setText("Welcome back.");     }      setContentView(mTextView);   } }   I thought it would be enough for the simplest case, but it always responds with the first message, no matter how I navigate away from the app.  I'm sure the solution is as simple as overriding onPause or something like that, but I've been poking away in the documentation for 30 minutes or so and haven't found anything obvious.
121434
I have a siteRegistrationController which is creating portal users as below:  Registration Controller:  public class SiteRegistrationController{      public void createPortalUser(){         //There is code to populate the values for variables u and acc.         String userId = Site.createPortalUser(u, acc.Id,null,false);             System.debug('userId is '+userId);     }  }   I am trying to test the above code and below is in my test class:  Test Class:  public class SiteRegistrationController_TEST{          SiteRegistrationController controllerObj = new SiteRegistrationController();          User guestUserObj = new User(username='testsfsdfsd@test.com',                                 IsActive=TRUE,                                 FirstName='test',                                 LastName='test',                                 Email='testsdfsd@test.com',                                 Alias='test',                                 timezonesidkey='America/Los_Angeles',                                 localesidkey='en_US',                                 emailencodingkey='UTF-8',                                 languagelocalekey='en_US');         insert guestUserObj;          System.runAs(guestUserObj){             controllerObj.createPortalUser();            } }   Site.createPortalUser is always returning null in test context.    -- This post is also about same problem but no solution here.  -- This post suggests that use the System.runAs(guestUser) but does not specify how to create guest user.   If any body has solution for this..Please help me. Thanks in Advance!
29851
I have an error that seems common on the web,  Though i cant find a definite answer that applies to my case:  I have the following Apex code:  public with sharing class templicenseemail {      private ApexPages.standardController standardController;       public Trainee__c trainee { get; set; }     public templicenseemail(ApexPages.StandardController controller) {         this.standardController = standardController;     }      public PageReference doSomething()     {         trainee  = [SELECT Email__c,First_Name__c,Institution__c,Last_Name__c FROM Trainee__c                  WHERE Id = :ApexPages.currentPage().getParameters().get('id')];                  String whatIs = trainee.Volume_Serial_Number__c;                 integer strlen = whatIs.length();                  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, trainee.Email__c  ));         return null;      }     }   And the following test case:  @isTest(seealldata=false)      private class Send_noti_emailsTestClass5 {          static testMethod void validateSend_noti_emails5() {              templicenseemail  MyTestcase = new templicenseemail();              // code here in the Middle              MyTestcase.doSomething();          }     }   I'm getting the following error:  Error: Compile Error: Constructor not defined: [templicenseemail].&lt;Constructor&gt;(SOBJECT:Lead) at line:      templicenseemail  MyTestcase = new templicenseemail();   Does anyone know why?
79268
Here is my code `  global with sharing class ReportsListController {     public String dcarr { get; set; }    public static ReportsColumnMap__c repcols { get; set; }    public ReportsListController() { } // empty constructor    @RemoteAction   global static List&lt;ReportsColumnMap__c&gt; getRepCols(String dcarr) {             List&lt;ReportsColumnMap__c&gt; repcols =          [SELECT ColumnName__c,SObject__c ,COUNT(ID) FROM ReportsColumnMap__c WHERE ColumnName__c IN ('OWNER','FIRST_NAME','LAST_NAME','TITLE','COMPANY','LEAD_SOURCE','RATING','STREET','EMAIL') AND SObject__c !='null' GROUP BY SObject__c ,ColumnName__c];     return repcols;   } }   `