[SalesForce] Type mismatch for

I have some VF pages with a custom component that are working fine in my dev environment. However, when I try to deploy this to production, the deployment fails and each page that I am trying to deploy, which all have the same component, have the following error message:

Type mismatch for <apex:attribute assignTo>. Value binding to a property of type String is required, property specified (sessionId) is of type null.

This is the attribute element from the custom component:

<apex:attribute name="websession" description="Website Session"
                  type="String" required="required" assignTo="{!sessionId}"/>

This is the sessionId variable from the custom component controller:

public String sessionId {get; set;}

and this is how the component is being used in each of the VF pages:

<c:MyCustomComponent websession="{!sessionId}" /> 

I know that the session id being assigned to the custom component is not null. As I said, this is working fine in dev. Just a deployment issue I think. I'm not really sure from the error message exactly what is wrong either. Is it saying that the value being passed into the component is null?

I have run the tests for these pages' controllers and they run fine.

Any ideas what could be up here?

Thanks

Best Answer

You say you are having issues when deploying correct? Any chance the controller already exists in the org you are deploying to? Any chance you missed the controller in the new deploy?

One scenario I have run into in the past is that the validation Salesforce runs can be a bit tricky when dealing with controllers and Visualforce. For instance:

  • You have two files in production, one for the controller and one for Visualforce.
  • You make changes to both files in a dev org/sandbox.
  • You deploy both files back to production, but validation fails on the Visualforce page. You get an error indicating a missing field, mismatched type, etc. indicating that the controller doesn't have that field.
  • You verify both files work fine in dev and are completely confused at this point. The problem I have found is (and this is completely speculating but I have seen it before). The issue is that the production org is validating the Visualforce against the old Apex code before it deploys the updated Apex code as part of the deploy.

To workaround this issue, if you can, you need to either delete the production instance of the code or comment out the Visualforce as part of the deploy and then uncomment it in production. There is no exact science to it, and this may not even be the real reason behind my issues in the past, but I have experienced some very strange things during deploys in the past. Good luck!