Problems while installing SnakeYAML using Maven

787 views
Skip to first unread message

Helen

unread,
May 19, 2017, 3:32:02 AM5/19/17
to SnakeYAML
Hi!

I have tried to install the library in a Maven project.I have followed the steps of your installation guide. However, even if there are the .jar files in ~/.m2, when I try to create a YAML object I got the following error: java.lang.NoClassDefFoundError: org/yaml/snakeyaml/Yaml. Moreover, I am not familiarize with Maven.

What could be the problem? 

Best Regards,

Helen.
~/.m2/settings.xml:
<repository>
    <id>Sonatype-public</id>
    <name>SnakeYAML repository</name>
    <url>http://oss.sonatype.org/content/groups/public/</url>
  </repository>
~/.m2/repository/pom.xml:
  <dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
    <version>1.18-SNAPSHOT</version>
  </dependency>

Andrey Somov

unread,
May 19, 2017, 4:20:07 AM5/19/17
to snakeya...@googlegroups.com
Dear Helen,
there may be a zillion reaons why you do not have SnakeYAML in your classpath.

This mailing list is not the best place to ask for such kind of support.

Cheers,
Andrey


--
You received this message because you are subscribed to the Google Groups "SnakeYAML" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snakeyaml-core+unsubscribe@googlegroups.com.
To post to this group, send email to snakeyaml-core@googlegroups.com.
Visit this group at https://groups.google.com/group/snakeyaml-core.
For more options, visit https://groups.google.com/d/optout.

Joachim Durchholz

unread,
May 19, 2017, 4:47:53 AM5/19/17
to snakeya...@googlegroups.com
> What could be the problem?
I see a (probably unrelated) problem: SNAPSHOT versions are
work-in-progress, which you probably don't want. Even if you wanted the
latest, bleeding-edge, cut-yourself version, it's probably not a good
idea to use them if you aren't familiar with Maven yet. (BTW consider
Gradle instead. Maven isn't particularly suitable for small team sizes.)

> when I try to create a YAML object I got the
> following error: java.lang.NoClassDefFoundError:
> org/yaml/snakeyaml/Yaml.

This kind of thing shouldn't possibly happen if the build is done with
Maven.
Is Maven run? It should be emitting quite a lot of messages on the
console. If you're using an IDE, you need to tell the IDE that it should
use Maven, otherwise you can build and run your application on the
command line but the IDE will not know that it should use the .jars
provided by Maven. In Eclipse, this means installing m2e and converting
your project to a Maven project. Or maybe set up a new Maven project and
move your code over - m2e is pretty intrusive and expects a lot of
things about what subdirectory holds what kinds of sources, like this:

src/main/java/ - application code, all .java files
src/main/resources/ - anything non-.java for the application
src/test/java/ - automated test code, all .java files
src/test/resources/ - anything non-.java for the automated tests

More elaborate directory structures do exist, but most projects
(including highly professionals) aren't even aware of that.
https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
will give you an idea of what variations exist; plugins may define more
standard directory but usually do not.

> However, even if there are the .jar files in ~/.m2,

These are automatically downloaded there whenever you run Maven, so you
don't need to worry about whether they're present there or not.
Inspecting .m2/ is useful to verify that a download did happen; the
usual approach is to kill the directory (or just the .jar you're
interested in) and see whether it downloads again.
(This is usually frowned upon by the administrators of the repository,
because they all have huge day-per-day download bandwidth and pay per
gigabyte, so this is something that one shouldn't do unless one has a
reason to.)

HTH
Jo
Reply all
Reply to author
Forward
0 new messages