Why did maven suddenly start compiling with an older version of Java? - java

I've been developing in Java using maven for a few days now. Today I edited my pom.xml based on these instructions. Suddenly running mvn compile is giving me errors as if I was compiling with an older version of java. Stuff like:
error: generics are not supported in -source 1.3
Now I've paired my pom.xml back to its original content, and I'm still getting this error. I've done a mvn clean and deleted everything under target, and am still having this problem.
Here's a snippet of maven running the compilation phase:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bahToBeh 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # bahToBeh ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/doug/lucid/bah-bio-demo/bahToBeh/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # bahToBeh ---
[INFO] Compiling 9 source files to /home/doug/lucid/bah-bio-demo/bahToBeh/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.880s
[INFO] Finished at: Thu Dec 20 13:52:06 EST 2012
[INFO] Final Memory: 7M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project bahToBeh: Compilation failure: Compilation failure:
[ERROR] /home/doug/lucid/bah-bio-demo/bahToBeh/src/main/java/com/lucid/bahdemo/parsers/pm/MeshReader.java:[23,4] error: generics are not supported in -source 1.3
And my paired-down pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lucid</groupId>
<artifactId>bahToBeh</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>bahToBeh</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.digitalpebble</groupId>
<artifactId>behemoth-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>marc4j</groupId>
<artifactId>marc4j</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
This had been working fine up until today. I'm not sure what setting I might have changed or how I could have munged up my project. I even double checked that the correct versions of java are installed:
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ javac -version
javac 1.7.0_10
Here is JAVA_HOME
doug#doug-VirtualBox:~/lucid/bah-bio-demo/bahToBeh$ echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
Maven IS using the pom.xml I think it is, if I run mvn -X compile I get:
DEBUG] (f) project = MavenProject: com.lucid:bahToBeh:1.0-SNAPSHOT # /home/doug/lucid/bah-bio-demo/bahToBeh/pom.xml
I've also deleted my maven repo rm -rf ~/.m2 and saw maven redownload everything same problem.
EDIT -- It suddenly works mysteriously
I have no idea what happened, but suddenly now its working. I thought that one thing I changed was I commented out a test. I went and uncommented out the test and then ran mvn compile and this time it compiled. Some state somewhere was out-of-sync and now things magically work?
I hate not knowing why my tools suddenly go wonky, so this is not an answer to the question, merely more information.
EDIT -- and it also just suddenly STOPPED working again
Looks like fully specifying the version to compile works though, so dingding thats the winner.

Set the source and target java versions explicitly. http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>

As a workaround you can try this (given that it is very specific to an environment, this could help).
You can enforce the version of compilation using the plugin.
Maven compilation plugin.
Good luck!

Related

Fatal error compiling: release version 10.0.1 not supported using IntelliJ IDEA and Maven

On macOS Catalina 10.15.4, I have jdk-10.0.1 installed.
When I go to the Terminal and type in:
echo $JAVA_HOME
stdout:
/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Java version:
java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
mvn -version
mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/pnwlover/maven/apache-maven-3.6.3
Java version: 10.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "mac"
Created a sample maven project and set JUnit 5 as a dependency:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>Calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>10.0.1</java.version>
<maven.compiler.source>10.0.1</maven.compiler.source>
<maven.compiler.target>10.0.1</maven.compiler.target>
<junit-jupiter.version>5.3.2</junit-jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- junit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>10.0.1</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Calculator class:
package com.sample;
public class Calculator {
public static int add(int a, int b) {
return a + b;
}
}
JUnit 5 test:
package com.sample;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CalculatorTest {
#Test
public void add() {
assertEquals(5, Calculator.add(2, 2));
}
}
When I run it via Terminal or IntelliJ IDEA Ultimate Edition 2019.3 (as a Maven run config mvn test), I get the following error:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.sample:Calculator >----------------------
[INFO] Building Calculator 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Calculator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # Calculator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/pnwlover/Calculator/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.655 s
[INFO] Finished at: 2020-04-04T16:57:35-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project Calculator: Fatal error compiling: release version 10.0.1 not supported -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Java source/target version specified as 10.0.1 is not supported. You should use the major version only like 10 instead:
<java.version>10</java.version>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
<configuration>
<release>10</release>
</configuration>
In IntelliJ IDEA open pom.xml file, press Ctrl+R (Alt/Option+R on macOS) for Replace action, type 10.0.1 in the search field, Tab, type 10 in the replace field, Alt+A for Replace All.

Bitnami Tomcat Stack Maven fails to compile

