0

i am unable to build my springboot project, I am using classes from another springboot jar, which i placed on the build path, its running in local via eclipse, but is not building, here's the error

"[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ContentManagementService 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ contentmanagementapi ---
[INFO] Deleting /home/bhargavgundu/git/contentmanagementservice/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ contentmanagementapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ contentmanagementapi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 42 source files to /home/bhargavgundu/git/contentmanagementservice/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
  symbol:   class SlackService
  location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
  symbol:   class UserDAO
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
  symbol:   class SlackService
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
  symbol:   class LicenseV5
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.917s
[INFO] Finished at: Tue Sep 12 17:16:44 IST 2017
[INFO] Final Memory: 24M/396M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project contentmanagementapi: Compilation failure: Compilation failure:
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
[ERROR] symbol:   class SlackService
[ERROR] location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
[ERROR] symbol:   class UserDAO
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
[ERROR] symbol:   class SlackService
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
[ERROR] symbol:   class LicenseV5
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[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
"

It is showing errors wherever i am using classes/functions from the external jar, can someone help? MY POM-

here is my POM

<?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.conduiraonline</groupId>
    <artifactId>contentmanagementapi</artifactId>
    <version>0.0.1</version>
    <packaging>jar</packaging>

    <name>ContentManagementService</name>
    <description>ContentManagementService</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.conduiraonline</groupId>
            <artifactId>licenseapi</artifactId>
            <version>0.0.1</version>
            <classifier>exec</classifier>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>21.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>
Bhargav
  • 697
  • 3
  • 11
  • 29
  • Compile time errors, check whether the necessary JAR files are included and do the JAR files added suffice? – N00b Pr0grammer Sep 12 '17 at 11:54
  • you need to add the maven dependency of your external jar in your pom – cralfaro Sep 12 '17 at 11:54
  • @cralfaro i did add it, check the lines having "licenseapi" – Bhargav Sep 12 '17 at 11:55
  • add compile – cralfaro Sep 12 '17 at 12:03
  • Whenever you want add jar to your project add it as dependency in your project instead of adding it in build path, because maven won't recognize the build path jars, if the dependency is not available in repositories create maven dependency script https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project and run it on classpath level – Mahender Ambala Oct 09 '18 at 08:00

2 Answers2

1

TL;DR

Remove <classifier>exec</classifier> from the dependency on com.conduiraonline:licenseapi

More Details ...

You are correct in using <dependency> to express the relationship between com.conduiraonline:contentmanagementapi and com.conduiraonline:licenseapi. Or to put it another way; this is the right way to tell Maven that the module com.conduiraonline:contentmanagementapi depends on the module com.conduiraonline:licenseapi.

However, you have defined the dependency on com.conduiraonline:licenseapi as:

    <dependency>
        <groupId>com.conduiraonline</groupId>
        <artifactId>licenseapi</artifactId>
        <version>0.0.1</version>
        <classifier>exec</classifier>
    </dependency>

The classifier tells Maven to look for an file named licenseapi.exec in the folder com/conduiraonline in your local Maven repo (and failing that, try to resolve that dependency from whatever remote repositories you have configured in your Maven settings.xml or in this pom.xml).

I presume there is no file named licenseapi.exec in the folder com/conduiraonline in your local Maven repo because exec is a very unusual classifier for a Maven artifact.

As long as a JAR for com.conduiraonline:licenseapi with version 0.0.1 has been installed in your local Maven repo this dependency will work:

    <dependency>
        <groupId>com.conduiraonline</groupId>
        <artifactId>licenseapi</artifactId>
        <version>0.0.1</version>
    </dependency>

You install a JAR for com.conduiraonline:licenseapi with version 0.0.1 in your local Maven repo by running mvn clean install for the licenseapi module (assuming that the pom.xml for the licenseapi modules has <version>0.0.1</version>).

glytching
  • 44,936
  • 9
  • 114
  • 120
  • This worked, Thanks :) i have one doubt, once i do this, that jar need not be present on the class path also right? – Bhargav Sep 12 '17 at 13:52
  • By declaring that dependency you are telling Maven that `com.conduiraonline:contentmanagementapi` has a compile dependency on `com.conduiraonline:licenseapi`. I'm not fully sure what you mean by "that jar need not be present on the class path" but by declaring that dependency you are saying that you **do** expect that JAR to be present on the classapth. – glytching Sep 12 '17 at 13:59
0

You must add the path of your jars / folder containing jars in your gradle or maven build file.

For example in gradle add

    compile fileTree(dir: 'path_to_ext_libs', include: '*.jar')

to your dependencies in the build.gradle then all the jars in the libs folder will be then included.

or in maven

<repositories>
   <repository>
     <id>local-files</id>
     <name>local-files</name>
     <url>file://c:\test\filerepo</url>
  </repository>

Naveed Kamran
  • 453
  • 1
  • 4
  • 16