Maven compile dependency error javax.mail missing - scala

I am following the instructions in the lift guide book for set up the basic hello world application (On windows 7 using cygwin)
After doing this to start
mvn archetype:generate -U -DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-blank -DarchetypeVersion=2.0 \
-DarchetypeRepository=http://scala-tools.org/repo-releases \
-DgroupId=demo.helloworld -DartifactId=helloworld \
-Dversion=1.0-SNAPSHOT
Then
cd helloworld
mvn jetty:run
I get the following error
[ERROR] Failed to execute goal on project helloworld: Could not resolve dependencies for project demo.helloworld:helloworld:war:1.0-SNAPSHOT: Failed to collect dependencies for [net.liftweb:lift-mapper:jar:2.0 (compile), javax.servlet:servlet-api:jar:2.5 (provided), junit:junit:jar:4.7 (test), org.mortbay.jetty:jetty:jar:[6.1.6,7.0) (test), org.scala-lang:scala-compiler:jar:2.7.7 (test)]: No versions available for javax.mail:mail:jar:[1.4,1.4.3) within specified range -> [Help 1]
Before that there were two warning for checksum errors for the metadata.xml file. I put the checksum ignore in my pom file.
I downloaded the mailx API package from Oracle and put it in my classpath. After trying various solutions found for similar sounding errors nothing seems to work. Can someone suggest something?
PS: I searched for two days for the answers and tried all the solutions that came up in various threads but found no answer in them.

You need to explicitly add java.net repository to your pom.xml. (Which is very weird)
<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
<!-- other repos -->
</repositories>

Related

Sonar `should be relative to project baseDir` error in travis

Some time between the 11th September and the 14th September, running sonar through our travis build started failing with an org.eclipse.dawnsci.targetplatform should be relative to project baseDir error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project org.eclipse.scanning: Dir /home/travis/build/eclipse/org.eclipse.dawnsci/org.eclipse.dawnsci.targetplatform should be relative to project baseDir -> [Help 1]
Looking through the pom.xml the org.eclipse.dawnsci module does stand out as being different to all of the others:
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
<module>org.eclipse.scanning.api</module>
...
</modules>
I have tried updating sonar-project.properties from
sonar.exclusions=**/*.xml,**/*.class
to each of the following:
sonar.exclusions=**/*.xml,**/*.class,../org.eclipse.dawnsci
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci*
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci**
but none of these changes helped.
After previous problems I have added --fail-never to the mvn -q sonar:sonar command in .travis.yml so this problem won't prevent pull requests being merged, but it would be nice to have sonar reports on our repo again.
Any suggestions about how I can fix our travis build would be appreciated?
We changed the way we validate project layout, and it leads to this error. A ticket was created to track this change, and we are currently discussing options (like updating the SonarQube Scanner for Maven). Feel free to follow it for updates, and sorry for the inconvenience.
For your specific case, one workaround is to create a build profile, and exclude module ../org.eclipse.dawnsci when running the SonarCloud analysis. Or move the module to be under the project basedir (and avoid using .. in module location).
As a side note, there is no point maintaining the file sonar-project.properties if you are using the Scanner for Maven (mvn sonar:sonar) since the Scanner for Maven will only read configuration from pom.xml.
As suggested by Julien H. - SonarSource Team adding a profile did solve this problem.
In the pom.xml I changed
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
...
</modules>
to
<profiles>
<profile>
<id>externalModules</id>
<activation><activeByDefault>true</activeByDefault></activation>
<modules>
<module>../org.eclipse.dawnsci</module>
</modules>
</profile>
</profiles>
<modules>
<module>org.eclipse.scanning.target.platform</module>
...
</modules>
so that the module is included by default.
I then added -P !externalModules to my mvn sonar:sonar command in .travis.yml so that it was excluded when running sonar analysis.
I stumbled over the same problem and finally came to the conclusion that this has all been fixed in the latest sonar-maven-plugin 3.4. You can simply upgrade your dependency to this:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>

Getting "The POM for <name> is invalid, transitive dependencies (if any) will not be available" only in Eclipse

