Mause / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

Getting Unknown Tag error message while loading data from yaml file #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just loading data from attached yaml file using the below java code
InputStream input = getInputFileStream(fileName);
if (input == null) {
    FileNotFoundException e = new FileNotFoundException("Resource " + fileName + " not found");
    logger.log(Level.SEVERE, e.getMessage(), e);
    throw e;
}
reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
yamlFile = new Yaml();
allObjects = new ArrayList<Object>();
Iterable<Object> it = yamlFile.loadAll(reader);

What is the expected output? What do you see instead?
It should successfully load all the data but i am geting the below error message

Can't construct a java object for tag:clarkevans.com,2002:invoice; 
exception=Unknown tag: tag:clarkevans.com,2002:invoice
 in "<reader>", line 1, column 5:
    --- !<tag:clarkevans.com,2002:invoice>
        ^

    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:105)
    at org.yaml.snakeyaml.Loader$1.next(Loader.java:64)
    at com.paypal.test.bluefin.platform.dataprovider.GUIMapYAMLDataProvider.<init>(GUIMapYAMLDataProvider.java:58)
    at com.paypal.test.bluefin.platform.dataprovider.NewYamlDataProviderTest.setUp(NewYamlDataProviderTest.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:640)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: org.yaml.snakeyaml.error.YAMLException: Unknown tag: 
tag:clarkevans.com,2002:invoice
    at org.yaml.snakeyaml.nodes.Tag.getClassName(Tag.java:98)
    at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:609)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:360)
    at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370)
    ... 21 more

What version of SnakeYAML are you using? On what Java version?

SneakYaml Version Used: 1.11
Java: 1.6.0_21

Please provide any additional information below. (Often a failing test is
the best way to describe the problem.)

Please let me know is this bug or i need to do any workaround

Original issue reported on code.google.com by skkanna...@gmail.com on 18 Jan 2013 at 10:54

Attachments:

GoogleCodeExporter commented 9 years ago
You have to provide a way to create an instance for the tag 
"clarkevans.com,2002:invoice".
You can remove the tag to create something by default.
Please read the spec about local tags and how to use them.
Mailing list is a better way to ask general questions.

Original comment by py4fun@gmail.com on 18 Jan 2013 at 3:38

GoogleCodeExporter commented 9 years ago
Thanks

Original comment by skkanna...@gmail.com on 21 Jan 2013 at 12:22