Not able to add springframe work in maven project - spring

I am trying to add spring-core & spring-context in a maven project but upon build, I am getting following error, I am trying to access three repositories which are given in first 3 lines of the follwing compilation error :
[INFO] Downloading from : http://repo1.maven.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] Downloading from : https://repo.spring.io/milestone/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.622 s
[INFO] Finished at: 2018-10-05T18:18:19+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project HelloWorldMaven: Could not resolve dependencies for project Demo:HelloWorldMaven:jar:0.1: Failed to collect dependencies at org.springframework:spring-context:jar:4.0.0.RELEASE: Failed to read artifact descriptor for org.springframework:spring-context:jar:4.0.0.RELEASE: Could not transfer artifact org.springframework:spring-context:pom:4.0.0.RELEASE from/to central (http://repo1.maven.org/maven2): connect timed out -> [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:
Following is my POM.xml in which I have added the dependencies :
<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>Demo</groupId>
<artifactId>HelloWorldMaven</artifactId>
<version>0.1</version>
<name>Hello world demo</name>
<description>Hello world demo</description>
<properties>
<org.springframework-core-version>4.0.0.RELEASE</org.springframework-core-version>
<org.springframework-context-version>4.0.0.RELEASE</org.springframework-context-version>
<log4j-version>1.2.17</log4j-version>
<junit-version>4.12</junit-version>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-core-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-context-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Please help , I am not able to figure out what I am missing, I think I am not able to access the remote repositories.
Please help. Thanks In advance.

You're probably behind a proxy, or your current network requires a proxy, or your connection is shaky
to central (http://repo1.maven.org/maven2): connect timed out ->

I added following in my setting.xml
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>my.host.address</host>
<port>myPort</port>
</proxy>
</proxies>
and ran the project with
clean install -DproxySet=true -DproxyHost=my.host.address -DproxyPort=myPort
And it worked !

Related

ERROR Source option 1.5 is no longer supported. Use 1.6 or later

It all happens when I was trying to build a springboot application by ./mvnw clean install
When I first run the install command, it runs into following problem.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Fri Jun 21 02:14:32 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException**
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar
[ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException
[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/PluginContainerException
I searched the problem on Stackoverflow and was able to solve this problem by the post
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)
Then, I got into another problem
[ERROR] Source option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
I'm on OS X. mvn -v shows:
Maven home: /Users/matthuntington/Desktop/apache-maven-3.5.0
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
Here is my pom file
<?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.packtpub.restapp</groupId>
<artifactId>ticket-management</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ticket-management</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>1.5.7.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
You can specify maven source/target version by adding these properties to your pom.xml file
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
I think this means that
You are using JDK9 or later
Your project uses maven-compiler-plugin with an old version which defaults to Java 5.
You have three options to solve this
Downgrade to JDK7 or JDK8 (meh)
Use maven-compiler-plugin version or later, because
NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6
See https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#target
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
Indicate to the maven-compiler-plugin to use source level 6 and target 6 (or later).
Best practice recommended by https://maven.apache.org/plugins/maven-compiler-plugin/
Also note that at present the default source setting is 1.6 and the default target setting is 1.6, independently of the JDK you run Maven with.
You are highly encouraged to change these defaults by setting source and target as described in Setting the -source and -target of the Java Compiler.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
or use
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
This error might be also for plugin versions. You can fix it in the .POM file like the followings:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Make sure you have following configuration in your pom.xml file.
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
For me the solution was to set the version of the maven compiler plugin to 3.8.0 and specify the release (9 for in your case, 11 in mine)
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
This worked for me!!!!
<?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>academy.learnprogramming</groupId>
<artifactId>hello-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<target>10</target>
<source>10</source>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
In IntelliJ:
Open Project Structure (⌘;) > Modules > YOUR MODULE -> Language
level: set 9, in your case.
Repeat for each module.
There can be corrupted jar file for which it may show error as "ZipFile invalid LOC header (bad signature)"
You need to delete all jar files for which it shows the error and add this Dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
I got this error: "Source option 5 is no longer supported. Use 6 or later"
after I changed the pom.xml
<java.version>7</java.version>
to
<java.version>11</java.version>
Later to realise the property was used with a dash insteal of a dot:
<source>${java-version}</source>
<target>${java-version}</target>
(swearings), I replaced the dot with a dash and the error went away:
<java-version>11</javaversion>
You need to set JDK 1.5 to your project and also all dependent project or jar file should also compiled with JDK 1.5

Maven versions-maven-plugin versions plugin 2.2 -- Maven Uncle Situation

Maven is 3.1.0.
I'm using versions-maven-plugin:2.2 in my project's pom.xml (as shown below). Apart from the usual pom.xml file configuration, I'm just showing the main code snapshot below:
<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>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<!-- Make sure that only non-snapshot versions are used for the dependencies. Only active when property 'snapshotDependencyAllowed' is false. -->
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${snapshotDependencyAllowed}</skip>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
<requireReleaseVersion>
<message>No Snapshots Allowed!</message>
</requireReleaseVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now, when I run: mvn clean install, it builds successfully.
NOTE: In my project, I have a parent section, where I'm dependent upon deploy-parent artifact whose group id "com.company.product" is the same group id what I want to tools-parent artifact (whose pom.xml I have pasted above) but deploy-parent is an artifact of another repository/project.
When I run: mvn versions:set -DnewVersion=0.0.7, I get the following error message.
[INFO] ------------------------------------------------------------------------
[INFO] Building tools-parent 0.0.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:set (default-cli) # tools-parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /user/home/u100123/giga/tools
[INFO] Processing change of com.company.product:tools-parent:0.0.7-SNAPSHOT -> 0.0.7
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] tools-parent .................................... FAILURE [1.093s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.404s
[INFO] Finished at: Fri May 01 20:44:22 GMT-00:00 2015
[INFO] Final Memory: 12M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project tools-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed. NullPointerException -> [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/PluginExecutionException
NOW, when I change the versions-maven-plugin version back to 2.1 (which what I was using earlier), the above mvn versions:set -DnewVersion=0.0.7 command is working successfully and pom.xml file is successfully getting changed to <version>0.0.7</version> for tools-parent artifact.
With version 2.2, it's giving me the error and not changing the version to 0.0.7.
Any reasons why 2.2 is failing? What can be done to resolve it?
It seems like some bug.
Solution:
1. I have to add <groupId>com.company.product</groupId> property outside of ... section as well i.e. for tools-parent, NOW version-maven-plugin:2.2 is working fine i.e. I added the top line (as shown below). The only thing is, what's the use of parent section then (apart from inheriting the main code of what deploy-parent is brining to tools-parent project). Why groupId needs to be defined output of parent section for artifactId tools-parent when it's already there in the parent section for versions-maven-plugin:2.2 to work successfully.
The most important thing is: This issue occurs only in case your pom.xml for a project/module has a <parent> section where the parent section's artifactId is not the parent of the project itself (a typical - Maven Uncle situation) i.e. if tools-parent artifact is defined in the parent section of another module (lets say tools-child) then version 2.2 will work successfully. But if tools-child's parent section is not containing the artifactId as "tools-parent" and is something else for ex: deploy-parent/some-different-project-artifact (which resides in a different project in your source control tool) then, for tools-child artifactId, we need groupId value also set outside of the parent section as well (even if the groupId of parent section's artifactId is same/different to tools-child's groupId).
<groupId>com.company.product</groupId>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
--OR
2. Switch back to versions-maven-plugin:2.1
Just to add to part 2 of Arun's answer, the way to use version 2.1 of the plugin is:
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set org.codehaus.mojo:versions-maven-plugin:2.1:commit -DnewVersion=0.0.7
You have to specify the full group-id and artifact-id.
Found this bug reported on the issue:
https://github.com/mojohaus/versions-maven-plugin/issues/51
I ran into a NPE too but it turns out the reason was a different one than suggested earlier. I debugged the versions-maven-plugin and found out that the NPE was caused by a missing <version> declaration of a dependency in the listed in the <dependencyManagement>. This can be reproduced with the following listing:
<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.example</groupId>
<artifactId>npe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>NPE Example</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<!-- missing <version>4.2.0.RELEASE</version> -->
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
</dependencies>
</project>

Maven error from Jenkins

I am running Jenkins 1.599. I have created a new freeStyle project, which executes the batch command mvn clean install.
If I do run the same batch command from the windows shell, the maven command runs successfully.
However, when Jenkins executes it, I get a maven failure, as shown below:
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>[workspace] $ cmd /c call C:\Windows\TEMP\hudson3523791316528515292.bat
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>C:\\develop\\AppHistData\\AppHistDataMvn\\maven_run.bat
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>cd C:\develop\AppHistData\AppHistDataMvn
C:\develop\AppHistData\AppHistDataMvn>C:\maven-3.2.5\bin\mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AppHistDataMvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for TradingInstrument:TradingInstrument:jar:1 is missing, no dependency information available
[WARNING] The POM for allinonetrade:allinonetrade:jar:1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.823 s
[INFO] Finished at: 2015-03-04T12:21:16+01:00
[INFO] Final Memory: 15M/491M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project AppHistDataMvn: Could not resolve dependencies for project com.deepfieldcapital:AppHistDataMvn:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: TradingInstrument:TradingInstrument:jar:1, allinonetrade:allinonetrade:jar:1: Failure to find TradingInstrument:TradingInstrument:jar:1 in http://bits.netbeans.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of maven2-repository.netbeans.maven2 has elapsed or updates are forced -> [Help 1]
[ERROR]
The POM.xml is as below:
<?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>deepFieldCapital</groupId>
<artifactId>TradeInstManager</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TradeInstManager</name>
<organization>
<name>Deep Field Capital</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.deepfieldcapital.tradeinstmanager.TradeInstrumentManagerMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>lib</id>
<url>file:../lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swing-layout</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>TradingInstrument</groupId>
<artifactId>TradingInstrument</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>BrokerOld</groupId>
<artifactId>BrokerOld</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>Utilities</groupId>
<artifactId>Utilities</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>allinonetrade</groupId>
<artifactId>allinonetrade</artifactId>
<version>1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<type>jar</type>
</dependency>
</dependencies>
</project>

maven compilation fails because unavailable dependency

I'm trying to run java program with maven but when i compiled using the command mvn -U compile
he shows me the following error
[root#onePK-EFT1 tutorials]# mvn -U compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building onePK Java Tutorials 0.6.0.5
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-core-rel
/0.6.0.5/libonep-core-rel-0.6.0.5.pom
[WARNING] The POM for com.cisco.onep:libonep-core-rel:jar:0.6.0.5 is missing, no
dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-
core-rel/0.6.0.5/libonep-core-rel-0.6.0.5.jar
[INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.517s
[INFO] Finished at: Tue Jul 09 07:28:28 PDT 2013
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project java-tutorials: Could not resolve
dependencies for project com.cisco.onep:java-tutorials:jar:0.6.0.5: Could not find
artifact com.cisco.onep:libonep-core-rel:jar:0.6.0.5 in central
(http://repo.maven.apache.org/maven2) -> [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
and this is my 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.cisco.onep</groupId>
<artifactId>hello-network-app</artifactId>
<version>0.1-SNAPSHOT</version>
<name>The onePK Hello Network Example Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>always</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.cisco.onep</groupId>
<artifactId>libonep-core-rel</artifactId>
<version>0.6.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<developers>
<developer>
<name>onePK Team</name>
<email>onepk-feedback#cisco.com</email>
<organization>Cisco.com</organization>
</developer>
</developers>
I think it's because he can't find libonep-core-rel.jar which i have it included
please any help
The simple solution is to use the appropriate maven repository for the artifacts com.cisco.onep* which are not located in Maven central.
As an immediate solution, but not a recommendation, you can use system dependencies to resolve artifacts on your local filesystem.
As #khmarbaise implied, try to publish those corporate artifacts to your corporate Maven repository (Nexus, Artifactory, Archiva, etc.), even an FTP/HTTP server would do...
Once you publish those corporate artifacts to your "corporate" repository(hopefully it's already in place), you just need a new repository declaration in your Maven POM.

Maven: Making Jars With Dependencies: Example From Book Doesn't Work

I am a complete beginner with Maven. I've been following the book Maven By Example. In the section 6.13 the author demonstrates making a JAR with the dependencies included via the command
mvn install assembly assembly
I followed the example in chapter 6, except I skipped the parts with unit testing. I went back through them to make sure I didn't skip a step. However when I tried the above command I got this error output:
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) # simple-weather ---
[INFO]
[INFO] <<< maven-assembly-plugin:2.2-beta-5:assembly (default-cli) # simple-weather <<<
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:assembly (default-cli) # simple-weather ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.094s
[INFO] Finished at: Wed Mar 21 15:53:03 EDT 2012
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:assembly (default-cli) on project simple-weather: Error readi
ng assemblies: No assembly descriptors found. -> [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
C:\home\Projects\simple-weather>
The problem is with the jar-with-dependencies descriptor in the plugins section. I googled around a bit, but didn't find a different way to do it from the book. So, I would be interested to know where I am going wrong.
Here is 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>org.sonatype.mavenbook.custom</groupId>
<artifactId>simple-weather</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>simple-weather</name>
<url>http://www.sonatype.com</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<organization>
<name>Sonatype</name>
<url>http://www.sonatype.com</url>
</organization>
<developers>
<developer>
<id>jason</id>
<name>Jason Van Zyl</name>
<email>jason#maven.org</email>
<url>http://www.sonatype.com</url>
<organization>Sonatype</organization>
<organizationUrl>http://www.sonatype.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thanks much in advance for any clues.
The problem is you have your descriptor refs configured for the compile plugin instead of the assembly plugin.
Add this to your /build/plugins section
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
and remove the below from your compiler plugin config as it is not doing anything.
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

Resources