cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5999
Views
3
Helpful
13
Replies

intelliJ/Maven CS SDK Dependency Errors

rdediana
Cisco Employee
Cisco Employee

Hello folks.

I'm experiencing the same issue identified in the following discussion: intelliJ/Maven CS SDK issue

i'm following the getting started guide

https://developer.cisco.com/site/context-service/discover/getting-started/

Error:(6, 39) java: package com.cisco.thunderhead.connector does not exist

Error:(7, 36) java: package com.cisco.thunderhead.plugin does not exist

i've added the required dependencies to the pom.xml file:

the compiler is highlighting the <version>2.0.1</version> with an error: dependency not found

<dependencies>

   <dependency>

        <groupId>com.cisco.thunderhead</groupId>

        <artifactId>context-service-sdk</artifactId>

        <version>2.0.1</version>

   </dependency>

   <dependency>

        <groupId>commons-logging</groupId>

        <artifactId>commons-logging</artifactId>

       <version>1.2</version>

   </dependency>

</dependencies>


<edit>

[ERROR]

[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

RDEDIANA-M-H1S6:cs-example regandediana$ mvn clean install

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building sdk-example 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[WARNING] The POM for com.cisco.thunderhead:context-service-sdk:jar:2.0.1 is missing, no dependency information available

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.298 s

[INFO] Finished at: 2017-06-20T17:52:03-04:00

[INFO] Final Memory: 8M/245M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal on project sdk-example: Could not resolve dependencies for project com.cisco.thunderhead:sdk-example:jar:1.0-SNAPSHOT: Failure to find com.cisco.thunderhead:context-service-sdk:jar:2.0.1 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]

