Eclipse, Tomcat & Maven workspace resolution: wrong folder structure? - java

I am trying to build a spring-mvc project that has another project (core, as .jar) as dependency.
If I disable "Resolve dependencies from workspace projects" in eclipse, install the core into my maven repo and run it from eclipse, the application works!
What I want to do, is re enable "Resolve dependencies from workspace projects", but there is the problem: When I try to run the project on tomcat (after maven clean, project clean), I get a "FileNotFoundException". The file in question is under src/main/resources/META-INF/spring/applicationContext-core.xml
It seems, the File can not be found in the classpath.
I looked up the deployment location and found out, that everything of the core is under the following folders:
WEB-INF
classes
So the file I am missing can be found here:
/WEB-INF/classes/META-INF/spring/applicationContext-core.xml
But it schould be here:
/META-INF/spring/applicationContext-core.xml
Why is the structure of my core dependency so messed up when I enable the workspace resolution and how can I fix this?
I am using eclipse mars with m2e..
Thanks for any help.
Edit:
Project structure (core) looks like this:
project structure

Related

Maven uses dependencies from workspace not .m2 folder

So I have the following project structure Sporium is a working set with the maven multimodule spigot-parent my problem now is when I define this pom.xml in my project it will not use the created dependency in the .m2 folder but instead it will use the files in the maven module project of my IDE's workspace which doesn't work because they are raw, unpatched and uncompiled files
as seen here. Any idea how I can tell maven to not use the version in my workspace and only search in the local repo .m2 folder?
Right click on the project, choose "Maven" and then disable Workspace resolution.
Then the projects are not resolved from your workspace any more.

Eclipse Luna, m2eclipse: empty dependency when dependency is a workspace project

I am working with Eclipse Luna.
I have a dynamic web project into my workspace: project-web. This project depends on another project into my workspace: project-lib.
So I get this scenario: project-web[:war] ---depends on--> project-lib[:jar]
I have checked "Resolve dependences from workspace projects" option into Properties -> Maven for the web project.
When I run "mvn clean package" for project-web Maven creates war file into the target directory but I have
an issue. If I explode the war file, I find an empty folder called "project-lib" into the WEB-INF/lib directory.
Since the library is empty I get some java exceptions on Tomcat startup.
How to create the war for project-web correctly?
Thanks in advance.
Enrico

Excluding svn directory when deploying to Tomcat in Eclipse

I have a Java project which is separated into 23 sub-projects that are all checked into a subversion repository. When they are checked out (not using the Eclipse SVN tool) there's a .svn directory on several levels of each sub-project. Then I run mvn eclipse:clean eclipse:eclipse on the whole thing (as these are Maven projects) I can import them into Eclipse and work there. So far, so good.
Here's the problem: When I deploy the project to Tomcat in Eclipse (oh yes, it's a web project) the .svn directories are also deployed. I can circumvent this by adding Resource filters in Eclipse (project properties -> Resource -> Resource Filters -> Add -> Exclude all, Files and folders, All children (recursive), Project Relative Path matches **/.svn) but every time I recreate the projects with maven (which I have to do ever so often) I have to recreate the filters for each of the 23 projects. Is there a better method to exclude resources for the tomcat deployment?
Note: I'm using
Java 1.6,
Eclipse Juno,
Tortoise SVN 1.7.6 (which comes with Subversion 1.7.4),
Maven 3.0.3 and
Tomcat 7.0.35
I am, sadly, not allowed to update anything. An ideal solution for me would be something like a global resource filter in Eclipse or some setting which would make Maven create Eclipse projects with such resource filters already set.
if you have the option to change the pom.xml, then I would expect that you can use sourceExcludes. That would be the automated version of your manual handlings.
There's also an example with svn files:
http://maven.apache.org/plugins/maven-eclipse-plugin/examples/specifying-source-path-inclusions-and-exclusions.html
Just use latest svn client - it will create only one .svn folder at parent folder.
Also, latest eclipse can import maven project without mvn eclipse:eclipse.

m2e maven eclipse plugin not configure the build path

I import a project to my workspace and convert it to Maven project using m2e and ran the pom file with goal specify "clean install".
But my project build path is not populating with the jars already downloaded to my local repository which still gives compilation errors in the source.
When i expand "Maven Dependency" variable in the library tab of build path, i can not see the jars already downloaded?
Was there existing Eclipse metadata when you imported the project, perhaps from another developer? This is a frequent cause of failure in Eclipse, especially if you have metadata from the earlier m2eclipse plugin.
I have encountered the situation many times (in Juno and Kepler) where the .classpath is incorrect, resulting in the symptom you describe, and I either have to rewrite the .classpath myself or nuke it and encourage Eclipse to try again.
In your case:
delete the project from your Eclipse workspace (but not the filesystem)
delete the subdirectories .settings and target, and the files .classpath and .project from the project directory
re-import the project into Eclipse via File -> Import... -> Existing Maven Project
The Eclipse dot-directories will be created from scratch, and the project should already be configured as a Maven project; artifact retrieval should start in the background.
If this fails, check the 'Maven Console' in Eclipse for clues, and/or the Eclipse Error Log.
As other people have commented, you need to ensure that your m2 settings file is being correctly interpreted by m2e.
Can you build successfully from the command line?

IntelliJ NoClassDefFoundError for jar Dependencies in other Modules

I had a perfectly running Eclipse project with Maven and project dependencies. Now I want to switch to IntelliJ IDEA - the import of my projects worked nicely (now called module with Maven and module dependencies), all the Maven configuration seemed to work out of the box (can expand libs and see source code).
When I run my module I get:
Exception in thread "main" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/XStream
From a dependent module, xstream-1.4.2.jar is correctly in the build path of that module.
What I tried and did not work:
Importing projects as Eclipse projects, applying Maven nature/framework support afterwards
Importing projects as Maven projects
Invalidate caches
Maven Reimport & Generate Sources and Update Folders
What worked but is not a solution: I can add the xstream-1.4.2.jar to the dependencies of the module I am running, but then it fails with the next missing jar. So it seems as if it does not find the jars referenced in referenced modules.
Often one encounters the NoClassDefFoundError when there are two libs in different versions on the classpath - I double checked, there is only one xstream*.jar file there.
I appreciate any help.
Thank you, Marcel
Is xstream-1.4.2.jar located in the correct groupid/artificatid/1.4.2/ folder under .m2 repository?
If you are running on linux, .m2 will be located under /home//.m2
If you are running on Windows, .m2 folder will be located under C:\Users\.m2

Categories

Resources