1

i have a x-module with those properties:

module-name: x-datamodel

this is a part of the pom.xml

<groupId>com.x.datamodel</groupId>
<artifactId>x</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

i have install the project in a local repository with this command line:

mvn install:install-file -Dfile=/Users/me/Documents/Projects/x-datamodel/target/classes/x-datamodel.jar -DgroupId=com.x.datamodel -DgeneratePom=true -DlocalRepositoryPath=/Users/me/Documents/Projects/me-repository  -DcreateChecksum=true -DartifactId=x -Dversion={1.0} -Dpackaging=jar

and added the project in bitbucket.

I try to integrate the module x in another project y.

here a part of the y's pom.xml

<dependency>
    <groupId>com.x.datamodel</groupId>
    <artifactId>x</artifactId>
    <version>${x.version}</version>
</dependency>

<repositories>
    <repository>
        <id>me-repository</id>
        <url>https://bitbucket.org/me/me-repository/src/master</url>
    </repository>
</repositories>

i can import some classes of the module x in the project y, but when i build the y project i get this error:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[18,12] cannot find symbol
  symbol:   class User
  location: class com.y.server.serviceImpl.UserServiceImpl
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/security/CustomUserDetailsService.java:[3,32] package com.x.datamodel.model does not exist
[INFO] 16 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:56 min
[INFO] Finished at: 2016-12-28T15:51:05+01:00
[INFO] Final Memory: 29M/209M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project y: Compilation failure: Compilation failure:
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[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/MojoFailureException

after installing the repository i have the library into this path:

.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar

why not:

.m2/repository/com/x-datamodel/x/1.0/x-1.0.jar
emoleumassi
  • 4,881
  • 13
  • 67
  • 93
  • Should `-Dversion={1.0}` have been `-Dversion=1.0`? – yshavit Dec 28 '16 at 15:13
  • didn't resolve the problem. same issue – emoleumassi Dec 28 '16 at 15:38
  • does the url specified include the `jar`? did you deploy to the remote from wherr you are trying to access? – Naman Dec 28 '16 at 16:50
  • A similar thread - http://stackoverflow.com/questions/14013644/hosting-a-maven-repository-on-github – Naman Dec 28 '16 at 16:50
  • Just wondering: why not do `cd /Users/me/Documents/Projects/x-datamodel/` followed by a `mvn install`? Also this looks weird: `/Users/me/Documents/Projects/x-datamodel/target/classes/x-datamodel.jar`. I would not expect the jar under `classes`, but under `target`. And finally, confirm you can open `/Users/me/Documents/Projects/x-datamodel/target/(classes/)x-datamodel.jar` – Robert Scholte Dec 28 '16 at 17:06
  • @RobertScholte i decided to build the x-datamodel.jar in this folder. i can do it in a different folder like target. I don't this, that this is the problem. – emoleumassi Dec 28 '16 at 17:20
  • @emoleumassi the question was not about you having access to the repository but being able to deploy to the url and then specifying the repository in the pom.xml. – Naman Dec 28 '16 at 17:28
  • 1
    Answer is groupId `com.x.datamodel` ensures `com/x/model/` as folder structure which is followed by `artifactId-version.jar` file name – Naman Dec 28 '16 at 17:29

2 Answers2

0

I tend to think the file is corrupted. Try deleting it and downloading it again.

leeyuiwah
  • 6,562
  • 8
  • 41
  • 71
  • i do it. i removed all util .m2/repository/ and run mvn clean install. But same issue – emoleumassi Dec 28 '16 at 15:22
  • If you have the checksum of the jar file, try comparing it with the that of your downloaded file. Also, you can try `jar tvf` to list the contents of the jar file just as a sanity check. Good luck! – leeyuiwah Dec 28 '16 at 15:37
0

Try removing the below lines

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

With :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
</plugin>
Abhilash Ramteke
  • 367
  • 1
  • 4
  • 11