In my RCP plugin application, earlier having a folder at project level "neededJar" in which i have all external jar needed in project build
But now I want to put all jar at a common library say a lib folder in installation directory, at my workspace i added needed jar as project->build path->configure build path->add external jar it works but when I export the plugin project it is not able to resolve dependency.
I also tried to give it as class path variable but it did not work.
My classpath entry is as follow:
<classpathentry kind="var" path="MY_JAR"/>
<classpathentry kind="var" path="MY_JAR/MYClasses.jar"/>
<classpathentry kind="var" path="MY_JAR/jMYlex.jar"/>
<classpathentry kind="var" path="MY_JAR/MYsm.jar"/>
By digging i got to know, not sure about it I am missing some entry in Manifiest.MF and build properties.
Please count what are the steps that i am missing. Please suggest me through process to add external jar in plugin project
update: it is yet not answered well.
You could use a linked folder.
Create a new folder in your workspace, but open the "advanced" tab in the wizard. Chose "Link to alternate location".
Just be careful with references to folders outside your workspace, since they have a tendency to move from time to time :).
I'm using eclipse with svn and when I add some .jar files to my Build Path eclipse add the jar with the full path from the root.
I know for sure that the file will always be in a folder called lib in the same directory as my project:
for example:
~/lib
~/proj
Can I add the file taking my project's directory as a reference? Something like ../lib?
Because, right now, when somebody makes an update the Build Path needs to be changed...
Thanks a lot
under
Window > Preferences > java > Build Path > User Libraries
you can define user libraries, witch you can add to your class path. just say new type in a name (for example MY_EXTERNAL_LIB_FOO) and hit ok. Then select it (simple click) and hit add JAR..., you can then brows your jars and add the ones you want (multi select is possible)
the entry in .classpath will look something like this
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/MY_EXTERNAL_LIB_FOO"/>
this way you can abstract the location for the libs for your projects, they only need to know the name, Eclipse needs to know where the Libs for a name are located.
If you are versioning the libs too within you project then when editing the Build path hit add JARs... and not add External JARs... you will be prompted wi a list of all the project in the actual workspace, choose the onse you have in your project. the entries in .classpath will be relative to your project.
So if you have the following project layout
+ MyProject
+ src
+ lib
some_3rd_party_lib.jar
then the entry in .classpath will look like
<classpathentry kind="lib" path="lib/some_3rd_party_lib.jar"/>
The Maven plugin for Eclipse is finding relevant source code for one of my project's referenced libraries in my local Maven repository and adding a sourcepath attribute to my .classpath file.
<classpathentry kind="lib" path="lib/core/guava-11.0.1.jar" sourcepath="Users/<my_user>/.m2/repository/com/google/guava/guava/11.0.1/guava-11.0.1-sources.jar">
<attributes>
<attribute name="javadoc_location" value="http://docs.guava-libraries.googlecode.com/git-history/v11.0.1/javadoc/"/>
</attributes>
</classpathentry>
The problem is that I cannot commit the .classpath file because it contains a hardcoded path to my local maven repo. Is there a way to tell Eclipse to output that using a environment variable like M2_HOME? Even if it's not automated, is there any token that I can put in there that will let it resolve the location of the source without the hard-coded path? I tried:
sourcepath="$M2_HOME/com/google/guava/guava/11.0.1/guava-11.0.1-sources.jar"
but Eclipse could not resolve the location of the source for this library after I made this change.
Any ideas?
With maven 2 you can set the M2_REPO classpath variable in Eclipse and maven eclipse:eclipse will use it automatically in your .classpath file. Details can be seen here: http://www.mkyong.com/maven/how-to-configure-m2_repo-variable-in-eclipse-ide/
We've not yet migrated to maven 3 so I am not certain, but I imagine the variable needs to be named M3_REPO for maven 3.
You're right that committing the .classpath or .project files is not a good idea.
However, in the same way that m2e added that value, as would the plugin for other users. Maven will download the files required on the PC of another user if required (i.e. not in their local repo), and give the correct sourcepath in the .classpath file.
Hope that helps!
I would add "guava-11.0.1.jar" to a maven repository and then add it as a dependency in my pom.xml. By doing this you won't have "classpathentry" tags in your .classpath file.
After that I would turn on source downloading via the m2eclipse plugin (Window->Maven and check "Download Artifact Sources"). Using sources this way does not add any .classpath file entries.
I'm getting this warning in Eclipse:
Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result
After searching I found that I need fix export. I did it.
But this warning persists!
What else can be done to fix it?
Thanks.
You can right click on the warning, choose quickfix and choose one of the following:
Mark the associated raw classpath entry as a publish/export dependency.
Exclude the associated raw classpath entry from the set of potential publish/export dependencies.
As you will not have eclipse publishing/exporting the project it is safe to exclude it. But either way it makes no difference
Step by step screenshots:
http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp?topic=/com.ibm.javaee.doc/topics/tlooseclasspath.html
I had tried both of the options but only the latter is what you need:
Mark the associated raw classpath entry as a publish/export
dependency
Exclude the associated raw classpath entry from the set of potential
publish/export dependencies
If you export the dependency, refreshing the project configuration via Maven -> Update Project Configuration context menu will cause the warning to return. In this case you need to edit the .classpath file by hand:
<classpathentry kind="con" exported="true" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
Simply delete have the attribute exported="true" and confirm by refreshing the project configuration.
I had the same problem; it vanishes after including
<packaging>war</packaging>
in the pom. There was no packaging at all.
See this solution from Geert Schuring's blog:
On certain occasions Eclipse will present you with the following warning:
Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.
So solve this, do the following:
Open the properties of the project that generates this warning
Click on “Java Build Path”
Click on the tab “Order and Export”
Enable “Maven Dependencies”
Click on “Ok”
Open the “Problems” view
Select the warning we are trying to solve, and press “Ctrl-1″
Click on “Ok”
The problem is now solved. It may take some time before the warning
disapears because the project needs to rebuild before it goes away.
I wasn't able to solve the problem with the quickfix in Eclipse Luna. The problem disappeared after removing the Project Facet "Dynamic Web _Module". In Windows -> Preferences -> Project Facets.
P.S. Packaging as War also solved the issued but it was suppoused to be a JAR and I was puzzled why some projects worked ok and some didn't.
And by the way, the warning was real. It caused a ClassNotFoundExceptions exceptions in the server that made it unsusable when other projects referenced this.
Simply right click on the warning and do a quick fix
You can then review the .classpath file changes from source control
I have a simple way to solve this problem:
Delete the project from your Eclipse.
Into the work space where the project is located.
Delete the items selected in the following image. Just leave src and pom.xml.
Re-import the project in your Eclipse.
None of the answers helped in my case. Every time I update the project, m2e will delete the entry from the .classpath file which disables the warnings.
I've now filed a bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=537401
Most answers, including the currently accepted one, only provide a temporary solution to this issue: every time I chose Maven > Update Project… and leaving the option 'Update project configuration from pom.xml' on, the warning came back.
However, after installing m2e-wtp - Maven Integration for WTP in Eclipse 4.5 (Mars) and issuing Update Project… again, while leaving the option selected, the warning (and resulting error) went away.
I was in the same situation that Aaron Digulla.
I am learning Maven and noticed that this issue manifested when
I added a pom packaging line, for war
updated the project
removed said line and updated again
I noticed that the file ".settings/org.eclipse.wst.common.component" was one of the leftover files after this operation. When I removed this one in particular and updated the project, the Warning would go away and it wouldn't come back unless I repeated it all again.
Using Eclipse Photon, the configuration below fixed the problem for me:
Window > Preferences > Maven > Java EE Integration > Enable Java EE Configuration
Note that I disabled this option before receiving the warning
Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported
All other options may not be checked if you do not need them.
The warning does not reappear after a Maven update.
I had the same issue after updating my JDK in project and resolved it by replacing my .classpath file with previous one.
I noticed the following changes in my .classpath file
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
The second line was missing from above code
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
This line was missing
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
These lines were added so I manually removed them and it all worked again.
I had the same problem in a maven project with dynamic web project, but I solved it like this.
Right click on the project
Properties
Deployment Assembly and button "add".
Select Directive Type "Java Build Path Entries"
Select "Maven Dependecies" and select button finish
This way when the "war" file of the final project is created, all the "jar" files from the "Maven Dependencies" directory will be added.
Adding to the pom.xml:
<properties>
<java.version>1.8</java.version>
</properties>
helped me in this case and also with Dynamic Web Module and other issues.
I came across this issue too!
I Believe that eclipse adds the same deps twice.
once in the
Maven Dependencies
Group and another in the form of
M2_REPO/ ...
You must remove the last one in the
Properties -> Java Buil Path -> Libraries
for the error to dissapear!
That's the typical problem with maven projects configured in Eclipse that are changed its configuration or saved inappropriately.
Normally I'll edit my .classpath file and check the references for the build path, etc.
So in your case, I think you'll need to delete your classpathentry with those org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER reference inside.
I have a basic web application (dynamic web project in eclipse) with an associated EAR project. I am trying to make sure that my junit test code stays out of the deployment EAR file.
In my web project I have a source folder called "src" and one called "test". I need to keep the .class files from the "test" source folder OUT of the EAR when I export it using eclipse.
I know this is trivial using ant but seems impossible using eclipse.. right click project and export the ear file.. the test classes are always included.
If I manually edit the .setting/org.eclipse.wst.common.component.xml file to remove the tag associated with the test folder it works but if some other developers change anything related to the build path, it gets regenerated...
Am I missing something obvious.. I've googled like crazy to no avail.. checked eclipse's docs and am at a loss..
It doesn't seem to be directly possible, which is bizarre. Here's a couple of workarounds you could try.
Note I'd move the java files from the web project to a Java project (this is probably a good practice to follow anyway). Either way create another "test" Java project and move the test sources to that project. Your test project declares the "main" Java project as a dependency so it has access to the types for testing, but isn't included in the war, so the test classes won't be deployed.
Alternatively if you want to keep the sources in one project, you can configure the test project to use linked resources. I've posted another answer that shows how you can use linked resources to share source locations across projects. With this approach the test sources still aren't on the build path for the main project, so won't be bundled in the jar, but are physically located in the project so source control is simpler.
I'm doing something similar, except with PDE, Using Eclipse 3.7.
I am deploying Eclipse/OSGi plugins/bundles, and have two java source directories: src and test
I've tweaked the contents of two eclipse project files to separate test code from the build.
.classpath:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry export="false" kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry export="false" kind="lib" path="/thirdparty/junit/junit.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
These changes were motivated by reading this
I don't know if this will apply to your situation, but I also had to modify a build.properties file, to exclude the results of compiling 'test' from the produced jar file.
source.optimizing.jar = src/
#This doesn't contain test/ because we don't want it in the build.
bin.includes = META-INF/,\
optimizing.jar
#The junit.jar is also exluded
When I build the entire project, the test files are completely absent.