Use Maven embedded in Eclipse to install dependencies - eclipse

I am trying to add log4j as a Maven Dependency. So I added it to the pom.xml
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
Now I have a warning message that I am missing 6 artifacts (jars that log4j depends on). As described on the following site Maven Repository - log4j.
My goal is to get Maven to install the 6 dependencies for me. I have Eclipse Kepler with embedded Maven, so I cannot run "mvn install". I see from this stackoverflow answer Run Maven Install in Eclipse that I can right click on the project and Run As > Maven Install. But I get the following error:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ############# 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.522s
[INFO] Finished at: Wed Nov 27 12:13:11 CST 2013
[INFO] Final Memory: 6M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project #############: Could not resolve dependencies for project #############:#############:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory -> [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/DependencyResolutionException
Please let me know if I am on the right path and how best to proceed to get the log4j dependencies. Thank you in advance for any help.
UPDATE
After checking Preferences > Maven > User Settings, I discovered that the settings.xml file that is being referenced does not exist. I clicked "Update Settings" and I get the following error:
ArtifactTransferException: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
UPDATE 2
It looks like my issue is a result of Maven 3 (which comes with Kepler) is trying to access a Maven 2 repository and having compatibility issues. I have yet to figure out how to redirect to an appropriate repository.

I changed the version from 1.2.15 to 1.2.17 and it worked (1.2.16 works as well). I do not see any of the dependencies listed "here" listed in the Resolved Dependencies frame like I did with 1.2.15. I do not have a full understanding of why this worked, but it worked for me.

