• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Maven not searching local repository for a JAR

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To mvn compile an Oracle JDBC program I put the JAR in my local repository :



Check and find :


Should I expect to find ojdbc6.jar in this directory ?

ojdbc6-11.2.0.POM
----------------------


My POM :


Compile mvn compile :

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Part of your post doesn't make sense - the location of the JAR file in the local repository. What is with the "maven.REPOSITORIES" text, and why is the file name on the next line, and what is with all of the spaces?

Given that C:\Documents and Settings\dell\.m2\repository is the location of your local repository, the JAR file, and its POM, should be at:
C:\Documents and Settings\dell\.m2\repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.jar
C:\Documents and Settings\dell\.m2\repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.pom

Check that both of these files exist.

Looking at you mvn install:install-file command, what is "{ORACLE_HOME}"? Look at line 8 in the install-file output, is that a valid path to the JAR file?
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed sqljdbc4-4.0.jar and ojdbc-11.2.0.jar manually by commands: mvn install:install-file -Dfile={/path/to/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

and it was Success for both.

and also checked they are present in my local repo with version name on path.

While my project is successfully build in cmd, but it is giving this error in Jenkins:

[ERROR] Failed to execute goal on project ****-service: Could not resolve dependencies for project *******:****-data-service:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.oracle:ojdbc6:jar:11.2.0, com.microsoft.sqlserver:sqljdbc4:jar:4.0: Failure to find com.oracle:ojdbc6:jar:11.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]

Please help
 
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maven will automatically install the dependency if you specify the repository where the dependency can be found. Maven Central says that this dependency is located at http://www.datanucleus.org/downloads/maven2/.

Add this repository to your project POM and it will be fine. You may have to bump the version number to 11.2.0.3 though.
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appreciate your answer but I have already installed these jars in my local, see attachment.

Also, mvn clean install on cmd is Success for my project, while giving error in jenkins.

What the jenkins is doing differently ? Is it not looking in my local repo .m2?

is it looking in https://repo.maven.apache.org/maven2 ??

Error in Jenkins: The following artifacts could not be resolved: com.oracle:ojdbc6:jar:11.2.0, com.microsoft.sqlserver:sqljdbc4:jar:4.0: Failure to find com.oracle:ojdbc6:jar:11.2.0 in https://repo.maven.apache.org/maven2 was cached in the local repository
Mvn.PNG
[Thumbnail for Mvn.PNG]
 
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himani Bhatia wrote:What the jenkins is doing differently ? Is it not looking in my local repo .m2?



No, it's looking in the Jenkins user's Maven repository, unless you set up Jenkins to look somewhere else.

Actually, if you're running Jenkins, you should consider a site repository such as Nexus and install your driver there. Jenkins and Nexus are really intended for team work.
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way that I can make jenkins look only in my local repository, since the jars com.oracle:ojdbc6:jar:11.2.0, com.microsoft.sqlserver:sqljdbc4:jar:4.0 are not available in https://repo.maven.apache.org/maven2.
I have installed them manually.

[ERROR] Failed to execute goal on project selfservices-data-service: Could not resolve dependencies for project uk.gov.crawley.selfservices:selfservices-data-service:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.oracle:ojdbc6:jar:11.2.0, com.microsoft.sqlserver:sqljdbc4:jar:4.0: Failure to find com.oracle:ojdbc6:jar:11.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]
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why it's not an option to point it to a public repository where the dependency is available...
 
Tim Holloway
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himani Bhatia wrote:Is there any way that I can make jenkins look only in my local repository, since the jars com.oracle:ojdbc6:jar:11.2.0, com.microsoft.sqlserver:sqljdbc4:jar:4.0 are not available in https://repo.maven.apache.org/maven2.



No, because as I said, Jenkins is designed to manage builds for teams. Jenkins typically runs on a shared server, not the user's local machine, and therefore it's very likely that there would be no way for Jenkins to look on someone else's local machine if they wanted Jenkins to do a build. Probably no network path to their local repo, likely a security issue even trying to do so, certainly a problem if they powered off and went home. And the same would be true for someone else needing resources on your machine. Jenkins needs its resources someplace where Jenkins can see them, because Jenkins is running Maven, not you.