I have recently upgraded to JAXB 2.2.11 and noticed in my Eclipse console the following message:
10/15/14, 11:42:46 PM GMT+2: [INFO] Creating new launch configuration
10/15/14, 11:42:58 PM GMT+2: [INFO] C:\Projects\workspaces\mj2p\maven-jaxb2-plugin-project\tests\JAXB-1044
10/15/14, 11:42:58 PM GMT+2: [INFO] mvn -B -X -e clean install
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-impl:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-xjc:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-core:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
What puzzles me is that I am not getting this warning in console. The poms in question also seems to be correct. I am sure I am using the same Maven installation in the console and in Eclipse (m2e). The repository also seems to be correct.
Does anyone happen to know, what could be causing this?
Please note that this is not a duplicate for (almost
identically-named) question:
The POM for <name> is invalid, transitive dependencies (if any) will not be available
This question is about the differences between Maven execution in the console and from the Eclipse.
The pom for com.sun.xml.bind.jaxb-impl has com.sun.xml.bind:jaxb-parent has its parent.
jaxb-parent pom has the following section:
<profile>
<id>default-tools.jar</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>
</properties>
</profile>
<profile>
<id>default-tools.jar-mac</id>
<activation>
<file>
<exists>${java.home}/../Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
</properties>
</profile>
In your Eclipse, neither of the profile seems to be activated due to which ${tools.jar} does not have a value.
One possibility could be JAVA_HOME value is set incorrectly.
After further investigation it appears that I have the same problem as in this question:
Maven not picking JAVA_HOME correctly
The solution thanks to #rustyx (please upvote that answer):
To fix the issue you need to start Eclipse using the JRE from the JDK by adding something like this to eclipse.ini (before -vmargs!):
-vm
C:\<your_path_to_jdk170>\jre\bin\javaw.exe
the pom for com.sun.xml.bind:jaxb-osgi:jar:2.2.10 is invalid issue.
worked for me after updating the rest-assured version to 4.1.1.
As others pointed out, this might happen because the JRE is setup incorrectly within Eclipse.
I solved it by adding the correct entry (pointing to where mi JDK is installed) inside Window>Preferences>Java>Installed JRE's
After this change, a project clean might be necessary.

Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war - Could not copy resource

I have a multi-module project that I'm trying to import in my Ubuntu 12.04 LTS's Eclipse Juno. (I already have done it successfully on Windows 7).
My project has six modules, the first four modules are successfully imported from the SVN Repository and built with Maven 3.0.5, but when I try to build the fifth called core, i receive the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war (default-war) on project core: Could not copy resource [/opt/workspace/core/target\preassembly]: File /opt/workspace/core/target\preassembly/scripts/Mask.js does not exist -> [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
As the error says, It looks like that Maven can't find the directory /opt/workspace/core/target\preassembly to copy the file /opt/workspace/core/target\preassembly/scripts/Mask.js.
But, this directory actually exists and the file Mask.js is in there. What looks strange to me is that backslash \ after target directory instead a common bar /. But I have no idea if this is a problem and how to solve it, I spent 2 days researching the Internet but unfortunately I've found nothing.
Here's my maven-war-plugin configuration section of parent project's pom.xml, where the backslashes appear
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}\preassembly</directory>
</resource>
</webResources>
</configuration>
</plugin>
I've also checked the owner of the directories on Ubuntu, and everything refers to the same owner that worked on the first four modules.
As I said above, the same version of eclipse, svn and maven works great on Windows.
Anyone ever had this problem? Thank you very much.
I was working on angular 8 and updated the code to angular 9 and then during build i got the same issue .For me clean build solved the issue.You can try clean build , hope that will help .

What type of new project for the Hibernate tutorial?

I am trying to follow this Hibernate tutorial:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html
which seems pretty easy & straightforward, but I got stuck on the very 1st decision point: When selecting File > New Project to use the tutorial's suggested pom.xml, which of the many type of projects should I select?
Intuitively, I thought of creating a new Maven project:
Maven > Maven Project [Next]
[v] Create a simple project (skip archtype selection) [Next]
But at step #3 it prompts me for the very same information provided by the tutorial's pom.xml. So I am thinking the tutorial was aiming at creating a "blank project" and then manually adding the suggested pom.xml to it?
But what type of "blank project" would that be?
Java?
Java EE?
EJB?
JAXB?
JPA?
Maven?
Does it matter?
(sorry, don't have much experience (yet) with this new jargon, will get there eventually)
UPDATE 1: Actually, the proposed method of selecting a Maven project (regardless whether starting with bogus or correct info) doesn't work:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.hibernate.tutorials:hibernate-tutorial
POM Location: C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
Validation Messages:
[0] 'dependencies.dependency.version' is missing for org.hibernate:hibernate-core:jar
[1] 'dependencies.dependency.version' is missing for javax.servlet:servlet-api:jar
[2] 'dependencies.dependency.version' is missing for org.slf4j:slf4j-simple:jar
[3] 'dependencies.dependency.version' is missing for javassist:javassist:jar
Reason: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
I am going to check now whether creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) will do the trick.
UPDATE 2: Creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) produces the same errors.
What am I missing?
UPDATE 3: Thanks to #cowls tip below I found that "I" was missing were the version numbers for the Maven dependencies. "I" because it's the tutorial that was missing them (what kind of a tutorial is this?)
Once I used some known version numbers, e.g.:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<!-- Because this is a web app, we also have a dependency on the servlet api. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>1.2_02</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.10</version>
</dependency>
<!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.8.0.GA</version>
</dependency>
</dependencies>
I have been able to get rid of that scary FATAL ERROR message. That error message's "tip" BTW was counter-productive as it was pointing to the wrong direction:
[INFO] Error building POM (may not be this project's POM).
Now... I am still getting a build error, albeit much less scary:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\dben\ws-study\First Hibernate Tutorial\src\main\resources
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.pom
[INFO] Unable to find resource 'javax.servlet:servlet-api:pom:1.2_02' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.jar
[INFO] Unable to find resource 'javax.servlet:servlet-api:jar:1.2_02' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) javax.servlet:servlet-api:jar:1.2_02
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
2) javax.servlet:servlet-api:jar:1.2_02
----------
1 required artifact is missing.
for artifact:
org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
Interesting tutorial: I was expecting to learn some Hibernate but instead I am finding myself learning Maven. :)
UPDATE 4: I corrected the javax.servlet version to 2.4 and all is well now.
LESSONS LEARNED:
Maven's pom.xml requires a <version> for each & every dependency.
That <version>'s value must be valid.
Creating a new Maven project, then replacing its pom.xml entirely would work, but it still creates it with the incorrect subdirectory under Workspace because there is no way to define the <name> in the wizard-based creation process.
Creating a plain Java Project, then adding the pom.xml to its directory, then refreshing the Package Explorer view is the recommended way to go (no subdirectory renaming necessary).
That tutorial recommends Maven's "standard layout" but then breaks it by using the declared package "org.hibernate.tutorial.domain" which does not match the expected package "main.java.org.hibernate.tutorial.domain"... Do take Eclipse's fix suggestion to rename the package to "main.java.org.hibernate.tutorial.domain". (and move Event.java to the newly renamed package!)
The Hibernate configuration command (mvn exec:java -Dexec.mainClass="org.hsqldb.Server" etc.) must be run from the directory where pom.xml resides.
Easiest is to create a new maven project and use the maven-archetype-quickstart archetype.
This will create a basic maven project and you should be able to go from there.
Note that a maven project is just a Java project that uses Maven to build it, hence you will see a pom.xml file in your project.
Using this pom file you can build the project, include external dependencies and much more. I would suggest using the m2e plugin if you are developing with eclipse to help you manage the maven projects better: http://eclipse.org/m2e/
Each dependency you specify should have a version number associated with it.
e.g.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
To get the correct version number, just google artifactid maven dependency. E.g. hibernate-core maven dependency.
Look for the link for the maven central repository - i.e. http://mvnrepository.com. If you cant find it on Google you can search directly on the site, however I find its search feature quite poor.
Put your Java code in src/main/java and your resources in src/main/resources (e.g. xml files etc).
You can then build the project using mvn clean install

