Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:09:40+00:00 2026-06-01T17:09:40+00:00

I’m having problems resolving sub-dependencies from a third-party package. I’m a bit of a

  • 0

I’m having problems resolving sub-dependencies from a third-party package. I’m a bit of a Maven beginner. Basically it goes like this:

git clone git://github.com/unidata/thredds.git
cd thredds
mvn install

Everything works great and stuff is installed into ~/.m2. Now, I wrote my own code that uses the package that I just installed:

<?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>test</groupId>
    <artifactId>test</artifactId>
    <packaging>jar</packaging>
    <version>0.1</version>
    <name>Test Package</name>

    <dependencies>
        <dependency>
            <groupId>edu.ucar</groupId>
            <artifactId>netcdf</artifactId>
            <version>4.3.8-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

Ok, this also works great when I run mvn package. The netcdf artifact is found. Now, when I try to run my code, I start down a long ClassNotFoundException path, having to keep adding all of netcdf‘s dependencies to my classpath.

Am I doing something wrong, or should the thredds package and all its dependencies automatically be picked up?

edit: the thredds package has many sub-modules one of which is netcdf. My code only depends on the netcdf jar.

edit: the snapshot version is installed

$ ls -l ~/.m2/repository/edu/ucar/netcdf/4.3.8-SNAPSHOT/
total 4272
-rw-rw-r-- 1 nwatkins nwatkins     700 2012-03-29 23:23 maven-metadata-local.xml
-rw-rw-r-- 1 nwatkins nwatkins     182 2012-03-29 23:23 _maven.repositories
-rw-rw-r-- 1 nwatkins nwatkins 4357494 2012-03-29 23:23 netcdf-4.3.8-SNAPSHOT.jar
-rw-rw-r-- 1 nwatkins nwatkins    7840 2012-03-29 22:28 netcdf-4.3.8-SNAPSHOT.pom

edit: to run the code which is in a single file Test.java

$ java -cp target/test-0.1.jar Test

edit: first error message

$ java -cp target/test-0.1.jar Test

Exception in thread "main" java.lang.NoClassDefFoundError: ucar/ma2/InvalidRangeException
Caused by: java.lang.ClassNotFoundException: ucar.ma2.InvalidRangeException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)

edit: then I just try to manually add the dependency jar to the class path

$ java -cp ../thredds/cdm/target/netcdf-4.3.8-SNAPSHOT.jar:target/test-0.1.jar Test

xception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at ucar.nc2.NetcdfFile.<clinit>(NetcdfFile.java:97)
    at Test.main(Test.java:37)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 2 more

The slf4j package is also in ~/.m2. I stopped trying to add things to the classpath after this as it seemed like the wrong approach.
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:09:42+00:00Added an answer on June 1, 2026 at 5:09 pm

    Two solutions here (the cause of the problem has been explained in several answers):

    1.Use maven exec plugin to launch your app:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <classpathScope>runtime</classpathScope>
                    <executable>java</executable>
                    <commandlineArgs>-classpath %classpath Test</commandlineArgs>
                </configuration>
            </plugin>
    

    2.You can also package your jar with all its dependencies, using maven assembly plugin. To do that, you need to add the following to your plugins of your build:

    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
            <execution>
            <id>build-package</id>
            <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    

    Then you can use the output jar created by maven assembly in your classpath arg

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.