eclipse nullpointer exception for modulare maven project update - eclipse

I'm using Eclipse 4.4.1 with m2e plugin and the latest gae dependencies. When I import the gae module sample project eclipse tells me that the project configuration is not up to date. If I run the suggested maven -> update project, I get a NPE.
There are a lot of bug reports according NPE on project updates out there. So far I've tried it with mvn eclipse:eclipse or maven project imports, in fresh or existing workspaces but I was never able to get the projects running in eclipse.
Are there any solutions to this?
EDIT:
That is the stacktrace:
java.lang.NullPointerException at
com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
at
com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
at
com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
at
com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)
at
org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:120)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:477)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:1)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:470)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProjects(ProjectConfigurationManager.java:250)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:163)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:1)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96)
at
org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1348)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:133)
at
org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob$1.doCreateMavenProjects(ImportMavenProjectsJob.java:73)
at
org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62)
at
org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob.runInWorkspace(ImportMavenProjectsJob.java:82)
at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

You can comment out the appengine-maven-plugin to solve the problem, but by doing that you lose the command-line capabilities of the plugin. You can have the best of both worlds (Eclipse and Maven command-line) by using Maven profiles:
<profiles>
<profile>
<id>gae</id>
<build>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
</build>
</profile>
</profiles>
To activate it, for instance, to deploy the project from the command-line, you can do:
mvn appengine:update -P gae
When defining the appengine-maven-plugin only inside a profile, Eclipse won't use it, and the bug goes away. When using the command-line, just remember to activate it using the -P flag.

I had the same problem suddenly appear in one of my projects. Disabling the JPA validator seems to have resolved the issue for now.
Select Windows > Preferences > Validation
Disable the JPA Validator for both Manual validation and Build validation
It might be related to the "The persistence.xml file does not have recognized content" error described in here: www-01.ibm.com/support/docview.wss?uid=swg21616684 .

I had the same issue after updating from Eclipse Kepler (4.3) to Luna (4.4). Commenting out the app-engine-maven plugin from my pom.xml fixed it for me.
<!--
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
-->
I'm able to run and deploy my app without any issues so far.

seem to be a duplicate of An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
got to preferences / Server / Runtime Environemnt
--> select "Google App Engine" and associate a valid SDk to this runtime.

Related

MILO OPC-UA Download with Maven

I tried to use the milo opc-ua Implementation. At first I download the source with Eclipse/Maven to my local working directory.
File -> Import -> "Checkout Maven Projects"
The Download works fine for me. After this, I tried to update the project files.
Right-Click -> Update Maven Project
The "build-tools" work well for me, everything is done without any errors. But when I try this with the other "folders" (client-examples, ...) I get the following error:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (execution: validate, phase: validate).
The following code shows the pom-file of the client-examples:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent>
<groupId>org.eclipse.milo</groupId>
<artifactId>milo-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>client-examples</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-client</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>server-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
The pom.entries, shown in https://github.com/eclipse/milo, are in the file. I also checked this for the other sources. But whats going wrong?
I'm using eclipse-neon and maven2eclipse.
Thanks for helping,
Andreas
The errors says that the M2Eclipse plugin has no idea how to map the execution of checkstyle into some build step for the IDE. M2Eclipse tries to set up your local IDE project to replicate the behavior of the Maven build.
By default M2Eclipse is missing the support for the checkstyle Maven plugin. Therefore you get this error. There are two ways to handle this:
You can simply make Eclipse ignore those errors
You can install the checkstyle plugin for Eclipse and have checkstyle run the same way the maven build does it, getting all validation information right into your IDE.
In order to install checkstyle do the following:
Locate the location where the error is reported in Eclipse, issue the "Quick fix" command (normally Ctrl-1)
Select "Discover new m2e connectors":
Review the dialog and press "Finish":
Wait and let Eclipse restart
That should be it.

m2e error in MavenArchiver.getManifest()

