Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.loadAs #13

Closed
dzmitrys-dev opened this issue Jun 6, 2014 · 10 comments
Closed

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.loadAs #13

dzmitrys-dev opened this issue Jun 6, 2014 · 10 comments

Comments

@dzmitrys-dev
Copy link

I tried to use JFairy in my project (TestNG 6.8.5) and got

java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.loadAs(Ljava/io/InputStream;Ljava/lang/Class;)Ljava/lang/Object;
at eu.codearte.fairyland.data.DataMaster.readResources(DataMaster.java:92)
at eu.codearte.fairyland.Fairy.(Fairy.java:35)
at eu.codearte.fairyland.Fairy.create(Fairy.java:72)
at eu.codearte.fairyland.Fairy.create(Fairy.java:61)
at eu.codearte.fairyland.Fairy.create(Fairy.java:50)
at org.stormnetdev.inputdata.testdata.DataProvider.(DataProvider.java:6)
at org.stormnetdev.pageobjects.sampletest.GoogleHomePage.performRandomPersonSearchQuery(GoogleHomePage.java:24)
at org.stormnetdev.tests.sampletest.SampleTest.sampleTest(SampleTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

@jkubrynski
Copy link
Member

Which version of SnakeYaml do you use?

@dzmitrys-dev
Copy link
Author

Ive installed jfairy via maven, so it loaded SnakeYaml 1.13, testng 6.8.8 uses SnakeYaml 1.12

Here is my pom fragment

<dependency>
    <groupId>org.jfairy</groupId>
    <artifactId>jfairy</artifactId>
    <version>0.2.4</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.8.8</version>
</dependency>

@jkubrynski
Copy link
Member

This method is available in SnakeYAML since version 1.9 - it looks like you have some old version in your classpath. Could you paste effective pom output?

@dzmitrys-dev
Copy link
Author

Sure, thank you for fast response


4.0.0
com.stormnetdev
webtestautomationframework
0.0.1-SNAPSHOT


org.jfairy
jfairy
0.2.4
compile


org.testng
testng
6.8.8
compile





false

central
Central Repository
http://repo.maven.apache.org/maven2





never


false

central
Central Repository
http://repo.maven.apache.org/maven2



/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/src
/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/src/main/scripts
/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/src/test/java
/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/classes
/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/test-classes


/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/src/main/resources




/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/src/test/resources


/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target
webtestautomationframework-0.0.1-SNAPSHOT



maven-antrun-plugin
1.3


maven-assembly-plugin
2.2-beta-5


maven-dependency-plugin
2.1


maven-release-plugin
2.0





maven-compiler-plugin
3.1


default-compile
compile

compile


1.7
1.7



default-testCompile
test-compile

testCompile


1.7
1.7




1.7
1.7



maven-clean-plugin
2.4.1


default-clean
clean

clean





maven-resources-plugin
2.5


default-testResources
process-test-resources

testResources



default-resources
process-resources

resources





maven-jar-plugin
2.3.2


default-jar
package

jar





maven-surefire-plugin
2.10


default-test
test

test





maven-install-plugin
2.3.1


default-install
install

install





maven-deploy-plugin
2.7


default-deploy
deploy

deploy





maven-site-plugin
3.0


default-site
site

site


/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/site


org.apache.maven.plugins
maven-project-info-reports-plugin





default-deploy
site-deploy

deploy


/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/site


org.apache.maven.plugins
maven-project-info-reports-plugin






/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/site


org.apache.maven.plugins
maven-project-info-reports-plugin







/Users/dzmitrysukhau/Workspace Eclipse/webtestautomationframework/target/site

@jkubrynski
Copy link
Member

I need one more thing - output of the
$ mvn dependency:tree

@dzmitrys-dev
Copy link
Author

Please note that http://mvnrepository.com/artifact/org.yaml/snakeyaml here 1.13 is listed as the latest version and was downloaded automatically after adding

org.jfairy
jfairy
0.2.4
compile

@dzmitrys-dev
Copy link
Author

[INFO] com.stormnetdev:webtestautomationframework:jar:0.0.1-SNAPSHOT
[INFO] +- org.jfairy:jfairy:jar:0.2.4:compile
[INFO] | +- joda-time:joda-time:jar:2.3:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] | +- com.google.guava:guava:jar:15.0:compile
[INFO] | +- org.yaml:snakeyaml:jar:1.13:compile (version selected from constraint [1.0,2.0))
[INFO] | +- com.google.inject:guice:jar:3.0:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | - aopalliance:aopalliance:jar:1.0:compile
[INFO] | - org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] - org.testng:testng:jar:6.8.8:compile
[INFO] +- org.beanshell:bsh:jar:2.0b4:compile
[INFO] - com.beust:jcommander:jar:1.27:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

I hope this would help

@jkubrynski
Copy link
Member

It's really strange - version 1.13 of SnakeYaml works great with JFairy so there is probably bug that I cannot see. Could you share this project, that I can build it locally?

@dzmitrys-dev
Copy link
Author

https://bitbucket.org/stormcore/webtestautomationframework/commits/all
there are some maven-managed dependencies, project can be run only in eclipse with testng plugin, try org.stormnetdev.tests.sampletest to run as testng test

it fails when I try to execute DataProvider.dataGenerator.company().name() in org.stormnetdev.pageobjects.sampletest.GoogleHomePage which executes

package org.stormnetdev.inputdata.testdata;
import org.jfairy.Fairy;
public class DataProvider {
public static Fairy dataGenerator = Fairy.create();
public static Fairy getGenerator() {
return dataGenerator;
}
}

@jkubrynski
Copy link
Member

Hmmm - when you use maven it's good to keep all maven conventions that tests could be executed from Maven, eg:

  • production files should be in /src/main/java
  • test files should be under /src/test/java

I've checked and everything is ok - probably your eclipse classpath has some incorrect snakeyaml version ( < 1.9) and uses it when running tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants