Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8267599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:35:34+00:00 2026-06-08T05:35:34+00:00

Trying to load up some fixture data in Play! 1.2.4 with SnakeYAML. Object type

  • 0

Trying to load up some fixture data in Play! 1.2.4 with SnakeYAML. Object type is Map<enum, Integer>. Error I am getting on Fixtures.loadModels(“quest.yml”) is “Cannot load fixture quests.yml: java.lang.String cannot be cast to java.lang.Enum”.

Code snippets-

Constants.java
public enum STATS {
        CREATIVITY, ENTHUSIASM, ...
}

Quest.java
@ElementCollection
@MapKeyEnumerated(EnumType.STRING)
public Map<Constants.STATS, Integer> reward;

quest.yml
Quest(sirlin):
    reward:
        CREATIVITY: 1 

As you can see, I’ve specified that I want to use the String value of the enum STATS with @MapKeyEnumerated annotation. I’m not sure how to change format of yml definition to get this working correctly. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:35:36+00:00Added an answer on June 8, 2026 at 5:35 am

    Well, I have found a ‘solution’ for play 1.2.4, it’s ugly, but it works.

    The first thing I found was this test case, that shows how it is you should do it:

    map:
      !!org.pacakge.EnumClass 'CLUBS': 1
      !!org.pacakge.EnumClass 'DIAMONDS': 2
    

    That would give a map with enums as keys.

    But it doesn’t work as it gives this exception:

    Can't construct a java object for tag:yaml.org,2002:models.Plazos; exception=Class not found: org.pacakge.EnumClass
    

    But then I found this and this. The problem happens because the Yaml parser (snakeyaml) creates its own ClassLoader in order to parse a .yml file. The structure of the Play! framework uses its own ClassLoader. The solution would be to replace this

    Yaml y = new Yaml();
    

    with this

    Yaml y = new Yaml(new CustomClassLoaderConstructor(playClassLoader));
    

    but, of course, that is being done inside the play.test.Fixtures class, so what was my solution? Well, copy that class into your project and replace in the method loadModels this line:

    Yaml yaml = new Yaml();
    

    with this one:

    Yaml yaml = new Yaml(new CustomClassLoaderConstructor(Play.classloader));
    

    And that will make it work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load some XML data into C++ code (classes) using gsoap.
Here are some models I am trying to load data for: class School(models.Model): name
I am trying to load some data (which may be up to a few
I'm trying to load some data using sql loader. Here is the top of
I am trying to load some GZIP-ed data from a resource in my .jar,
I am trying to load some JSON data into to a table using the
I'm trying to load some data from a plist file. It contains an NSArray
I am trying to load some data from a text file into a vector
i am trying to load some data using json and jquery the problem occurs
I am trying to load some data into R from an Access database. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.