I am seeing an error in my STS and am not sure how to debug it. Searching around I only see vague references to the error and no solutions.
The error is:
org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) pom.xml /<maven projectName> line 1 Maven Configuration Problem
Question: Can anyone give any suggestions on how to get more information on the issue in order to debug it further or any possible solutions?
Maybe some more context on what the functionality of method is. The javadoc associated with the MavenArchiver.getManifest() method is not very detailed and there is no stack trace that I see. I've tried several refreshes and updates of the project and associated projects including clearing my local m2 repo.
STS info:
Version: 3.7.3.RELEASE
Build Id: 201602250940
Platform: Eclipse Mars.2 (4.5.2)
m2e info:
Version: 1.6.2.20150902-0002
I encountered the same issue after updating the maven-jar-plugin to its latest version (at the time of writing), 3.0.2.
Eclipse 4.5.2 started flagging the pom.xml file with the org.apache.maven.archiver.MavenArchiver.getManifest error and a Maven > Update Project.. would not fix it.
Easy solution: downgrade to 2.6 version
Indeed a possible solution is to get back to version 2.6, a further update of the project would then remove any error. However, that's not the ideal scenario and a better solution is possible: update the m2e extensions (Eclipse Maven integration).
Better solution: update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to the following URL:
https://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
Then follow the update wizard as usual. Eclipse would then require a restart. Afterwards, a further Update Project.. on the concerned Maven project would remove any error and your Maven build could then enjoy the benefit of the latest maven-jar-plugin version.
Additonal notes
The reason for this issue is that from version 3.0.0 on, the concerned component, the maven-archiver and the related plexus-archiver has been upgraded to newer versions, breaking internal usages (via reflections) of the m2e integration in Eclipse. The only solution is then to properly update Eclipse, as described above.
Also note: while Eclipse would initially report errors, the Maven build (e.g. from command line) would keep on working perfectly, this issue is only related to the Eclipse-Maven integration, that is, to the IDE.
I found my answer! I looked into the pom for any plugins that have a dependency on the maven-archiver and found the maven-jar-plugin does. It was using the latest 3.0.0 version. When I downgraded to 2.6 it seems to fix the issue :-)
I had the same problem with a spring boot project. the solution was to downgrade the jar maven-jar-plugin from 3.2 to 2.6 . i had just to add this to the project pom:
<properties>
<maven-jar-plugin.version>2.6</maven-jar-plugin.version>
</properties>
I had exactly the same problem. My environment was:
Spring STS 3.7.3.RELEASE
Build Id: 201602250940
Platform: Eclipse Mars.2 (4.5.2)
The symptoms of the problems were:
There was a red error flag on my PM file. and the description of the error was as described in the original question asked here.
There were known compilation problems in the several Java files in the project, but eclipse still was not showing them flagged as error in the editor pane as well as the project explorer tree on the left side.
The solution (described above) about updating the m2e extensions worked for me.
Better solution (my recommondation):
update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to the following URL: https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
Select the m2e extensions, accept the license.
After update, you will be asked for restarting STS. The problem goes away after STS comes back up.
I had the same problem with a spring boot project. The solution was to downgrade the spring-boot-starter-parent dependency version from 2.0.0.RELEASE to 1.5.10.RELEASE(you can move to any stable version)
from:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
to
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I had also faced the same issue and it got resolved by changing the version from 3.2.0 to 2.6 as shown in below pom.xml snippet
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>Spring4MVC</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Upgrade your m2e extensions instead downgrade.
From Help > Install New Software.., add a new repository (via the Add.. option)
Specify name for your plugin and add path http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
once you are done with installation, please restart eclipse and update your project.
I also faced the similar issues, changing the version from 2.0.0.RELEASE to 1.5.10.RELEASE worked for me, please try it before downgrading the maven version
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
I solved this error in pom.xml by adding the below code
spring-rest-demo
org.apache.maven.plugins
maven-war-plugin
2.6
I had also faced the same issue and it got resolved by commenting the version element in POM.xml as show.
org.apache.maven.archiver.[MavenArchiver](https://maven.apache.org/shared/maven-archiver/apidocs/org/apache/maven/archiver/MavenArchiver.html).getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.5.1</version> -->
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<!-- <version>3.1.0</version> -->
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
Use the steps given in this link. It worked for me.
Step - 1 Right click on your project in Eclipse
Step - 2 Click Properties
Step - 3 Select Maven in the left hand side list.
Step - 4 You will notice "pom.xml" in the Active Maven Profiles text box on the right hand side. Clear it and click Apply.
Step - 5 Run As -> Maven clean -> Maven Install
Hope it helps!

An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Could you help me?
Thank you.
I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.
For me worked the answer I found on CodeRanch, by user Maneesh Godbole:
Close eclipse.
Navigate to your "workspace" folder
Ensure the setting on your OS to view hidden files is turned on
Identify and delete the .metadata directory
Restart eclipse
Import project
I've had the same problem in one of my modules.
Running "mvn eclipse:eclipse" in the console/cmd solved the problem for me.
In our instance of this problem, we had pom.xml files where the m2e-specific life cycle mapping configuration
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
...
did not have the <version>1.0.0</version> part. When doing a Maven -> Update Project..., this causes the reported NullPointerException without a stack trace. When using a fresh Import... -> Existing Maven Projects, the same exception occurred, but with a stack trace that led me to find the above.
(This is with m2e 1.6.1.20150625-2338 in Eclipse Luna Service Release 2 (4.4.2).)
In case it helps anyone, in addition to deleting .settings and .project, I had to delete .classpath and .factorypath before being able to import the project successfully into Eclipse.
org.eclipse.m2e.core.prefs file is in .settings folder. If you face the problem of
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Delete the project from eclipse then by deleting the .settings folder & .project file in the project -> then re-import the project.
None of the above methods worked for me. This might also arise due to the presence of circular dependency in your eclipse workspace. So if there are any other errors present in any of the other projects in your workspace, try to fix those and then this issue will be gone. This is how i eliminated the error.
This helped me: Project menu -> Clean... -> clean all projects
Eclipse has an error log. There you will see the complete stack trace. In my case it seems to be caused by a bad jar file combined with the java.util.zip libs not throwing a proper exception, just a NullPointerException.
I'm using:
Eclipse Java EE IDE for Web Developers.
Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
The fix/trick for me was deleting my local repository in ~/.m2/repository in order to remove local dependencies and rebuilding my project in which fresh dependencies are pulled down.
Above solutions did not work for me as the issue with open JDK 13 version
https://github.com/spotify/dockerfile-maven/issues/163
So I degraded to open JDK8 and it works for me
I had the same problem. None of the solutions here worked. I had to completely reinstall eclipse and make a new workspace. Then it worked!
I had this same issue across multiple projects and multiple workspaces, none of the solutions I found online worked for me. I'm using STS and the only thing that worked was to go into my STS directory and add a "-clean" to the top of the STS.ini file. You can then start up your workspace and run maven clean without errors. (you can also remove the -clean tag from the ini file so it doesn't clean everytime you start it)
Hope this helps someone.
The root issue in my case was a file conflict in the .settings folder. So, deleting the .settings folder would have resolved the Maven error, but I wanted to keep some of my local configuration files. I resolved the conflict, then tried a Maven update again and it worked.
I had the same issue ... solution at the end !
here the eclipse log:
java.lang.NullPointerException
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
at com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
at com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)
... it comes from "appengine maven wtp plugin" that try to get the type of GAE runtime, but seems to be null here (... getRuntimeType() --> NPE):
see class com.google.appengine.eclipse.wtp.maven/GaeRuntimeManager.java
private static IRuntime getGaeRuntime(String sdkVersion) {
IRuntime[] runtimes = ServerCore.getRuntimes();
for (IRuntime runtime : runtimes) {
if (runtime != null && **runtime.getRuntimeType()**.equals(GAE_RUNTIME_TYPE)) {
So, if you check in eclipse, Google App Engine is visible , but when you select it you'll see that no SDK is associated ...
SOLUTION:
in red on the screenshot ;-)
I encountered this same symptom and none of the solutions above were helpful. I finally got a stack trace of the problem by importing the ear project again to eclipse, and was able to trace this down to the org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement which was trying to delete a directory in windows' temp directory called ".mavenDeploymentDescriptorManagement", which caused an irrational NullPointerException from the java.io.File.exists() method, particularly because the code already had successfully done the same thing in a previous method with the same variable, then called file.isFile() without problem.
Checking this out on the file system revealed that the file could only be accessed with administrator privileges. Apparently I had at some point launched eclipse from an administrator console by mistake.
In the end I just made hidden files visible in windows explorer and deleted the temporary file manually, which solved the problem.
Just another possible source of the problem!
I found out that in my case it was the following resource block that caused it:
<project>
<build>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
<resources>
</build>
</project>
It included a folder from the project folder (the eclipse project is a subfolder of the versioned project folder).
In my case, I could remove the error by removing the block and replacing it with a call to the Build helper Maven plugin:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>my-own-very-cool-id-for-this-step</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I had to reinstall eclipse, delete .m2 folder and rebuild the jars.
deleting the local maven repository helped me
In my case, the problem was a conflict of derived dependencies that were been used by other dependencies, and some of those derived dependencies versions were not available, maybe because some deploy that i forgot to do because with workspace resolution everything worked, but when moving to other environment all broke suddenly.
And also I was working with version ranges
maven was giving me this error:
Could not resolve dependencies for project
MyProject:MyProject:jar:1.0.0: Could not resolve version conflict
among Dependency-A:1.0.1 -> Dependency-B:1.1.0 ->
Dependency-C:1.0.0, Dependency-X:1.0.1 -> Dependency-Y:1.1.0 -> Dependency-C:1.0.0, Dependency-I:1.0.1 -> Dependency-J:1.1.0 -> Dependency-C:1.0.0
I tried all above and nothing worked, so...
THE SOLUTION: Use LATEST as version in all dependencies, so maven don't need to resolve all dependencies in ranges, wich must be used
with care because if you miss to deploy one of the dependencies the
build will fail
Only I suggest you to use LATEST if you are working with your own dependencies, otherwise in some third party future version, you could find some compilation or runtime errors
Avoid deleting the .metadata folder as it cleans up all settings, run configurations.
Instead, rename the .metadata folder --> Restart eclipse --> Import project
deleting the local .settings folder helped me
solution step is delete following files in project folder
.settings
.project
.classpath
I solved this problem like this: Project -> Clean -> %YOURPROJECT%
Click Here for image

Eclipse error with osgi + maven + maven-pax-plugin

I am trying to create an OSGi bundle and integrate it into eclipse. I am using the maven-pax-plugin to create the bundles. These are the steps I follow
I create an osgi project using pax
mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId=osgi-project -Dversion=1.0-SNAPSHOT
and then create a bundle
mvn pax:create-bundle -Dpackage=org.sonatype.mcookbook -Dname=osgi-bundle -Dversion=1.0-SNAPSHOT
and then try to import the maven project into eclipse (file/import/existing maven project) the bundle project created in the second step always gives me this error
maven-pax-plugin:1.5:compile (1 error)
Execution default-compile, in org.sonatype.mcookbook/pom.xml
maven-pax-plugin:1.5:testCompile (1 error)
Execution default-testCompile, in org.sonatype.mcookbook/pom.xml
When I select one of the errors the description says
No marketplace entries found to handle Execution default-compile, in org.sonatype.mcookbook/pom.xml in Eclipse. Please see Help for more information.
If i ignore the error and import the project anyway this is what eclipse complains about
Plugin execution not covered by lifecycle configuration: org.ops4j:maven-pax-plugin:1.5:compile (execution: default-compile, phase: compile)
Has anyone seen this? any ideas how to fix it?
I am following this tutorial but adding integration with eclipse. Note however that if I build it with maven and don't use eclipse at all it all works fine, the problem is in eclipse/m2e
I am using Eclipse Indigo SR2 and m2e 1.0.200
I get rid of this problem by following the comment in the generated POM and move the <extensions>true</extensions> down to the maven-bundle-plugin below giving:
...
<plugins>
<plugin>
<groupId>org.ops4j</groupId>
<artifactId>maven-pax-plugin</artifactId>
<version>1.4</version>
<!--
| enable improved OSGi compilation support for the bundle life-cycle.
| to switch back to the standard bundle life-cycle, move this setting
| down to the maven-bundle-plugin section
-->
<!-- WAS HERE -->
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<!--
| the following instructions build a simple set of public/private
| classes into an OSGi bundle
-->
<extensions>true</extensions> <!-- MOVED HERE :-) -->
<configuration>
...
Then update the project (Right click on project name in Project Explorer: Maven -> Update Project...), wait for the build to complete and the error is gone.
Hope that helps!
The new m2eclipse versions require that every plugin that affects the build is supported using a m2eclipse plugin. So the maven-pax-plugin is not yet supported. As this basically happens with most maven plugins out there I still use the old m2eclipse version.
Unfortunately the old version 0.12 download seems to have been removed recently. So probably you will have to wait till maven-pax-plugin is supported.

Eclipse WTP not publishing Maven dependencies

I'm trying to set up a basic hello world project using Eclipse Indigo and a Tomcat server. I created a dynamic project with a simple servlet. Tested the servlet and that worked fine. Then I enabled Maven support and added logback to my pom. I put a logging statement in the servlet's doGet method. When running the servlet, it complains it cannot find any bindings because the logback jars are not being copied into the Eclipse tomcat instance. I expected to find the jars published somewhere in here:
${workspace}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\
How do I get Eclipse to work with WTP/Maven properly? I also tried installing the m2e-wtp connector with no difference.
Check Deployment Assembly (context menu on project), there must be mapping Maven Dependencies -> WEB-INF/lib.
Coming from an ASP.NET background, I find it shocking how much work it takes to get a webapp running with Eclipse WTP and Maven especially if you are learning on your own. Hopefully this quick start guide will help someone else get up to speed quickly.
There are two ways to get a hello world project working in Eclipse WTP with Maven. You can create a Dynamic web project and then add the Maven nature or you can do the opposite.
Pre-requisites for Eclipse with update sites
"Web, XML, Java EE and OSGi Enterprise Development"
http://download.eclipse.org/releases/indigo
"Maven Integration For Eclipse"
http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
"Maven Integration for WTP"
http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
Startup configuration
Install copy of Tomcat 7 from http://tomcat.apache.org/download-70.cgi
Window -> Preferences -> Server -> Runtime Environment
Add Apache Tomcat 7.0 and select local installation directory
Option 1: Create Dynamic Web Project then add Maven Nature
Create new Maven project, select archetype
org.apache.maven.archetypes:maven-archetype-webapp
Change to Java EE perspective.
Create a new source folder, src\main\java. Notice how Eclipse is not smart enough to do this for you and also the ordering of the folders is incorrect.
src\main\java folder is listed after src\main\resources. This can be manually fixed later in the project properties.
Create a new servlet. Notice how Eclipse defaults this file in the wrong folder src\main\resources because the order is wrong. Instead, manually select src\main\java.
Change the URL mapping on the second page of the wizard to /* to make testing easier.
Now our servlet is ready but the dependencies on the servlet api are unbound. A) we can add the servlet api as a dependency to our project or B) we can bind to the Eclipse server config for Apache 7.0.
For option A, add this dependency to the pom:
.
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-api</artifactId>
<version>7.0.${set this}</version>
<scope>provided</scope>
</dependency>
For option B:
Project properties -> Java Build Path -> Libraries -> Add Library -> Server Runtime -> Apache Tomcat 7.0
Right click and run on server:
A blank page should come up in the internal browser like http://localhost:8080/${artifact}
Test of dependency publishing:
Add joda-time to the pom.
Add this line in the servlet created earlier for the doGet method and import the necessary dependencies:
.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println("The time is now: " + new DateTime().toString());
}
Reload the test page and the output should now be:
The time is now: 2012-03-03T14:14:29.890-05:00
Now if you want to play with Servlet 3.0 and annotations this is not enabled by default, for what reason I don't know.
First force Maven to use Java 1.6 by adding this to your pom, otherwise each time you update your pom the configuration will revert to Java 1.5.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
Open Project Properties -> Project Facets. Change the Version under "Dynamic Web Module" to 3.0, change java version 1.6
Create a new Servlet with class name AnnotatedServlet in src\main\java and notice how the #WebServlet annotation is auto created.
Option 2: Create Dynamic Web Project then add Maven Nature
Select Tomcat Runtime and Dynamic Module Version 3.0
Create source folder src\main\java
Set default output target\classes
Set context directory src\main\webapp
Check generate web.xml
Create servlet with mapping /* for quick testing
Add an output statement to the doGet method
response.getWriter().println("Another test");
Double click the "Deployment descriptor" and add this attribute to the root web-app element metadata-complete="false"
Right click project and select Run As -> Run On Server
Right click project -> Configure -> Convert To Maven Project
Select packaging as war
Edit pom and set compiler to use java 1.6 and add joda-time dependency:
.
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Right click on the web project in Project Explorer then choose Maven -> Update Project
I faced a similar problem and although I had configured Deployment Assembly correctly it still didn't work. Then I found that under Window -> Preferences -> My Eclipse -> Java Enterprise Project -> Web Project, under the Deployment tab, the management of Dependent projects was turned off. I changed it to deploy jars of dependent projects to the lib folder and then everything worked like a charm. I could even turn off the Deployment Assembly option.