Used Bitnami Tomcat Stack to create a instance in EC2 . Everything works perfect in matter of few mins. But at final stage to deploy application maven is failing to compile the source code. Eventhoug JAVA_HOME is perfectly set it is failing to compile with below error log.
root#ip-172-31-18-89:/mnt/apps/stutzen-backend# echo $JAVA_HOME
/opt/bitnami/java
root#ip-172-31-18-89:/mnt/webapps/stutzen-backend# mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ware27 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # ware27 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # ware27 ---
[INFO] Compiling 34 source files to /mnt/webapps/stutzen-backend/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
/opt/bitnami/java/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.245s
[INFO] Finished at: Sun Jul 13 10:37:54 UTC 2014
[INFO] Final Memory: 6M/25M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ware27: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /opt/bitnami/java/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
How to deal with it ?
The issue is that the maven compiler plugin is configured by default to use the a Java 1.5 compiler (see the source and target options in the official documentation) while Bitnami Tomcat Stack is includes Java 1.7. You will need to configure your projects to use Java 1.7 instead. For this you can define a different value for the maven.compiler.source and maven.compiler.target properties or define the maven.compiler.compilerVersion instead which will work as well. In both cases you need to set maven.compiler.fork to true. The example below shows how to configure this per project:
pom.xml:
<project>
(...)
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.fork>true</maven.compiler.fork>
</properties>
(...)
</project>
However you will likely want to define these settings as global settings for all your projects. In that case you can edit the settings.xml in ($M2_HOME/conf/settings.xml) and define a profile which will be always actived:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" ...>
(...)
<profiles>
<profile>
<id>env-dev</id>
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.fork>true</maven.compiler.fork>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>env-dev</activeProfile>
</activeProfiles>
</settings>
kaysa's answer is correct. The solution, however, can be achieved a little easier by adding a maven-compiler-plugin to your pom as shown below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I'm not sure if this helps you or not. add a profile to your pom.xml :)
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Oracle Corporation</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
give your true tools.jar address and run maven with this profile
if it's not working forget that and change your java home to something like : /opt/bitnami/jdk1.7.0_51/jre:)

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin

I'm trying compile using mvn install but I'm getting this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project test: Compilation failure: Compilation failure:
pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.mycompany.test.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
How to fix it?
Your issue is most likely the <scope> of the dependency. When inside of the IDE, all scopes are added to the build path of the project. However, when running mvn only the appropriate scopes are added to the classpath for the javac command. For example, if you had a class in /src/main/java that imported a class from one of your dependencies scoped to <scope>test</scope>, the IDE would be able to build the project, but mvn would fail in the manner you are experiencing.
I encountered a similar error when trying to download and compile the aws kinesis consumer library (kcl)
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # amazon-kinesis-client ---
[INFO] Compiling 81 source files to /opt/speedshiftmedia/aws.kcl/1.1.0/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.822s
[INFO] Finished at: Tue Jul 22 12:31:39 PDT 2014
[INFO] Final Memory: 4M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project amazon-kinesis-client: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: invalid target release: 1.7
It turns out that while I had updated my version of Java from 1.6 to 1.7, I had not updated Javac from 1.6 to 1.7.
To do so I used the following command on ubuntu
sudo update-alternatives --config javac
And then choose the desired version at the prompt.
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
I hope this helps someone else.

error in install a plugin in Maven

I am new in Maven and I want to use qt-jambi in maven. I followed this tutorial and Maven gave me the following error:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building iycTest
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'net.sf.qtjambi:qtjambi-maven-plugin' does not exist or no val
id version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Nov 26 02:25:57 PST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mypacakage</groupId>
<artifactId>iycTest</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>iycTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi</artifactId>
<version>4.5.2_01</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi-maven-plugin</artifactId>
<executions>
<execution>
<id>qtjambi</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<sourcesDir>src/main/java</sourcesDir>
<noObsoleteTranslations>true</noObsoleteTranslations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</pluginRepository>
</pluginRepositories>
</project>
How do I solve it? i am using MS Windows xp and Maven 2.0.11
[update based on #Raymond hint to look into README.txt at old repository location]
The repository has moved so you must change the repository URL. Change all the repository urls from
http://qtjambi.sourceforge.net/maven2/
to
http://repository.qt-jambi.org/nexus/content/repositories/releases-before-2011/
Also check the new home page at http://qt-jambi.org for additional info. At this new repository 4.6.3_04 is available for the maven plugin. 4.5.2_01, 4.6.2 and 4.6.3 are available qtjambi itself.
If you browse to the README you'll find a link at the bottom to the repository. Update your pom.xml then rerun maven:
$ mvn --update-plugins clean install
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: /home/user/apache-maven-3.0.4
Java version: 1.7.0_09, vendor: Oracle Corporation
Java home: /home/user/jdk1.7.0_09/jre
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-18-generic", arch: "amd64", family: "unix"
Try adding the version to the plugin it may not be being resolved automatically:
<version>4.6.3_04</version>
The available versions you can use for the plugin is at the repository url:
http://old.qt-jambi.org/maven2/net/sf/qtjambi/qtjambi-maven-plugin/
At a guess you'd probably need the same plugin version as the version of qtjambi so in this case you'd need to find the appropriate repository.

Maven Pom Error - Can not find parent for Jersey

Have Eclipse Juno, maven 2.2.1, and m2eclipse running on a Red Hat Linux platform...
Downloaded a simple example to build a Restful Hello World web service (which works on my OS X computer) but for some odd reason, its not working on my Linux box.
Here's the pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>RESTfulExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>RESTfulExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>RESTfulExample</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I try to issue an mvn compile from the command line:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building RESTfulExample Maven Webapp
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:jersey-server:bundle:null
Reason: Cannot find parent: com.sun.jersey:jersey-project for project: null:jersey -server:bundle:null for project null:jersey-server:bundle:null
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Nov 15 17:07:16 PST 2012
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
Has anyone encountered this issue? I don't understand how it works on my OS X computer but not on Linux (which I don't think is the issue).
Thank you for taking the time to read this.
I would completely remove the entire repositories element in your pom.xml file. This way maven will use the standard central repository. Then change the version of jersey-server to 1.15 (the latest).
The latest jersey in that java.net repository is dated august 2011, while the standard central maven repository has version 1.15 dated October 30 2012.
I suspect that the reason it works on one machine and not the other is that in your ~/.m2/repository cache you have good cached files on one machine but not on the other. It may be necessary to delete the entire ~/.m2/repository/com/sun/jersey hierarchy and rebuild. You may have corrupted files there.

Categories