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 7405891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:28:22+00:00 2026-05-29T05:28:22+00:00

I have a dictionary-style application I’m working on with Java, and I’m using the

  • 0

I have a dictionary-style application I’m working on with Java, and I’m using the Simple framework for serialization. It includes an ArrayList of Strings, and the only problem I’ve encountered is that Simple will serialize/deserialize those Strings and change any empty values to null. I understand from this question that you need to use a Converter. I followed what was described on that page and added the class that Sand wrote in his answer (with the “new AnnotationStrategy()” change needed), and now this is what the main class that I’m having problems with looks like (with the numerous get/set methods stripped):

    public class Item  {

    @ElementList(name = "itemContents")
    @Convert(SimpleXMLStringConverter.class)
    private ArrayList<String> values;

    public Item()
    {
    }
}

Whenever I try to write the class to an XML file, I get this error:

org.simpleframework.xml.convert.ConvertException: Element annotation required for field 'values' private java.util.ArrayList main.LangComp.Item.values
    at org.simpleframework.xml.convert.ConverterScanner.getConvert(ConverterScanner.java:147)
    at org.simpleframework.xml.convert.ConverterScanner.getConvert(ConverterScanner.java:121)
    at org.simpleframework.xml.convert.ConverterScanner.getConverter(ConverterScanner.java:100)
    at org.simpleframework.xml.convert.AnnotationStrategy.write(AnnotationStrategy.java:175)
    at org.simpleframework.xml.convert.AnnotationStrategy.write(AnnotationStrategy.java:155)
    at org.simpleframework.xml.core.Source.setOverride(Source.java:394)
    at org.simpleframework.xml.core.Factory.setOverride(Factory.java:170)
    at org.simpleframework.xml.core.Composite.isOverridden(Composite.java:1387)
    at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1309)
    at org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1194)
    at org.simpleframework.xml.core.Composite.writeElements(Composite.java:1165)
    at org.simpleframework.xml.core.Composite.writeSection(Composite.java:1071)
    at org.simpleframework.xml.core.Composite.write(Composite.java:1042)
    at org.simpleframework.xml.core.Composite.write(Composite.java:1019)
    at org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
    at org.simpleframework.xml.core.CompositeList.write(CompositeList.java:248)
    at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1331)
    at org.simpleframework.xml.core.Composite.writeElement(Composite.java:1314)
    at org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1194)
    at org.simpleframework.xml.core.Composite.writeElements(Composite.java:1165)
    at org.simpleframework.xml.core.Composite.writeSection(Composite.java:1071)
    at org.simpleframework.xml.core.Composite.write(Composite.java:1042)
    at org.simpleframework.xml.core.Composite.write(Composite.java:1019)
    at org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
    at org.simpleframework.xml.core.Traverser.write(Traverser.java:208)
    at org.simpleframework.xml.core.Traverser.write(Traverser.java:186)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1187)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1169)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1147)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1266)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1248)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1229)
    at org.simpleframework.xml.core.Persister.write(Persister.java:1208)
    at main.IO.FileHandler.WriteXML(FileHandler.java:32)
    at main.UI.MainUI.formWindowClosing(MainUI.java:108)
    at main.UI.MainUI.access$000(MainUI.java:16)
    at main.UI.MainUI$1.windowClosing(MainUI.java:76)
    at java.awt.Window.processWindowEvent(Window.java:2045)
    at javax.swing.JFrame.processWindowEvent(JFrame.java:296)
    at java.awt.Window.processEvent(Window.java:2003)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Window.dispatchEventImpl(Window.java:2713)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

I was able to get this program to work before, with the only problem being that it would turn empty strings to null, which is something I need to avoid. I can’t figure out what’s causing the problem or how to fix it. Is it because the converter class I got from the question I linked is for strings, not ArrayLists, or does it not matter because the XML nodes are strings and not lists anyway? I’m having trouble understanding what annotation it wants when it says “Element annotation required for field”.

  • 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-05-29T05:28:22+00:00Added an answer on May 29, 2026 at 5:28 am

    The error message was being thrown because I was using @ElementList, and this process requires @Element. I found a way to make it work with ArrayLists because I gave up on trying to make it work in one instance and just wanted the converter to apply to EVERYTHING. I don’t know if it’s a good approach but it works. I just followed the steps described here to create a RegistryStrategy, and instead of binding the converter to my class (which it wouldn’t accept), I bound it to String.class; in other words, the serialization process doesn’t care about if it’s stored in a complex class, ArrayList, ect, if it is a String then it is going to be set to “” if it’s read in as null.

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

Sidebar

Related Questions

I have a resource dictionary in my WPF application which contains the style information
I have a ComponentResourceKey defined in my resource dictionary like this: <Style x:Key={ComponentResourceKey TypeInTargetAssembly={x:Type
I have a dictionary of 200,000 items (the keys are strings and the values
I have a dictionary where keys are strings, and values are integers. stats =
I have the following style defined in the ResourceDictionary of a Silverlight 4.0 application
I want to read simple excel xml file to dictionary. I have tried to
I have been struggling to get a simple DynamicObject example working in .NET 3.5.
I have developed a WPF application. I have a one resource dictionary file in
Does VBA have dictionary structure? Like key<>value array?
I have a Dictionary<string, someobject> . EDIT: It was pointed out to me, that

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.