Maven project Creation - While creating project from Eclipse failed - eclipse

I am able to create the maven project from command line but not able to create project from eclipse.I have configured same maven as external in eclipse. When i am trying to create maven project , its giving me below error. How to fix the below error.
My eclipse version is kepler
Could not calculate build plan: Plugin org.apache.maven.plugins:maven- resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-
plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Please advise.

Try this:
1: Delete .M2 Content
2: Set the Proxy configuration in settings.xml
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.com</host>
<port>xxxx</port>
<nonProxyHosts>local.net</nonProxyHosts>
</proxy>
</proxies>
Be careful! don't put any username and passowrd if proxy is without auth
3: Close Eclipse..and reopen
4: clean and update project configuration
5: verify the java buld path used for the project configuration
6: Try use the Maven embedded in eclipse just for a test, to see if the problem is the external Maven installation corrupted

Related

[New maven project in eclipse on MacOS]How to solve "Could not resolve archetype..."?

I am working on MacOS 10.14.6 with:
java version "12.0.2" 2019-07-16
Apache Maven 3.6.2
Eclipse IDE for Java Developers Version: 2019-06 (4.12.0)
When I tried to open a new maven project, the following error happened:
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
I have tried the following:
set proxy in settings.xml and place it in .m2 folder
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<username>****</username>
<password>****</password>
<host>proxy****</host>
<port>**</port>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
set proxy in network connections in eclipse
configure the settings.xml paths of global and user settings in eclipse as the settings.xml in the installed folder
delete .m2 folder and restart eclipse
add remote archetype catalog with the path
http://repo1.maven.org/maven2/archetype-catalog.xml
May I have your kind help to solve this?
The issue is solved by adding the mirror content in the settings.xml. https://maven.apache.org/guides/mini/guide-mirror-settings.html

Oracle driver ojdbc6 maven dependency error in spring boot application

I am trying to develop spring boot application which will in back-end connect to oracle db.
For oracle db connection I have added ojdbc6 driver dependency. I already have ojdbc6 jar in .m2 folder. But still I am getting compilation error in pom.xml for ojdbc6 dependency 'Missing artifact com.oracle:ojdbc6:jar:11.2.0.3'
As per solutions mentioned on various sites I tried to install ojdbc6 jar using following mvn command :
mvn install:install-file -Dfile={Path/to/your/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar
But it failed saying artifact already exist:
jar installation error
Error in pom.xml:
You can navigate to .m2 folder, find the path of repository/com/oracle/... and delete the content. then run the command again.
The following solution worked for me:
Download the jar, rename it according to your dependency and paste in the repository folder. For example below path and the dependency:
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.1</version>
</dependency>
C:\Users\Elias.m2\repository\com\ibm\db2\jcc\db2jcc4\10.1

Can maven treat WEB-INF\lib the way eclipse (and m2e) does?

I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist
Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).
I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?
Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.
Observations:
Alt+F5 removes this line:
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.
Related:
Maven: How to include jars in Eclipse, which are not available in repository?
Uses the maven eclipse plugin : update my classpath with an Eclipse User Library via the maven eclipse plugin - not compatible with m2e
How does the m2e eclipse plugin interact with eclipse? - apparently m2e checks the pom then calls the eclipse builders (hence the .classpath is read)
Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server
Deploying a Maven project with dependencies to Tomcat or Jboss running within Eclipse
Did you add this jar from WEB-INF\lib as a dependency like this:
<dependency>
<groupId>someGroupId</groupId>
<artifactId>someArtifactId</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>

Add maven dependencies of OSGi bundles to the Eclipse target platform

