Eclipse project does not build with unhelpful error - eclipse
Eclipse is giving me a red X on a project. I compared this project to a similar one in another workspace. The classpath is different (it's supposed to be), and a few source files that are supposed to be. But the error in the problems tab says
"The project was not built due to "". Fix the problem, then try refreshing this project and building it since it may be inconsistent"
Yeah, that key spot where it seems like critical information would go just says "". I tried refreshing and rebuilding to no avail. The project is imported from outside the workspace. But that shouldn't matter, should it? I've done that before with no problems. But a similar project (the one I am comparing to) works fine in the workspace.
Where else can I look for error info that might help me narrow this down?
update - This project is used by others as a project reference, but this project does not rely on others. Here is it's classpath file contents:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.ibm.ws.ast.st.runtime.runtimeTarget.v70/was.base.v7">
<attributes>
<attribute name="owner.project.facets" value="jst.utility"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/WebSphere Application Server v7.0 JRE">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/antlr-2.7.6.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/aspectjweaver-1.6.8.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/cecore.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/celib.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/ceplugins_client.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/ceplugins_core.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/ceplugins_cr.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/cereports.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/cesession.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/ceutils.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/cglib-nodep-2.2.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/aopalliance-1.0.0.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/apache-commons/commons-beanutils.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/apache-commons/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/apache-commons/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/apache-commons/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/corbaidl.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/ebus405.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/hibernate/hibernate-3.5.1/hibernate3.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/icu4j-3.4.4.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/jasypt-1.7.1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/javassist-3.9.0.GA.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/joda-time-1.6.1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/jpa-api-2.0-cr-1.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/junit-4.8.2.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/log4j-1.2.5.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/buisnessObjects/logging.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.aop-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.asm-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.aspects-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.beans-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.context.support-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.context-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.core-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.expression-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.instrument-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.jdbc-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.jms-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.orm-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.oxm-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.test-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.transaction-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.web.portlet-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.web.servlet-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.web.struts-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/spring/spring-framework-3.0.1/org.springframework.web-3.0.1.RELEASE-A.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/poi-3.7-beta3-20100924.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/serialization.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/SL_plugins.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/slf4j-api-1.5.8.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/misc3rdParty/slf4j-log4j12-1.5.8.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-auth-roles-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-datetime-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-devutils-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-extensions-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-guice-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-ioc-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-jmx-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-objectsizeof-agent-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-spring-1.4.7.jar"/>
<classpathentry kind="lib" path="C:/views/SharedComp_Development/SharedComp_Software/jar/wicket/wicket-1.4.7/wicket-velocity-1.4.7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Sounds like the project has a dependency defined but the project name was removed. This can be done with the .classpath file is manually edited. I would try to remove all the dependent projects from the .classpath file.
You can do this from Eclipse by editing the build path and removing any projects. Then add the dependent proejcts back. This should clean up the .classpath file.
Thanks to Zagrev for helping, but it turns out, someone had checked our bin folder into our integrated source control and so eclipse wasn't actually able to compile the code. Once I deleted the bin and it could generate, it generated fine and the error went away.
Still, FANTASTICALLY unhelpful message there eclipse. Had the message directed me towards unwritable class files, I'd probably have found it right away. Instead I floundered for hours trying to figure out what was wrong with my .classpath or .settings.
Related
Eclipse Gradle Project - Classpath issue - ClassNotFoundException
I am running the below code in a gradle project in Eclipse. public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } I am getting ClassNotFoundException for this. The class runs fine in a maven project. Maven's .classpath file looks like this. <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java" including="**/*.java"/> <classpathentry kind="output" path="target/classes"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> </classpath> This is Gradle's .classpath file <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="bin/main" path="src/main/java"> <attributes> <attribute name="gradle_scope" value="main"/> <attribute name="gradle_used_by_scope" value="main,test,intTest"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/ org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/ JavaSE-11/"/> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> <classpathentry kind="output" path="bin/default"/> </classpath> Is there anything I need to add to build.gradle or make changes to .classpath file to make it work?
How to use eclipse as an IDE for hibernate-tools
I have cloned hibernate tools and I can build it from maven, however after running mvn eclipse:eclipse I get a .classpath that looks like <classpathentry kind="lib" path="h2/target/hibernate-tools-tests-h2-6.0.0-SNAPSHOT-sources.jar"/> <classpathentry kind="lib" path="h2/target/hibernate-tools-tests-h2-6.0.0-SNAPSHOT.jar"/> <classpathentry kind="lib" path="maven/target/hibernate-tools-tests-maven-6.0.0-SNAPSHOT.jar"/> <classpathentry kind="lib" path="maven/target/local-repo/antlr/antlr/2.7.7/antlr-2.7.7.jar"/> <classpathentry kind="lib" path="maven/target/local-repo/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar"/> <classpathentry kind="lib" path="maven/target/local-repo/com/h2database/h2/1.4.195/h2-1.4.195.jar"/> <classpathentry kind="lib" path="maven/target/local-repo/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar"/> <classpathentry kind="lib" path="maven/target/local-repo/commons-logging/commons-logging/1.2/commons-logging-1.2.jar"/> These jars are in my ~/.m2/repository but the specified location does not in fact have the jars ./hibernate-tools/test/maven/target/local-repo/dom4j/dom4j/1.6.1 dom4j-1.6.1.pom dom4j-1.6.1.pom.sha1 _remote.repositories How can I use eclipse on this projecgt?
Why is Eclipse not attaching 3rd party libs source files to a WTP-faceted Gradle project?
The sources are downloaded in the Gradle cache and the classpath-entries for the source files looks ok, but Eclipse does not show the source files for 3rd party libs. <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="output" path="bin/main"/> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="src/main/resources"/> <classpathentry output="bin/test" kind="src" path="src/test/java"/> <classpathentry output="bin/test" kind="src" path="src/test/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" exported="true"/> <classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework/spring-webmvc/3.1.2.RELEASE/source/bc9c347358c5d59998b27e8a13c75106c3d0696/spring-webmvc-3.1.2.RELEASE-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework/spring-webmvc/3.1.2.RELEASE/jar/e02f3e5aa91c8caa37b2e9b780229d27e76c0f2e/spring-webmvc-3.1.2.RELEASE.jar" exported="true"> <attributes> <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> <classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.data/spring-data-jpa/1.2.0.BUILD-SNAPSHOT/source/19e4dedbb956cdc3bb1d34d61a351229b653029a/spring-data-jpa-1.2.0.BUILD-SNAPSHOT-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.data/spring-data-jpa/1.2.0.BUILD-SNAPSHOT/jar/2a3cfc2ea0b2c8d87f32166e16bb56e1f092568b/spring-data-jpa-1.2.0.BUILD-SNAPSHOT.jar" exported="true"> <attributes> <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> <classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.security/spring-security-web/3.1.2.RELEASE/source/49e8d929d835d4ba4556ba9d138488ecc083a794/spring-security-web-3.1.2.RELEASE-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.security/spring-security-web/3.1.2.RELEASE/jar/e43e7683289f08c1e073564a94e6f26298ec4f59/spring-security-web-3.1.2.RELEASE.jar" exported="true"> <attributes> <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> <classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/javax.validation/validation-api/1.0.0.GA/source/7a561191db2203550fbfa40d534d4997624cd369/validation-api-1.0.0.GA-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/javax.validation/validation-api/1.0.0.GA/jar/b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e/validation-api-1.0.0.GA.jar" exported="true"> <attributes> <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> </classpath>
That's a weird behavior in Eclipse with the generated .classpath-file. Just put the 'Web App Libraries' entry at the bottom of your classpath file (-> Java Build Path -> Order and Export). The best solution is to enhance your gradle.build file (then you don't need to reorder your build path each time you generate the classpath file via gradle): ... eclipse.classpath.file { // Classpath entry for Eclipse which changes the order of classpathentries; otherwise no sources for 3rd party jars are shown withXml { xml -> def node = xml.asNode() node.remove( node.find { it.#path == 'org.eclipse.jst.j2ee.internal.web.container' } ) node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true']) } }
Differences in Adding jars in Eclipse Buildpath-Libraries & WEB-INF/lib folder
I recently faced an issue when deploying an Spring 3.0 based Web-Application in Eclipse Helios IDE. I have included the spring & its dependency jar files in BuildPath -> Libraries -> Add External Jars from my local repository(maven local repo). When I'm trying to start the server, it throws ClassNotFoundException, NOTE: I can find my Spring-web jar in Eclipse Buildpath-Libraries. SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387) at `enter code here`org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3786) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) .classpath file: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="rest-client/src/main/java"/> <classpathentry kind="src" path="rtsocketdatamonitor/src/main/java"/> <classpathentry kind="src" path="rtsocketdatamonitor/src/main/resources"/> <classpathentry kind="src" path="rest-client/src/main/resources"/> <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.2/commons-lang-2.2.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.2/commons-lang-2.2-sources.jar"/> <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.2/slf4j-api-1.6.2.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6-sources.jar"/> <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/> <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final.jar" sourcepath="M2_REPO/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar" sourcepath="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final-sources.jar"/> <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.6.0.Final/hibernate-entitymanager-3.6.0.Final.jar" sourcepath="M2_REPO/org/hibernate/hibernate-entitymanager/3.6.0.Final/hibernate-entitymanager-3.6.0.Final-sources.jar"/> <classpathentry kind="var" path="M2_REPO/cglib/cglib/2.2/cglib-2.2.jar" sourcepath="M2_REPO/cglib/cglib/2.2/cglib-2.2-sources.jar"/> <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/3.0.5.RELEASE/spring-aop-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/3.0.5.RELEASE/spring-aop-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-asm/3.0.5.RELEASE/spring-asm-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/3.0.5.RELEASE/spring-beans-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-aspects/3.0.5.RELEASE/spring-aspects-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aspects/3.0.5.RELEASE/spring-aspects-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/3.0.5.RELEASE/spring-context-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/3.0.5.RELEASE/spring-context-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/3.0.5.RELEASE/spring-expression-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/3.0.5.RELEASE/spring-expression-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-context-support/3.0.5.RELEASE/spring-context-support-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context-support/3.0.5.RELEASE/spring-context-support-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-test/3.0.5.RELEASE/spring-test-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-test/3.0.5.RELEASE/spring-test-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-jdbc/3.0.5.RELEASE/spring-jdbc-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-jdbc/3.0.5.RELEASE/spring-jdbc-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-tx/3.0.5.RELEASE/spring-tx-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-tx/3.0.5.RELEASE/spring-tx-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-orm/3.0.5.RELEASE/spring-orm-3.0.5.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-orm/3.0.5.RELEASE/spring-orm-3.0.5.RELEASE-sources.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-web/3.0.5.RELEASE/spring-web-3.0.5.RELEASE.jar" sourcepath="/SPRING_SOURCE_3.0.1/org.springframework.web-sources-3.0.1.RELEASE-A.jar"/> <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/> <classpathentry kind="lib" path="D:/ProgramJR/spring/servlet-api-2.5.jar" sourcepath="C:/Users/sasikumar.s/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="owner.project.facets" value="java"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="output" path="build/classes"/> </classpath> But, When i added the jars in WEB-INF/lib folder, the application runs properly.( Could not find above errors) Kindly clarify about the difference between "Adding jars in Build Path" and WEB-INF/lib folder. I'm not interested in adding jars to every project. Appreciate your help.
How to instruct Eclipse to record relative paths of the external jars?
Here is my .classpath file, after I have added two more external jars (org.restlet.ext.simple.jar and org.simpleframework.jar): <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.jackson.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src"> <attributes> <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/> </attributes> </classpathentry> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.ssl.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src"> <attributes> <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/> </attributes> </classpathentry> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src"> <attributes> <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/api"/> </attributes> </classpathentry> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.jsslutils_1.0/org.jsslutils.jar"/> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.core.jar"/> <classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.mapper.jar"/> <classpathentry kind="lib" path="../3rd_party/guice-3.0/aopalliance.jar"/> <classpathentry kind="lib" path="../3rd_party/guice-3.0/guice-3.0.jar"/> <classpathentry kind="lib" path="../3rd_party/guice-3.0/javax.inject.jar"/> <classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.simple.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src"> <attributes> <attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/> </attributes> </classpathentry> <classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.simpleframework_4.1/org.simpleframework.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Notice that they have been added with absolute paths, unlike other entries which are with relative ones, but only because I manually edit this file each time new external jars are added. My question is can I somehow tell Eclipse to use relative paths of newly added external jars? Thanks.
One solution is to not use external jars, but to put your jars into a project, and then use Add Jar(s) instead of Add External Jar(s). This makes sense from the point of view of source control, you can add/remove dependencies as you need them. It also means that when you update one jar for a separate project, it'll not affect this one. We've done this in the past, we had a single project which contained all of the jars, which were referred to in the build paths of other projects. But now we use maven, so we don't need to do that any more.
In eclipse, right-click the project, choose Properties, then Java Build Path, Libraries tab and select "Add Jars"... this will add it with a relative path. "Add External JARs" adds the jar with an absolute path which is not what you want.
If your paths are relative to your Eclipse installation, declare them using the “Add Variable…” button (in [Project] → Properties → Java Build Path → Libraries). There you should be offered a variable called ECLIPSE_HOME, which you can then Extend. This will produce a „kind=var“ entry in your .classpath(rather than a „kind=lib“). <classpathentry kind="var" path="ECLIPSE_HOME/... If your paths are relative to somewhere else you can declare your own variables (Configure variables). This way, when your workspace changes or someone makes a copy of it you just need to update these variables. This is often clearer than having true relative paths starting with one or two dots.
Please note that Eclipse relative paths should begin with a single dot. Instead of <classpathentry kind="lib" path="../3rd_party/example.jar"/> You need to use <classpathentry kind="lib" path="./../3rd_party/example.jar"/> The first method might sometimes work, but the second method works always. This is very confusing because you might have 5 entries in classpath that work with the ".." at the beginning and the others won't work with it. Change all references to begin with the single dot first.