Let me qualify that "no". Yes, you can log in on the Jenkins machine as the Jenkins user and install the Oracle driver jar as the Jenkins user, which will put the repo where Jenkins can find it (since Jenkins will own it). But that's a rather crude and limited solution.

Since the master Maven repository doesn't have the Oracle JDBC driver in it (due to copyright limitations), the next best bet is to create your own in-house shared Maven repository. That's what Nexus does. It allows you to set up a server which can be on the Jenkins machine or anywhere else on the LAN that both you and Jenkins can see. This server functions almost exactly like the maven.apache.org repository server does. However, you can install your Oracle driver there. You can also install shared project JARs there (Jenkins can handle that). And Nexus also acts as a proxy for the apache maven repository - and possibly other public maven repos if you need them. Which means that you don't have to set up dual repos in the maven configuration for every user, and you reduce external Internet traffic, since once Nexus has pulled and cached an apache.org repo artefact, other users only have to pull from Nexus, not all the way back to apache.org.
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Tim. Will try setting up Nexus with Jenkins.

Does Maven follow these steps:
1) Read Pom.xml for project
2) Try to download the jars from remote repo https://repo.maven.apache.org/maven2
3) Download and store in local repo .m2


My question a) when does maven refer local repo for jars?
b) if maven can't find jars in remote repo, and jars are available in local repo, why it's not picking up?

Thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maven first checks the local repository, and if it can't find a dependency there, it checks each configured repository one by one until it finds it. Maven Central is configured by default, but you can also configure other repositories.

As Tim mentioned, Jenkins does not use your personal local repository. Jenkins has its own repository that it uses to cache dependencies.

Again, why is it a problem to just configure the http://www.datanucleus.org/downloads/maven2/ repository in your project?
 
Tim Holloway
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to understand what "local" means. When you run maven manually, "local" means your own personal Maven environment, which is typically in your ${user.home}/.m2 directory. But modern computer OS's allow for multiple concurrent users. On a Unix or Linux machine, 5 different people could log in to the same machine, each with his/her/its own home directory and therefore his/her/its own local maven environment (including their own repository caches). Jenkins is also normally run as a distinct user, so Jenkins also has a maven environment directory. Everyone has their own .m2 - they are not shared.

Jenkins is not like Maven. It's not a program that you run to build things. Jenkins is a multi-user server that build things for you. Or for that matter, any authorized requester, regardless of what computer they made that request from or what, if any Maven environment they have. Which is why Jenkins has a user account of its own, separate from your account or anyone else's. So not only does Jenkins not look at your Maven repository - which, as I mentioned, is physically impossible for it to do anyway, it doesn't even look ar your project directory. Unless you've gone through some contortions, Jenkins will access its own private copy of your project - including its own private copy of the pom.xml file - and build against that project copy in its own working directories. Using its own Java compiler and Maven program, which may or may not be the same files that you're using.

In short, having Jenkins build a project is no different than handing the project to someone else and having it run on their own computer. Anything that the other person cannot access (such as your own private .m2 directory) won't be usable to help do the build.

 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good to have great piece of info about Jenkins @Tim.
@Stephan, I have got settings.xml in C:\software\maven\apache-maven-3.5.0\conf which I think point it to https://repo.maven.apache.org/maven2 (where it can't find ojdbc6 jar and sqljdbc4 jars).

How can I configure it to look into http://www.datanucleus.org/downloads/maven2/ ?
Also, it seems to contain only ojdbc jars but not sqljdbc jars, while I require booth, any solution for this?
Mvn_settings.xml.PNG
[Thumbnail for Mvn_settings.xml.PNG]
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or any config settings I can change in Jenkins to point it to http://www.datanucleus.org/downloads/maven2/ ?
 
Tim Holloway
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himani Bhatia wrote:Or any config settings I can change in Jenkins to point it to http://www.datanucleus.org/downloads/maven2/ ?



Jenkins simply runs Maven, so what has to be actually done is change the repo settings in the .m2 directory for the Jenkins account.

However, yes, I think there's stuff in the Jenkins web interface configuration pages that will do that for you.
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just add the repository to the POM of your project:
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After adding Nexus Repository to my Pom, my Project was Build successfully but overall Build Failed due to this error:

