function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ron PlankenRon Planken 

JsRemote error while updating the Apex class

While working on a new jsRemote based VisualForce page I have been getting some random errors. The setup is as followed:

I have a public class that is the main controller for a VisualFoce Page. In this VisualForce page I have multiple Extentions that implement a RemoteAction. I call the RemoteAction from my javascript to fill the page with data. Now, this all works like a charm. The page loads, it gets the data and then builds the HTML on the page.
public with sharing class ExampleClassExt {
    public ExampleClass (ExampleHome ctl){ }
    
    @RemoteAction
    public static list<CustomObject> body(String employeeId) {
    }
}
 
Visualforce.remoting.Manager.invokeAction(  
	 "c.ExampleClassExt.body",
	 Employeeid,
	 function(result,event){
	   if(event.status){  
             doStuff();
           }
         });

Now the error shows up when I change something in the Apex code, either in the controller or one of the Extentions and shows up like this:
 
Apex script unhandled exception by user/organization: 00xxxxxxx/00Dxxxxxxxxx
 
Visualforce-pagina: /apex/c__ExampleHome

caused by: line 8, column 40: Public remoted methods not allowed in global components


The weird thing is that this error shows up sometimes even after only changed a space or something else small. This error keeps showing up, just untill I reupload the VisualForce page. After that, it works immediately and the error is gone. As you can see, I have no Global classes or Public classes and its all run from Salesforce itself. The odd thing is that the moment I recompile/reupload the VisualForce page everything is working again.

Has anyone seen this error before? And perhaps know where I'm doing things wrong? 
 
Waqar Hussain SFWaqar Hussain SF
Define you remoteAction method and class as global, it probably solve your problem.
Ron PlankenRon Planken
Thanks for the info. We were kinda trying to not go that route quite yet and hope there was a different solution for it.
Brandon FeatherBrandon Feather
Ron I have been running into the same issue what did you end up doing?
Ron PlankenRon Planken
Brandon, unfortunatly the only solution we found was to actually make the classes and methods globals.. It works like a charm now, but it does have the downside of all globals being kinda permanent.