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
MystwalkerMystwalker 

Eclipse does not save Appex classes to server

I've made some changes last week on some of my Appex classes and this morning with the same configuration and when I try to save my changes on the server I get this error message:

 

File only saved locally, not to server

 

So I've created a new project, a new workfolder and  made a checkout of everything and without even changing the code, I still get this error. I have some Appex pages too, but they work fine (compile ans save on server).

 

I notice on ''Monitor Deployment'' that the deployment status is supposedly completed and all my classes have the API version 15 but when I create new classes I can only select API version 16 now. Is this related to my problem?

 

Does some of you knows a good way to fix this?

Best Answer chosen by Admin (Salesforce Developers) 
rocwilcoxrocwilcox
Once you write unit tests and they cover atleast 75% of your lines of code, the restriction to save to server is released and everything is normal.   Btw..I upgraded eclipse thinking something was wrong too :)

All Answers

JonPJonP

What version of the Force.com IDE are you using?  When you get the "File only saved locally" warning, are there any additional messages displayed in the Problems views?

 

What type of organization are you working in?  Developer Edition?  Sandbox?  Production?

 

Thanks,

Jon

salesforce.com Product Manager

MystwalkerMystwalker

Hi Jon,

 

I'm using Eclipse Platform version: 3.4.2 with Force.com IDE 16

 

And ''File only saved locally'' is the only warning I get in the Problems views.

 

I'm not really sure how to check my Organization Type, but it's not Sandbox for sure.

 

JonPJonP

When you log into your organization in a browser, if you view an Apex class, can you edit it?  Or can you create a new Apex class?  (Production organizations only allow you to create or modify Apex code by deploying it via the Metadata API, using the Force.com IDE or the Force.com Migration Tool for Ant.  You cannot simply create or edit classes in the browser.)

 

 

In the Force.com IDE:

 

If you right-click (option-click) on the top-level project folder in Project Explorer, is Force.com > Work Offline checked?

 

If you edit your .cls file (add a new space character or something) and save it, does the Problems view change?

 

Can you right-click on the .cls file and choose Force.com > Save to Server?

rocwilcoxrocwilcox

I had this problem starting on 7/1/2009 as well.  Do you have unit tests for all your classes?

Try a 'run tests' or 'deploy' and you'll get more diagnostic information.

Apparently this rule about unit testing has been in effect for a while, but not enforced untill recently (as far as I can determine)

 

MystwalkerMystwalker

Okay,

so my Organization Type is production, I cannot modify or create Apex classes in my browser.

 

-Workoffline isn't checked

-Adding a space to a line in a previously working Apex class doesn't change the problems view (same warnings)

-when I save to server I still get the File only save locally, not to server

 

I tough it could be my Force.com IDE configuration but I reinstalled a newer version and updated it and I still get the same warning

MystwalkerMystwalker

Hi rocwilcox,

 

It started the 1st july for me too and I don't have any tests for my classes. 

 

Does the information in your tests has helped you resolve the problem?

Message Edited by Mystwalker on 07-06-2009 12:01 PM
rocwilcoxrocwilcox
Once you write unit tests and they cover atleast 75% of your lines of code, the restriction to save to server is released and everything is normal.   Btw..I upgraded eclipse thinking something was wrong too :)
This was selected as the best answer
JonPJonP

We strongly recommend against creating Force.com projects in the IDE directly against production organizations.  Instead, you should use your Developer Sandbox to write your code and test methods, then deploy everything to production using the IDE's Deploy to Server wizard.  We provide a free Developer Sandbox with every Enterprise Edition or higher production organization, so that you have a place to write code without meeting the strict requirements that apply to production.

 

Here's how to get started:

 

1. Log into your production organization in a browser and create a new Developer Sandbox (Setup | Data Management | Sandbox > New Sandbox).  This will copy all the configuration from your production organization, including the Apex code you've already written, into a new Sandbox on test.salesforce.com.

 

2. In the Force.com IDE, create a new Force.com project against your new sandbox.

 

3. Develop your Apex code and unit tests.  Right-click on one or more Apex classes, or the "classes" folder, then select Force.com > Run Tests to execute your test methods and see your code coverage.  When writing tests (and code for that matter), be sure to avoid referencing any records or configuration by Id, as these Ids may be different between your sandbox and production organizations. 

 

4. When you are ready to deploy to production, right-click on your project root folder and select Force.com > Deploy to Server.  This wizard will walk you through the process of uploading your code to your production organization.  The deployment will only succeed if all your new classes compile, all the test methods you are deploying and those already in your organization pass, and the overall code coverage in the organization after deployment would be 75% or higher.

 

 

MystwalkerMystwalker

Looks like the test coverage is really the problem.

 

Implementing test for all my apex classes seems time consuming considering that most of them will be untouch and are already working just fine.

 

Is there a way to bypass this for now and implement tests later?

JonPJonP

Test coverage for Apex code is an integral part of the Force.com platform and cannot be bypassed.

 

While it may seem like a burden when you have to write tests for a large body of code all at once, you'll find later that the investment really pays off--like the first time you make a change that breaks and old test, and you realize you would have broken something important in production had you deployed that code.  You will also find that writing tests as you go improves the quality of your code and forces you to look at problems more deeply.

 

Many new Force.com developers who started out as skeptics of the test coverage requirement have come to feel that it's a huge benefit (once they bit the bullet and implemented the tests so they could deploy to production).

AkiTAkiT

When developing in DE or sandbox, hitting save in force.com IDE should save in server as well. (taken you are not in Offline mode)

 

Check also that you have auto build enabled from Eclipse menu - Project - Build Automatically 

nuked planetnuked planet

Old post but I just encountered this exact issue. Bizarre issue was I had one project working fine, the other not.

A quick look at the Eclipse Project Properties->Builders uncovered a difference.

 

The broken one was missing the definition for the "Force.com Online Builder" - but how to add it in?

Rather than battle with the Eclipse IDE GUI I decided to look at the Eclipse Project files(i.e the .project files inside each workspace project directory)

 

Working .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>working@projectname</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.salesforce.ide.builder.online</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.salesforce.ide.builder.default</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.salesforce.ide.nature.default</nature>
        <nature>com.salesforce.ide.nature.online</nature>
    </natures>
</projectDescription>

 

File Saved Locally Only Issue .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>broken@projectname</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.salesforce.ide.builder.default</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.salesforce.ide.nature.default</nature>
    </natures>
</projectDescription>

 

Spot the difference? :-)

A quick copy'n'paste effort later and a restart of Eclipse.... voila files now save server side.

 

Hope this helps anyone in the future.

 

 

nuked planet

sanjayrs23sanjayrs23
this was instant help. thanks nuked planet.
sidhartha nathsharmasidhartha nathsharma
it resolved my issue. Thanks you so much.