Maven and eclipse: remove JRE System Library - eclipse

I am building a project against the CrEme VM Library. I want to configure maven and eclipse, to build only against this JAR. But m2eclipse "Update Project configuration" automatically adds the "JRE System library". I can fix it, by removing it in eclipse project classpath, but i want to configure it only in the pom.xml (and not checkin the eclipse settings).
I tried to do this:
// ...
<dependency>
<groupId>ch.sbb.cis-infra.mobile</groupId>
<artifactId>vmclasses</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
// ...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.3</source>
<target>1.3</target>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<debug>off</debug>
<compilerArguments>
<bootclasspath>''</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
But still, m2eclipse adds the "JRE System Library [JRE_1.3]".
Compilation on command line is correct, but in eclipse I can't see compile problems.
How can I remove the JRE in eclipse using the pom.xml configuration?
(Eclipse Helios SR2, m2e plugin 0.12.1)

Well, IMHO (I'm not sure) JRE container in Eclipse is because of Java nature of the project, not the Maven integration. Try to disable Maven nature of the project and JRE will be still there. If you have Maven-managed Java project (and your POM says that) Java nature in Eclipse is enabled causing JRE to be attached to the project.

Related

Versions Maven Plugin in Eclipse

How can I add the Versions-Maven-Plugin to my Eclipse projects ??
I tried the Add Plugins menu option but it doesn't seem to be able to find the plugin.
To check maven plugin version in eclipse:
Click Window –> Preferences –> Maven –> Installation . It will show you installation window with Maven version.
You have to add the versions maven plugin into the reporting part of your pom to create appropriate reports about dependency updates.
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>1.3.1</version>
<reportSets>
<reportSet>
<reports>
<report>dependency-updates-report</report>
<report>plugin-updates-report</report>
<report>property-updates-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
You can not install the versions-maven-plugin in Eclipse, cause the version-maven-plugin is a Maven plugin and not a Eclipse plugin. But not an bad idea.

WTP dependency does not seem to be working

From reading A Java web project created with Maven is not recognized as such by Eclipse
I add the below plugin to pom.xml to convert my maven project to a web project :
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugin>
I then run "Update Project Configuration" but the maven project is not converted to a web project.
If I run the command mvn eclipse:eclipse -Dwtpversion=2.0 the project is then updated. Should updating the .pom file not suffice to convert the maven project to a web project ?
It will not suffice. The plugin configuration needs to be executed, which will not happen by just loading/refreshing it in Eclipse. It gets executed when mvn eclipse:eclipse is run.
I assume we do not have m2e, which does not need this configuration anway.

what does the wtpversion mean in the Eclipse plugin?

using maven, what does the wtpversion mean in the Eclipse plugin?
wtp adds web application support to eclipse. If you want to develop Maven based web applications with Eclipse, you should rather use Eclipse m2eclipse plugin.
As for wtpversions, this link has a mapping of wtpversion and eclipse versions.
This is the abbreviation of Eclipse Web Tools Project and you can use in maven > pom.xml under the <build> tag:
<!-- Eclipse project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Always download and attach dependencies source code -->
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<!-- Avoid type mvn eclipse:eclipse -Dwtpversion=2.0 -->
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
From: How To Create A Web Application Project With Maven

m2eclipse sets JDK compliance to 1.4

Using eclipse 3.5, when I create a new maven project, m2eclipse automatically adds J2SE1.4 to libraries and Compiler Compliance Level to 1.4 (Project properties > Java Compiler).
My JRE system library is 1.6 and my default compiler compliance level is 1.6. I don't even have 1.4 installed.
Can I make m2eclipse use my default settings and prevent it from modifying project settings?
It should follow the maven-compiler-plugin configuration:
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
(even if, as mentioned in this thread, it won't work for aspect-j)
This thread reminds us about the difference between m2eclipse within eclipse, and a maven script:
One thing worth to mention that this only applies to "the development mode" when m2eclipse is configuring Eclipse tools such as JDT, AJDT and WTP according to the configuration from pom.xml. This is how you normally code and debug your application, run unit tests (with Run as... / JUnit test) or run on web app server (Run as... / Server app).
However if you use Run as... / Maven build..., or create corresponding launch config from the Run/Debug menu, then you can select JVM that is used to launch Maven and all your compiler configuration will be respected in the same way it is respected in the command line.
So:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
</plugins>
m2e does not (and cannot) use external java compiler, so it will just ignore these configuration parameters. m2 only considers source/target maven-compiler-plugin parameters.
The JDK compliance level is derived from the maven project, not the other way around. In other words, you need to configure the maven compiler plugin for 1.6 level compliance and then m2eclipse will derive the appropriate settings under Eclipse:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
The pom.xml is the master, not m2eclipse.
In summary I did an mvn eclipse:eclipse on the project and an F5 refresh of the project in Eclipse and this configured the Java compliance setting correctly.
My set-up as follows. Using Kepler. Java 1.7 configured as default in preferences in Eclipse (as mentioned already, seems to be ignored anyway in deference to whatever is found in the pom.xml). I imported a bunch of Maven projects into Eclipse. All showed up as Java compliance level 1.4 and even the build path of the projects lists the Java 1.4 runtime. I double checked 1.7 is correctly specified in the pom.xml by requesting the effective pom on the command line to confirm the setting is present and correct in the pom:
mvn help:effective-pom -Doutput=eff.xml
This showed the correct setting was present:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
</configuration>
</plugin>
Guessing the problem is with the import part of the m2e plugin, version showing in Eclipse is:
1.4.0.20130601-0317

GWT/Eclipse/Jetty issue: Jasper can't resolve tag libraries

I'm trying to get GWT Hosted mode working in Eclipse, à la this HOWTO. Servlets work fine, as does my GWT code, but all my JSPs fail because with errors such as the following:
[WARN] /view/lniExecutiveSummary.htm
org.apache.jasper.JasperException: /WEB-INF/jsp/lni/lniExecutiveSummary.jsp(1,1) The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
[ trimmed ]
This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse.
I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.
Update: I'm no longer using Eclipse; I've switched (back!) to Intellij IDEA. So I can't honestly evaluate the answers you kind folks have posted. Once some voting action happens, or someone else reports success with one of these methods, I'll accept the appropriate answer. Thanks.
I feel your pain. I've gone thru the same pain trying to get gwt, maven, and eclipse to work together.
I've been able to get it working with maven using the following pom.xml. This way you can use mvn gwt:run to run in hosted mode, but unfortunately, I could never get the mvn goal mvn gwt:eclipse for generating an eclipse launch run time config to work.
Here's the relevant snippets from my pom.xml. Note that I've found it easier to install gwt in separate location and point maven to use that instead of having mvn download gwt from repo. The "system" level scope in the mvn dependencies are what make this happen.
<properties>
<!-- convenience to define GWT version in one place -->
<gwt.version>1.7.1</gwt.version>
<google.webtoolkit.home>${env.GWT_HOME}</google.webtoolkit.home>
<!-- tell the compiler we can use 1.5 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- GWT dependencies (from central repo) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>system</scope>
<systemPath>${env.GWT_HOME}/gwt-servlet.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>system</scope>
<systemPath>${env.GWT_HOME}/gwt-user.jar</systemPath>
</dependency>
... other dependencies...
</dependencies>
<build>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>com.gwt.example/Application.html</runTarget>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
</configuration>
</plugin>
<!--
If you want to use the target/web.xml file mergewebxml produces,
tell the war plugin to use it.
Also, exclude what you want from the final artifact here.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>target/web.xml</webXml>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<module>com.gwt.example</module>
</configuration>
</plugin>
</plugins>
...rest of pom.xml...
Another technique I've had success with is to use the eclipse google gwt plugin. Just use the wizard to create a new gwt project, make sure that you can run it from eclipse, then modify with your own code.
This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse. I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.
You apparently have the JSTL JAR file(s) in Tomcat/lib instead of WEB-INF/lib. You can fix this in at least three ways:
Move/copy the JSTL JAR file(s) into WEB-INF/lib.
Move/copy the JSTL JAR file(s) into Tomcat/lib of your development machine.
Associate the right Tomcat server containing the JSTL JAR file(s) with web project in Eclipse. If not done yet, add the Tomcat server in Servers view. Then in project properties go to Java Build Path > Libraries > Add Library > Server Runtime > select the server in question.
Add the Jar files in eclipse project classpath. if you already had this file tomcat lib. This option will works for you. Second option is add jar in Web-Inf lib folder if you have eclipse web project.
Did you try to mark the "jsf-api.jar" as "exported" in your Java project ?
(as mentioned in this thread)
1.) Go into the java-project properties and mark the "jsf-api.jar" as exported.
(project>properties>java build path>order and exports)
2.) Go into the advanced global tomcat preferences and add your project to
the tomcat classpath (windows>preferences>tomcat>advanced>add projects to
tomcat classpath)
Then, try again to run your webapp under eclipse.
Here is an article describing the same procedure/setup, not for JSF but Hudson (same problem though)
You can clearly see the two steps I mentioned above:
(source: hudson-ci.org)
(source: hudson-ci.org)