[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

</edit>


any thoughts our suggestions would be greatly appreciated.

Regan

1 Accepted Solution

Accepted Solutions

I just noticed that you were using sudo to do the maven install.  Check which directory intellij is using for your local maven repo.  To do that, go to preferences/Build, Execution, Deployment/Build Tools/Maven.  Check on the right where the local repository is pointed.  Make sure that matches where the files are getting installed.  Above, it looks like because you are running sudo its getting installed in /var/root/.m2/repository.  IntelliJ is not likely to be running as root.  IntelliJ is probably using /Users/regandediana/.m2/repository.  If so, try running the mvn install:install-file command without using sudo.

View solution in original post

13 Replies 13

cvadnais
Level 1
Level 1

Have you run step 12 in the getting started guide to install the pom file in your local maven repo?  Make sure to replace the 2.x.x with the correct version - 2.0.1 in your case.

mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.x.x.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.x.x -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-pom-2.x.x.xml



yes. it was successful.

NOTE: for what  it's worth, there is a typo in the guide; which initially caused it to fail. the version and -pom are reversed.

src/main/resources/context-service-sdk-pom-2.x.x.xml

>> actual SDK File name structure: context-service-sdk-2.0.1-pom.xml

mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.x.x.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.x.x -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-pom-2.x.x.xml

actual results:

RDEDIANA-M-H1S6:cs-example regandediana$ sudo mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.0.1.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.0.1 -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-2.0.1-pom.xml

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building sdk-example 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ sdk-example ---

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example/src/main/resources/context-service-sdk-2.0.1.jar to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.jar

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example/src/main/resources/context-service-sdk-2.0.1-pom.xml to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.473 s

[INFO] Finished at: 2017-06-20T18:43:39-04:00

[INFO] Final Memory: 10M/309M

[INFO] ------------------------------------------------------------------------

RDEDIANA-M-H1S6:cs-example regandediana$


it is after this step where the error is first seen: Step 13:


when copying the following to the pom.xml file (in the project directory)

<dependencies>

   <dependency>

   <groupId>com.cisco.thunderhead</groupId>

   <artifactId>context-service-sdk</artifactId>

   <version>2.0.1</version>

   </dependency>

   <dependency>

   <groupId>commons-logging</groupId>

   <artifactId>commons-logging</artifactId>

   <version>1.2</version>

   </dependency>

</dependencies>

i was able use a temporary solution to resolve the pom.xml file by adding the <systemPath> element to explicitly specific the SDK jar.

<dependency>

   <groupId>com.cisco.thunderhead</groupId>

   <artifactId>context-service-sdk</artifactId>

   <version>2.0.1</version>

   <systemPath>${basedir}/src/main/resources/context-service-sdk-2.0.1.jar</systemPath>

</dependency>

As suggested, this did resolve the issue in the pom.xml file, however, it does indicate that maven or the complier is not able to locate the SDK dependencies. i did review the system path and variables to ensure they are referencing the correct locations

M2_HOME=/Users/regandediana/apache-maven/apache-maven-3.5.0

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin

echo $PATH

...<abreviate>...:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin:/Users/regandediana/apache-maven/apache-maven-3.5.0/bin

unfortunately, this issue is still persistent; after creating the Register.java class in the tutorial step Register with Context Service the compiler is not able to resolve the SDK artifacts.

any suggestions on how to properly set dependency references for the project? or how to resolve the issues?

thanks for you support.

Regan

i believe if found a temporary solution. in IntelliJ >Program Structure > Modules.

this configuration tool illustrates the issue. i was able to add an external Jar file (cs-sdk) and resolved the reference issues in the Register.java class.

Screen Shot 2017-06-21 at 11.38.54 AM.png

however, these are workarounds to a larger issue. any guidance to properly resolved would be greatly appreciated.

Regan

I see that you incorrectly entered the mvn install command from step 12 first before entering it correctly. I'm wondering if that somehow is causing your problems. I think it would be beneficial to delete your ~/.m2 directory and then re-enter the mvn install command from step 12. Once you do that, please verify that the 2.0.1 sdk jar and pom files have been successfully installed in the correct location: ~/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1. Once that has been done, right click on the root of your project in intellij and select Maven > Reimport. You should see the 2.0.1 sdk appear in your external dependencies.

Still Same issue.

Deleted jars from local maven repo

RDEDIANA-M-H1S6:repository regandediana$ pwd

/var/root/.m2/repository

RDEDIANA-M-H1S6:repository regandediana$ ls

classworlds com junit org

RDEDIANA-M-H1S6:repository regandediana$ sudo rm -rf com/

Maven jar SDK install to local repo

RDEDIANA-M-H1S6:cs-example regandediana$ sudo mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.0.1.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.0.1 -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-2.0.1-pom.xml

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building sdk-example 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ sdk-example ---

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example/src/main/resources/context-service-sdk-2.0.1.jar to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.jar

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example/src/main/resources/context-service-sdk-2.0.1-pom.xml to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.483 s

[INFO] Finished at: 2017-06-21T14:28:20-04:00

[INFO] Final Memory: 9M/245M

[INFO] ------------------------------------------------------------------------


IntelliJ is reporting:

Library Maven: com.cisco.thunderhead:context-service-sdk:2.0.1 has broken classes path:   /Users/regandediana/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.jar [Fix]



** is it possible that the system variable are not properly configured? **


Current Environment system variables

RDEDIANA-M-H1S6:cs-example regandediana$ which mvn

/Users/regandediana/apache-maven/apache-maven-3.5.0/bin/mvn

RDEDIANA-M-H1S6:cs-example regandediana$ echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

RDEDIANA-M-H1S6:cs-example regandediana$ echo $M2_HOME

/Users/regandediana/apache-maven/apache-maven-3.5.0

RDEDIANA-M-H1S6:cs-example regandediana$ echo $PATH

/usr/local/Cellar/python/2.7.11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/bin/jamf:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin:/Users/regandediana/apache-maven/apache-maven-3.5.0/bin


cheers.

I just noticed that you were using sudo to do the maven install.  Check which directory intellij is using for your local maven repo.  To do that, go to preferences/Build, Execution, Deployment/Build Tools/Maven.  Check on the right where the local repository is pointed.  Make sure that matches where the files are getting installed.  Above, it looks like because you are running sudo its getting installed in /var/root/.m2/repository.  IntelliJ is not likely to be running as root.  IntelliJ is probably using /Users/regandediana/.m2/repository.  If so, try running the mvn install:install-file command without using sudo.

Hi Christopher.

yes. that seems to point something i've recently noticed.

to you point. when i issue the maven install it is installing files to /var/root/.m2 path rather than /users/regandediana/.m2

RDEDIANA-M-H1S6:cs-example-project regandediana$ sudo mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.0.1.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.0.1 -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-2.0.1-pom.xml

Password:

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building sdk-example 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ sdk-example ---

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example-project/src/main/resources/context-service-sdk-2.0.1.jar to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.jar

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example-project/src/main/resources/context-service-sdk-2.0.1-pom.xml to /var/root/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.500 s

[INFO] Finished at: 2017-06-23T08:59:04-04:00

[INFO] Final Memory: 9M/245M

[INFO] ------------------------------------------------------------------------

RDEDIANA-M-H1S6:cs-example-project regandediana$

RDEDIANA-M-H1S6:2.0.1 regandediana$ pwd

/Users/regandediana/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1

RDEDIANA-M-H1S6:2.0.1 regandediana$ ls

context-service-sdk-2.0.1.jar context-service-sdk-2.0.1.pom

RDEDIANA-M-H1S6:2.0.1 regandediana$



one thing i did notice was that the jar and pom sdk files and .lastUpdated appended to the end. this was causing an error when trying to reference them in the pom.xml dependency configuration. when i removed the .lastUpdated these files were properly discovered.


these issue may be related....


i'll try the maven install WITHOUT sudo. however, i suspect since mv install is trying to place the files in var/root ill be prompted once again.


trying now and will update with the results.


thanks again.

ok.

yes. removing sudo did change the destination .m2 repository location.

RDEDIANA-M-H1S6:cs-example-project regandediana$ mvn install:install-file -Dfile=src/main/resources/context-service-sdk-2.0.1.jar -DgroupId=com.cisco.thunderhead -DartifactId=context-service-sdk -Dversion=2.0.1 -Dpackaging=jar -DpomFile=src/main/resources/context-service-sdk-2.0.1-pom.xml

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building sdk-example 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ sdk-example ---

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example-project/src/main/resources/context-service-sdk-2.0.1.jar to /Users/regandediana/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.jar

[INFO] Installing /Users/regandediana/IdeaProjects/cs-example-project/src/main/resources/context-service-sdk-2.0.1-pom.xml to /Users/regandediana/.m2/repository/com/cisco/thunderhead/context-service-sdk/2.0.1/context-service-sdk-2.0.1.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.485 s

[INFO] Finished at: 2017-06-23T09:28:53-04:00

[INFO] Final Memory: 10M/309M

[INFO] ------------------------------------------------------------------------

RDEDIANA-M-H1S6:cs-example-project regandediana$


i'm still getting some errors. however, this is most likely a result of my tinkering around the Intelligj IDE configuration attributes.  current issue is:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

  at com.cisco.thunderhead.plugin.ConnectorFactory.<clinit>(ConnectorFactory.java:65)

  at Register.main(Register.java:8)

Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory

  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)

  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

  ... 2 more

Process finished with exit code 1

will rebuild the project again with mv install change; hopefully will resolve the existing issue. crossing fingers.

thanks Christopher. that was it.

using sudo was putting the sdk in the wrong repository.

cheers.

FYI, using sudo is generally BAD when _using_ build tools. Unless something explicitly says to use sudo, you should not.

Hi,

Not sure if you still need help, but if so, can you please try following the README located here?

https://github.com/CiscoDevNet/context-service-sample-code/tree/master/End-To-End_Sample_Code

Thanks

Tom

Thomas. thanks. i'll give that a shot.