building spring batch sample application

I am trying to build the sample application for spring batch 2.1.6. (ie. spring-batch-2.1.6.RELEASE/samples/spring-batch-samples) using maven but am getting this error for a missing plugin:
[ERROR] Plugin
com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE
or one of its dependencies could not be resolved: Failure to find
com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE
in http://repo1.maven.org/maven2 was cached in the local repository,
resolution will not be reattempted until the update interval of
central has elapsed or updates are forced ->
Is there another repository I can set up to get this plugin? I am a bit suprised to be getting this errror as this is the latest realease version of spring batch.
Here is the repository section from the pom as it came in the download:
<repositories>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle External</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
The project's parent pom has a bootstrap profile which contains the necessary repository definitions. Build the project with the command mvn test -P bootstrap and it will download the dependencies.
P.S. This is explained in the readme's instructions that how to build Spring Batch. It would be good if they would also tell how to do it in the instructions for using the samples - maybe you could file a bug report?
i am using maven3 and was able to solve this problem by adding this to my pom:
<pluginRepositories>
<pluginRepository>
<id>plugin.repo.maven.central2</id>
<url>http://objectstyle.org/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
The Spring batch Admin sample build is broken for sure. At least as of today.
The -Pbootstrap doesn't help and adding the repos in that profile in my local settings doens't help either.
When I attempted to build spring-batch-admin-sample, I found that I was missing dependencies of spring batch!
So I went to build that. There I found that I was missing org.neo4j:neo4j-cypher-dsl-1.9.M04 and also gemfire.7.0.1.jar. Adding repos doesn't help because of the maven2/3 incompatibility issues.
So a sure way to fix this is to go to each repo, download the missing dep and mvn install-file them.
So get the neo4j one here:
http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-cypher-dsl/1.9.M04/
Get the gemfire one from here:
https://repo.springsource.org/gemstone-release-cache/com/gemstone/gemfire/gemfire/7.0.1/
And then I ran into a foundrylogic.vpp dependency that I found here:
http://objectstyle.org/maven2/foundrylogic/vpp/vpp/2.2.1/
Don't forget to get the corresponding poms also to keep it clean and get all the transitives, if any.
Use the mvn install-file plugin described here to get all three deps to your local repo.
http://maven.apache.org/plugins/maven-install-plugin/usage.html
Now spring-batch should build clean.
Now if you go to build spring-batch-admin it will still fail because it depends on spring-batch-core-2.2.3.BUILD-SNAPSHOT whereas what we just built was version 3.0.0.BUILD-SNAPSHOT.
So go to spring-batch-admin-parent's pom and modify the pom like so:
<!-- <spring.batch.version>2.2.3.BUILD-SNAPSHOT</spring.batch.version> -->
<spring.batch.version>3.0.0.BUILD-SNAPSHOT</spring.batch.version>
And then step back to spring-batch-admin and mvn clean install should build the sample.
Hope this helps someone!
I installed maven 3.2.1 and it works.