Eclipse wiping my .classpath

1.5k Views Asked by At

I'm using Eclipse Java EE IDE for Web Developers (Kepler Service Release 1) and this morning it started throwing the following exception:

eclipse.buildId=4.3.0.M20130911-1000
java.version=1.6.0_45
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean -data c:\dev\workspaces\workspace-moneris\

Error
Tue Dec 10 10:10:43 AST 2013
Exception while reading /PC_war/.classpath

java.io.IOException: Bad format
    at org.eclipse.jdt.internal.core.JavaProject.decodeClasspath(JavaProject.java:915)
    at org.eclipse.jdt.internal.core.JavaProject.readFileEntriesWithException(JavaProject.java:2497)
    at org.eclipse.jdt.internal.core.JavaProject.readFileEntries(JavaProject.java:2507)
    at org.eclipse.jdt.internal.core.JavaProject.writeFileEntries(JavaProject.java:2895)
    at org.eclipse.jdt.internal.core.JavaModelManager$PerProjectInfo.writeAndCacheClasspath(JavaModelManager.java:1352)
    at org.eclipse.jdt.internal.core.JavaModelManager$PerProjectInfo.writeAndCacheClasspath(JavaModelManager.java:1364)
    at org.eclipse.jdt.internal.core.SetClasspathOperation.executeOperation(SetClasspathOperation.java:77)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:793)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3096)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3058)
    at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3111)
    at org.eclipse.jdt.apt.core.internal.generatedfile.ClasspathUtil.updateProjectClasspath(ClasspathUtil.java:208)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager.addToClasspath(GeneratedSourceFolderManager.java:117)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager.ensureFolderExists(GeneratedSourceFolderManager.java:192)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedResourceChangeListener.addGeneratedSrcFolderTo(GeneratedResourceChangeListener.java:123)
    at org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedResourceChangeListener.resourceChanged(GeneratedResourceChangeListener.java:92)
    at org.eclipse.jdt.internal.core.DeltaProcessingState$1.run(DeltaProcessingState.java:465)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:460)
    at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:291)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
    at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149)
    at org.eclipse.core.internal.resources.Workspace.broadcastBuildEvent(Workspace.java:382)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:139)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

… and then replacing my .classpath with the following:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path=".apt_src">
        <attributes>
            <attribute name="optional" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="bin"/>
</classpath>

Obviously this is causing problems...

Any idea why this is happening?

2

There are 2 best solutions below

1
On BEST ANSWER

Check that there isn't a space in the XML declaration line:

[no space here]<?xml version="1.0" encoding="UTF-8"?>
0
On

Check that the XML syntax is valid, for example by

  • opening the .classpath file in an editor that highlight XML syntax errors (e.g. Emacs, but not Eclipse, ironically),
  • running xmllint --format .classpath