You can right-click on your project then Maven > Update Snapshots. (Make sure u check the "Force update on snapshots" checkbox. This should work.

Related

Creating Maven multi-module project with Eclipse

I want to create a maven Multi-module project.
I want to create the Parent project using
mvn archetype:create -DgroupId=com.websystique.multimodule -DartifactId=parent-project
But I got this error:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.203 s
[INFO] Finished at: 2017-05-02T19:57:19+02:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'create' in plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.1 among available goals crawl, create-from-project, generate, help, integration-test, jar, update-local-catalog -> [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/MojoNotFoundException
Did you read the error message?
[ERROR] Could not find goal 'create' in plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.1 among available goals crawl, create-from-project, generate, help, integration-test, jar, update-local-catalog -> [Help 1]
The error message tells you that the goal you've specified for the plugin (create) isn't one of the available options. It also lists the valid options for you:
crawl
create-from-project
generate
help
integration-test
jar
update-local-catalog
The goal you're looking for is generate. For example:
mvn archetype:generate -DgroupId=com.websystique.multimodule -DartifactId=parent-project
For more info: maven-archetype-plugin.

Maven Build - Couldn't resolve dependencies

OS: OSX Yosemite
Eclipse: Kepler
Problems:
1. [ from Eclipse Run ] : maven-compiler-plugin is missing
2. [ from Command Line ] : Failure to find com.microsoft.sqlserver:sqljdbc4:jar:2.0
I have a maven project which pom.xml ( partly ) defined as mentioned below, after seeing the problem i manually executed Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar in the project directory where the pom.xml is defined and the result came as BUILD SUCCESS. However when i run maven build i get error [2]. and when i try to run in eclipse i get error 1.
MVN:
mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
POM.XML:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>2.0</version>
<scope>runtime</scope>
</dependency>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.6</compilerVersion>
<target>1.6</target>
<source>1.6</source>
<fork>true</fork>
</configuration>
</plugin>
Error 1:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for XXXXXXXXXX:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 139, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Error 2:
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for XXXXXXX:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 139, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XXXXXX 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.microsoft.sqlserver:sqljdbc4:jar:2.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.381 s
[INFO] Finished at: 2017-02-15T20:04:48-06:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XXXXXX: Could not resolve dependencies for project XXXXXXXXX:war:0.0.1-SNAPSHOT: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:2.0 in https://repo.maven.apache.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 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project XXXXXX: Could not resolve dependencies for project XXXXXXXXX:war:0.0.1-SNAPSHOT: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:2.0 in https://repo.maven.apache.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
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
Reference:
I did refer this post and couldn't resolve the problem.
sqlserver jar file needs to be added in the maven directory as mentioned below,
Path : /Users/xxxxx/.m2/repository/com/microsoft/sqlserver/sqljdbc4/2.0
File: sqljdbc4-2.0.jar

Missing artifact com.oracle:ojdbc7:jar 12.0.1.2 error in pom.xml in eclipse

[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------- ----------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.061 s
[INFO] Finished at: 2017-01-19T14:37:43-05:00
[INFO] Final Memory: 7M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/myname). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException
I saved my ojdbc7 at /Users/myname/Downloads/ojdbc(1)
And that is what I am entering for my path so I don’t’ know where do I need to store this ojdbc. I don’t have Oracle on my machine.
I am just practicing. Please advise
Go to the location of your ojdbc driver and open the command line there. You need to execute the following command in this directory
mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -
Dversion=11.2.0 -Dpackaging=jar
This will add ojdbc driver to your local m2 repository.
Download the ojdbc driver and place it on the local drive. Run the following command either from the command prompt or from eclipse.
mvn install:install-file -Dfile=D:/jar//ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar
If still see BUILD FAILURE error, in eclipse just remove mvn from the command and run.

do not pass correct settings.xml to Maven Release Plugin

i have the following issue with eclipse , i am running an mvn install ,
try to build my project.
no idea what do with this error
please help
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building superman 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-hpi-plugin:1.95:validate (default-validate) # superman ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.0.1:enforce (enforce-maven) # superman ---
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Build with Maven 3.0.4 or later. Maven 3.0 through 3.0.3 inclusive do not pass correct settings.xml to Maven Release Plugin.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.032s
[INFO] Finished at: Thu Dec 04 11:24:21 CST 2014
[INFO] Final Memory: 22M/355M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce (enforce-maven) on project superman: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [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
That means simply that you are using an older Maven version. Based on the rule you have to use Maven 3.0.5+ that's the problem. The problem with Maven 3.0...3.0.3 had problems with informations from settings.xml to the release plugin which produces problems.
so after all that , you have to go to
window> preferences > maven > installations > and change the settings in there to the new install on your work station . that why eclipse is going to use the new maven 3.2.3
issue solved

maven dependency not found in repository

I'm trying to run the project, which uses gwt-dev.
The instructions are at: http://neiliscoding.blogspot.ru/2012/05/how-to-setup-examples-for-use-in-gxt-3.html?showComment=1362999279386
when I create dependency in terminal like: mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-dev -Dversion=2.5.0 -Dpackaging=jar -Dfile='/home/mikhail/Загрузки/libraries/gwt-2.5.0/gwt-dev.jar'
and add dependency to the pom.xml:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.5.0</version>
</dependency>
maven says:
[WARNING] You should not declare gwt-dev as a project dependency. This may introduce complex dependency conflicts
Downloading: http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.5.0/gwt-dev-2.5.0-linux-libs.zip
[INFO] Unable to find resource 'com.google.gwt:gwt-dev:zip:linux-libs:2.5.0' in repository central (http://repo1.maven.org/maven2)
else if I remove it maven says:
[INFO] using GWT jars from project dependencies : 2.5.0
Downloading: http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.5.0/gwt-dev-2.5.0-linux-libs.zip
[INFO] Unable to find resource 'com.google.gwt:gwt-dev:zip:linux-libs:2.5.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
So I have Build error in both cases. How to deal with such situation? help me please.
I didn't managed with this problem yet but I've just found that I used 1.2 version of maven plugin. I'm not shure it is the main problem, but I'd like to deal with it anyway. so, sinse I've added this plugin according to your first link, maven drops build error:
`
[INFO] Scanning for projects...
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Batch mode
[INFO] Archetype repository missing. Using the one from [org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1] found in catalog remote
[WARNING] Property module is missing. Add -Dmodule=someValue
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Archetype org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1 is not configured
Property module is missing.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Tue Mar 12 15:18:50 MSK 2013
[INFO] Final Memory: 27M/428M
`
and by the way, I use intellij IDEA
GWT stopped maintaining separate platform dependent libs for windows,linux and mac long time ago. GWT 1.7 was the last of such platform dependent libs. So "linux-libs" does not make sense in your error. I am guessing you are using a really old gwt-maven-plugin .
Move to latest gwt-maven-plugin.
Use <scope>provided</scope> for gwt-dev dependency to avoid it being pushed into WEB-INF/lib ( harmless but redundant )
Use global/central repository instead of installing it user repo locally.
You can also start off using GWT samples for maven projects here.
Note - your query might be a duplicate/similart to NetBeans + GWT 2.2.0 + Maven compile problem
Edit for new GWT release
GWT 2.5.1 has been released and also make note gwt-maven-plugin is of 2.5.0 ( 1 step behind GWT :)