I added a classpath variable (via eclipse's build path) that points to a cache of jars. While this folder is represented in eclipse's folder view, the contained jars are not recognized for some reason.
For example, when I import a class that is present in a jar in the cache (and thus the added classpath variable), eclipse indicates that the class can not be resolved.
Any ideas what is wrong and how to resolve it?
You have to make sure that the jar(s) that you want are actually included in the classpath of the project you're working on. Right-click on the project, go to properties -> java build path and make sure you've added the jar to your project.
I think this is the problem you are having : https://bugs.eclipse.org/bugs/show_bug.cgi?id=70417
So go vote for the enhancement - it's the only way things like this get done!
I too struggled with the same problem and finally got the solution for it. Just copy the jar's in your server's lib folder eg)apache tomcat's lib folder and then run the project.
Related
I am trying to import a maven project (import->existing maven project) into eclipse and it is showing up in eclipse using the generic java project structure as opposed to the maven one. I have tried several versions of the m2e connection and all have the same problem. So for example instead of the following folders/packages/files I have:
src/
main.java.my.package.name
myfile.java
test.java.my.package.name
testfile.java
etc.
instead of the maven project structure
src/main/java
my.package.name
myfile.java
etc.
Any assistance appreciated, thanks!
For the sake of completeness:
This happens sometimes due to a race condition in eclipse.
As you already found out: if it happens, it happens only once, on initial import. So your way was almost correct:
Remove all source paths
do not add them manually
instead, right-click on the project and select "Maven -> Update project" and accept the default settings. Now the source paths will be set correctly
Woops, right after posting I was able to get it to work.
I had to go to project -> build path -> Source and remove the src/ folder and add the src/main/java, src/main/resources, etc. folders and it all works now.
Thanks for looking y'all!
My previous question about a problem I had, led me to numerous file path changing in order to come up with an answer that caused Maven not not to work properly (apparently Maven is not fond of sub-source-folders).
I changed the project folders to adhere Maven's standard directory layout and put log4j2.xml under src/main/resources/META-INF and the problem returned.
For some reason a Folder in eclipse is not on classpath.
How do I make it work?
EDIT:
I'm using the latest m2e to manage project's build and packages.
The project (is currently) consists of several sub-projects.
The parent pom defines the different modules and Java's compiler version. The pom of the module containing the META-INF folder, states several dependencies, nothing more.
rightclick on your project -> add source folder -> select your resourcefolder. done.
The solution in Eclipse Oxygen.3a is to right-click on the folder -> Build Path -> Use as Source Folder.
I have a .war project in Eclipse. It is probably not relevant but I should mention that it was converted from a maven project using mvn eclipse:eclipse plugin.
I saw a warning that various .jar files on the Build Path were not being exported. To fix this I went to Project Properties -> Deployment Assembly and added the jars that needed to go into the .war
However, one .jar file does not need to go into the .war because it will be provided by the container. It is on the build path merely to get the project to compile.
For this .jar file, I want to get rid of the warning. One way was to Ctrl+1 to QuickFix which caused the Properties->Java Build Path->Libraries tab->...jar file to have an extra line on expanding it which says: Excluded from publish/export structure: (None)
My question is how could I have done this without Quick Fix? I could not find any way to exclude from publish/export structure without using the Eclipse Ctrl+1 Quick Fix.
There is no other UI beyond the quick fix for setting the ignore flag.
m2e-wtp automatically takes care of this for you - any dependency that has the scope as provided is excluded from the publish\export structure.
I have created an eclipse plugin/bundle which needs some additional jar-files. these jar-files are located in the 'lib'-folder and added to the build-path. so far, so good.
If I launch the application which uses the bundle, I get exceptions. It looks like the required jar-files are not known anymore. I'm confused.
all of our bundles (the others work fine) appear in the bundle cache (../configuration/org.eclipse.osgi/bundles/) and they contain their.jar + the lib-folder with all jars this bundle needs.
in the problematic bundle the lib-folder is missing.
other bundles from other people do not appear at all in this cache. why? should they appear there? if not, what am I doing wrong? if yes, how do I have to configure my bundle that it doe not miss the required jars?
can anybody help with this issue?
Which build path did you add them to? The project one, or the MANIFEST.MF->runtime->Classpath one? They need to be in the MANIFEST.MF file for them to be on the classpath at runtime.
Even though the lib is on the build path, it may not be included in the build output. Open the plugin.xml or plugin manifest file, select the Build tab. Examine the *Binary Buil*d section to see if the JAR(s) from /lib are being included.
Occasionally I see eclipse lose the reference to the third party jars contained in the a projects. (you get the the build path error stating the jar cannot be found)
Its easy enough to fix as you can remove the jar, save the properties of the project and then go in and re-add the jar that it could not find, eclipse can then see the path to the jar and you can then compile again.
the problem is that if you have a lot of projects in your build you would have to do this task a lot.
Is there anything you can do to force eclipse to recognise that it actually has the jar on its classpath?
I have also faced the similar situation many times with my projects in eclipse. The jar file path is correct in the .classpath file and the jar is present still eclipse do that. To fix it you open the .classpath file and resave it and refresh the probject in eclipse and it builds fine.
That's a weird behaviour...
If that's ok you can use Maven 2 for your projects. This means that you have to follow Maven's project structure, which is quite ok, but it can be a pain if you decide to migrate old projects.
Then you can run mvn eclipse:eclipse whenever you want and that will fix your problem in a few seconds.