java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.<init>(Lorg/yaml/snakeyaml/constructor/BaseConstructor;)V

7,638 views
Skip to first unread message

Annapurna Rambhotla

unread,
Oct 27, 2011, 5:03:40 PM10/27/11
to snakeya...@googlegroups.com, py4...@gmail.com
Hi,

I am trying to load yaml document using the following code:

Yaml yaml = new Yaml(new Constructor(ConfigData.class));

This worked when my ConfigData was a follows:

public class ConfigData {
    private Class<Action<? extends Serializable, ? extends Serializable>> actionClass;

    private String actionName;
    private Object inputData;
    private String testID;
    private List<ConfigData> children;
    private ConfigData tearDownAction;

//excluding getters/setters just to make this email concise...
}

But now I added two more properties to it :
public class ConfigData {
    private Class<Action<? extends Serializable, ? extends Serializable>> actionClass;

    private String actionName;
    private Object inputData;
    private String testID;
    private List<ConfigData> children;
    private ConfigData tearDownAction;
    private Integer retryIntervalInSecond;
    private Integer retryCount;

//excluding getters/setters just to make this email concise...
}

Now when I get the following error when I run the same test case:

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.<init>(Lorg/yaml/snakeyaml/constructor/BaseConstructor;)V

Is it the problem with Integer type?

Could someone clarify on this please.

Thanks,
Annu


Andrey

unread,
Oct 27, 2011, 6:23:09 PM10/27/11
to snakeya...@googlegroups.com, py4...@gmail.com
Hi,
Integer is fully supported.

If you manage to create a (failing) JUnit test case, we can see what is going wrong...

-
Andrey

Annapurna Rambhotla

unread,
Oct 27, 2011, 7:10:35 PM10/27/11
to snakeya...@googlegroups.com, py4...@gmail.com

Hi Andrey,

Thanks for your quick response. One of my team mate updated TestNG  version from 5.8 to 6.2 and hence that is causing this issue. When I reverted to 5.8 the test is working fine.

I am not sure why TestNG version affects parser.

Any idea?

Thanks,
Annu

--
You received this message because you are subscribed to the Google Groups "SnakeYAML" group.
To view this discussion on the web visit https://groups.google.com/d/msg/snakeyaml-core/-/SsCMEKbC4ggJ.
To post to this group, send email to snakeya...@googlegroups.com.
To unsubscribe from this group, send email to snakeyaml-cor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/snakeyaml-core?hl=en.

maslovalex

unread,
Oct 28, 2011, 1:52:32 AM10/28/11
to snakeya...@googlegroups.com, py4...@gmail.com
Hi Annu.

Look ant the exception - it means construtor does not exists.
The problem is testng 6.2 's dependency - snakeyaml-1.6.
And Yaml(BaseConstructor) was introduced after 1.6 release - see this diff.
I have same problem with testng and bsh under Eclipse. Eclipse always uses classes from testng dependencies even they have test scope (maybe m2eclipse problem).

-alex

Andrey Somov

unread,
Oct 28, 2011, 3:11:55 AM10/28/11
to snakeya...@googlegroups.com
May be the best solution is to report a bug for TestNG ?
The migration to SnakeYAML 1.9 should not be that difficult for TestNG...

-
Andrey

Annapurna Rambhotla

unread,
Oct 28, 2011, 12:23:38 PM10/28/11
to snakeya...@googlegroups.com, alexande...@gmail.com, py4...@gmail.com
Hi Andrey,

I did upgrade SnakeYAML to 1.9 and rerun my test and it still fails with the same issue.
Do you think the issue is in TestNG?

Alex, I am not running test from IntelliJ directly. I am using "mvn test" from my linux host.

Thanks,
Annu

--
You received this message because you are subscribed to the Google Groups "SnakeYAML" group.

Andrey Somov

unread,
Oct 28, 2011, 12:43:25 PM10/28/11
to snakeya...@googlegroups.com
I mean TestNG should upgrade.
As from version 6 they have support for YAML format for the test
specification. That is why they have a dependency on SnakeYAML.
You have a conflict in your classpath. You wish version 1.9, but one
of your dependencies (TestNG) wants another version. Usual problem. No
general solution.

-
Andrey

Annapurna Rambhotla

unread,
Oct 28, 2011, 3:41:27 PM10/28/11
to Andrey Somov, snakeya...@googlegroups.com
Hi Andrey,

Thanks a lot for this pointer. I did the following and my test runs fine:
<dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.2</version>
            <type>jar</type>
            <exclusions>
                <exclusion>
                    <artifactId>snakeyaml</artifactId>
                    <groupId>org.yaml</groupId>
                </exclusion>
            </exclusions>
        </dependency>

Thanks once again for your quick response!

-Annu

Andrey Somov

unread,
Oct 28, 2011, 6:53:57 PM10/28/11
to snakeya...@googlegroups.com
You are welcome.

Just for your information. You have explicitly ignored the version
defined in TestNG in favor of the latest version. Even though we try
to keep the backward compatibility, 1.6 and 1.9 are not fully
backwards compatible. It means that if TestNG is using any of the
functionality which has been changed, you may still face the problems.
If you do not define your tests with YAML, you should be safe...

-
Andrey

Reply all
Reply to author
Forward
0 new messages