views:

775

answers:

2

If I reference the SnakeYAML jar directly from a test program (see bottom), everything works. If I'm inside my Maven-created project, I get the following output from my unit tests:

java.lang.NoSuchMethodError: java.util.LinkedList.push(Ljava/lang/Object;)V
    at org.yaml.snakeyaml.scanner.ScannerImpl.addIndent(ScannerImpl.java:482)
    at org.yaml.snakeyaml.scanner.ScannerImpl.fetchBlockEntry(ScannerImpl.java:653)
    at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:268)
    at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:178)
    at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:213)
    at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:172)
    at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143)
    at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:163)
    at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:66)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:60)
    at org.yaml.snakeyaml.Loader.load(Loader.java:35)
    at org.yaml.snakeyaml.Yaml.load(Yaml.java:134)

Since Maven couldn't find SnakeYAML in the central repos, I manually installed it into my local repo. In case it matters, I'm on a Mac using SnakeYAML 0.9, and Maven 2.0.9.

Sample YAML File

- 
    accountCode: foo
    accountId: 1
    email: [email protected]
    userId: 1

Working Test Program

import java.io.*;
import java.util.*;

import org.yaml.snakeyaml.Yaml;

/**
 * Testing SnakeYAML.
 *
 * @author Hank Gay
 */
public final class Foo {
    public static void main(final String[] args) throws Exception {
        final Yaml yaml = new Yaml();
        Reader reader = null;
        try {
            reader = new FileReader("/tmp/foo.yaml");
            System.out.println(yaml.load(reader));
        } catch (final FileNotFoundException fnfe) {
            System.err.println("We had a problem reading the YAML from the file because we couldn't find the file." + fnfe);
        } finally {
            if (null != reader) {
                try {
                    reader.close();
                } catch (final IOException ioe) {
                    System.err.println("We got the following exception trying to clean up the reader: " + ioe);
                }
            }
        }
    }
}
+2  A: 

Seems like a JDK version issue: LinkedList#push was introduced in Java 6.

Try setting JAVA_HOME to the correct version before running Maven.

Olivier
Thanks. `java -version` revealed 1.6, but `mvn -version` revealed I had the wrong JDK referened in $JAVA_HOME.
Hank Gay
+2  A: 

fixed in release 1.0rc1

All Java 6 dependencies are removed from SnakeYAML.

Is there some documentation on which <repository> I need to add to my POM to get SnakeYAML to download? I wound up just installing the JAR manually.
Hank Gay
There is no remote repository yet. Once SnnkeYAML reaches 1.0 it will be uploaded somewhere.
SnakeYAML 1.0 is released. The remote MAven 2 repository can be found here:http://trac-hg.assembla.com/snakeyaml