I have some OSGi-bundles (plain OSGi, no eclipse dependencies) and a maven build with pax runner that launches them in a Knopflerfish server.
The maven build and launching the bundles works perfectly fine but only via pax runner (mvn pax:provision).
For debugging the bundles it would be nice though to launch them directly from within eclipse, otherwise my breakpoints won't trigger (seems obvious, as pax:provision launches built jar-files that are not tied to eclipse anymore).
The MANIFEST.MF-file is built the usual maven-way, means using maven-bundle-plugin. Therefore launching the bundles directly from eclipse fails because the eclipse platform misses all that required external OSGi-bundles that maven gets doing it's maven magic.
Therefore I am looking for a way to set up my eclipse target platform somehow so that the OSGi-bundles from maven are automatically included and can be accessed from within the IDE for resolving the constraints at launch time.
I checked the target platform settings, but apparently one can only add specific jars and folders to it, not whole folder structures like it would require to use the whole local maven repository. If I need to update my target platform for every new dependency thats going to get really ugly (I'd wish I could do something like "add C:\Users\myprofile.m2\repository to target platform" and eclipse would just load what it needs).
While researching I found Eclipse Tycho but apparently this only compiles a target platform for building the bundles, but not for compiling and launching them from within the IDE. Next I found this site: http://andriusvelykis.github.io/pde-target-maven-plugin/ And this looks like exactly what I need. From the documentation it seems that this plugin is able to take the target platform that is compiled from eclipse tycho and write it to a file. Then I am able to import this file back into my IDE and use it as target platform.
The problem I have is, that the plugin quits with an error that I can't deduce (I turned on stacktraces for a more complete error message).
[ERROR] Failed to execute goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies (default-cli) on project orchestrator-parent: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies (default-cli) on project orchestrator-parent: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:581)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:534)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[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/PluginParameterException
This is the configuration for the plugin:
<plugin>
<groupId>lt.velykis.maven</groupId>
<artifactId>pde-target-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>pde-target</id>
<goals>
<goal>add-pom-dependencies</goal>
</goals>
<configuration>
<baseDefinition>D:/platform.target</baseDefinition>
<outputFile>D:/platform-pde.target</outputFile>
</configuration>
</execution>
</executions>
</plugin>
I can see that the paths are correct because the platform-pde.target file is created, but it has the same content as the base file.
File content (just a standard target platform that I created and shared as the base file):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="OrchestratorPlatform" sequenceNumber="8">
<locations>
<location path="${eclipse_home}" type="Profile"/>
</locations>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
<nl>en_US</nl>
</environment>
<launcherArgs>
<vmArgs>-Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx512m</vmArgs>
</launcherArgs>
</target>
What I am looking for are tips on how to configure the plugin correctly or any other ways I can bring my maven dependency bundles into my target platform so that I can launch the bundles directly from eclipse without having to maintain the dependencies somewhere in the depths of eclipse preferences again.
You can give a try to run PAX with defining vm options for your test container. By default the container is started in a separate JVM, and you can define command line options for it. In the documentation even you will find an example to start the tests in debug mode. Just define suspend=y, and you will have enough time to attach your Eclipse with a remote debugging session.
There is also an eclipse plugin for Pax Runner, you can try that.
EDIT:
With the launch config you sent me in the comment, you debugged the maven JVM, and not the OSGI container.
It is tricky to find documentation for pax:provision. I tried help:describe:
C:\>mvn help:describe -Dplugin=org.ops4j:maven-pax-plugin:1.5 -Dgoal=provision -Ddetail
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) # standalone-pom ---
[INFO] Mojo: 'pax:provision'
pax:provision
Description: Provision all local and imported bundles onto the selected
OSGi framework
mvn pax:provision [-Dframework=felix|equinox|kf|concierge] [-Dprofiles=log,war,spring,...]
If you don't have Pax-Runner in your local Maven repository this command
will automatically attempt to download the latest release. It will then
continue to use this locally installed version of Pax-Runner unless you add
-U to force it to check online for a later release, or -Drunner=version to
temporarily use a different version.
Implementation: org.ops4j.pax.construct.lifecycle.ProvisionMojo
Language: java
Available parameters:
args
User property: args
URL of file containing additional Pax-Runner arguments.
deploy (Default: true)
User property: deploy
When true, start the OSGi framework and deploy the provisioned bundles.
deployPoms
User property: deployPoms
Comma separated list of additional POMs with bundles as dependencies.
deployURLs
User property: deployURLs
Comma separated list of additional bundle URLs to deploy.
framework
User property: framework
Name of the OSGi framework to deploy onto.
noDependencies
User property: noDeps
Ignore bundle dependencies when deploying project.
profiles
User property: profiles
Comma separated list of additional Pax-Runner profiles to deploy.
provision
User property: provision
A set of provision commands for Pax-Runner.
runner (Default: RELEASE)
User property: runner
The version of Pax-Runner to use for provisioning.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.570s
[INFO] Finished at: Wed Feb 19 00:01:05 CET 2014
[INFO] Final Memory: 8M/109M
[INFO] ------------------------------------------------------------------------
So as it seems:
Create a file containing the following text:
--vmOptions=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8888
Run your build like this:
mvn pax:provision -Dargs=file:///c:/yourfilepath/thefilecontainingstuffabove.txt
I did not try it, but it can work. Suspends, port 8888, Eclipse Remote Debug :)
I am using remote debugging with Apache Karaf a lot. There karaf also loads the bundles from the maven repository.
Still eclipse finds the breakpoints and triggers them. So the same should work for pax runner.
What I do is to export KARAF_DEBUG=true and start karaf. This triggers the typical remote debugging settings which should also be available for pax runner. I then start a remote debug session from eclipse and simply add all necessary open eclipse projects to the sources of the remote debug session. This works almost all of the time. Sometimes my breaktpoints are also not triggered but it is very seldom and I did not find out why.
Btw. Karaf also allows to update bundles from the local maven repo while running. So if you change a project you can simply call mvn clean install on the single bundle project, do "update bundleid" on the shell and can continue to debug with the new version of the bundle. This is extremely helpful when you got a large project but only work at a small part while debugging.
So to resume you should be able to use pax runner with remote debugging without problems and it might also be interesting to take a look at apache karaf.

Eclipse 3.7 (Indigo): How to add a remote Maven 2 repository mirror

I recently installed Eclipse 3.7 (Indigo) and now a wanted to start a new project using the integrated Maven plugins.
Problem is, I can't download any dependencies from the central maven 2 repository http://repo1.maven.org/maven2
After creating a new simple Maven project (without an archetype), i constantly get these Error messages:
Description Resource Path Location Type
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: The repository system is offline but the artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 is not available in the local repository. pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 pom.xml /JAVA line 1 Maven Build Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Using an archetype doesn't work at all.
Am I right to just add another repository mirror to get the needed dependencies?
If so, how do I add another one?
Update: I wrote a D:\Users\.m2\settings.xml manually and the m2e-plugin recognized it correctly:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>dotsrc.org</id>
<url>http://mirrors.dotsrc.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Problem is: I can't find a complete mirror of the Maven central repository. I tried every single one I could find on the net, but all are missing some dependencies, archetypes, etc.
Any help out there?
Try one of these.