[INFO] ******* Maven Webapp .................. FAILURE [  0.033 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.433 s
[INFO] Finished at: 2018-07-04T16:04:47+01:00
[INFO] Final Memory: 33M/283M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-war-plugin:2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:2.2: Could not transfer artifact org.apache.maven.plugins:maven-war-plugin:pom:2.2 from/to central (https://repo.maven.apache.org/maven2): Failed to transfer file: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.2/maven-war-plugin-2.2.pom. Return code is: 400 , ReasonPhrase:Bad Request. -> [Help 1]

with few warnings like:
Jenkins_error.PNG
[Thumbnail for Jenkins_error.PNG]
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's helpful if you show us your POM.
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is Pom for data service Project

<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>
<parent>
<groupId>**domain**selfServices</groupId>
<artifactId>selfservices</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>selfservices-data-service</artifactId>
<repositories>
   <repository>
     <id>datanucleus</id>
     <url>http://www.datanucleus.org/downloads/maven2/</url>;
   </repository>
 </repositories>
<dependencies>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework.ws</groupId>
       <artifactId>spring-ws-core</artifactId>
       <version>2.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Hibernate resources -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>

<!-- http://mvnrepository.com/artifact/org.hibernate/hibernate -->
<!-- To solve ASM and CGLIB issue Exclusion of asm and cglib as there is problem using hibenate dependancy
out of the box with jersey restapi framework -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
</exclusion>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
<!-- End of hibernate dependency -->

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<!-- ORACLE JDBC driver, need install yourself -->
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
<!-- MS SQL server JDBC driver, need install yourself -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
</project>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This is POM for Parent Project on which references 3 Projects mentioned in <Module>

<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>***selfservices</groupId>
<artifactId>selfservices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>selfservices-external-service-consumer</module>
<module>selfservices-data-service</module>
<module>selfservices-restapi</module>
</modules>
<properties>
<java-version>1.8</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework-version>4.0.0.RELEASE</org.springframework-version>
</properties>
<dependencies>
<!-- Log4j -->
<dependency>
           <groupId>log4j</groupId>
           <artifactId>apache-log4j-extras</artifactId>
           <version>1.2.17</version>
       </dependency>
       
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>

<!-- http://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
project_snapshot.PNG
[Thumbnail for project_snapshot.PNG]
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works fine for me. You just need to add another repository for sqljdbc4:
 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. why does your parent POM declare dependencies? If you want to configure dependencies for all sub-modules, do that under <dependencyManagement>, not <dependencies>.
 
Himani Bhatia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for help, really appreciate to burn your time on this.

I will try adding in <dependencyManagment>

But, my all projects are successfully build in mvn with these POM.

Just, that having issue with Jenkins at Maven WebApp stage (All projects build successfully).

 
Stephan van Hulst
Saloon Keeper
Posts: 10506
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can significantly reduce the complexity of your dependency graph if you do the following steps:

  • Upgrade Spring to 4.0.5.RELEASE.
  • Remove spring-core, spring-beans and spring-context from your parent POM.
  • Upgrade spring-ws-core to 2.2.0.RELEASE.
  • Remove hibernate-commons-annotations, hibernate-annotations, hibernate-core, hibernate, cglib, asm, and cglib-nodep from your child POM.
  • Configure hibernate-commons-annotations to exclude slf4j-api.

  • You should probably also give spring-test the test scope. The resulting POMs look something like this:


    Try it out, and let me know if your project compiles and runs successfully.
     
    Himani Bhatia
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I removed Proxy settings from $maven_home/conf/settings.xml and it Worked for me :-)

    Since, I was getting Error: Plugin org.apache.maven.plugins:maven-war-plugin:2.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:2.2: Could not transfer artifact org.apache.maven.plugins:maven-war-plugin:pom:2.2 from/to central (https://repo.maven.apache.org/maven2): Failed to transfer file: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.2/maven-war-plugin-2.2.pom. Return code is: 400 , ReasonPhrase:Bad Request. -> [Help 1]

    Thanks everyone for help :-)
     
    Beauty is in the eye of the tiny ad.
    professionally read, modify and write PDF files from Java
    https://products.aspose.com/pdf/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!