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

  • Home
  • SEARCH
  • 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 962527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:31:16+00:00 2026-05-16T01:31:16+00:00

I’m currently trying to consume a list of strings from some XML using Apache

  • 0

I’m currently trying to consume a list of strings from some XML using Apache Digester, as described in the How do I add literal elements to a List object? section of the FAQ.

I’m hitting the following error:

[DEBUG] Digester - [SetNextRule]{job/editorial/articlegroup/article} Call java.util.ArrayList.setFields([This, This, is, is, a, a, test, test, , , , ])
[ERROR] Digester - End event threw exception <java.lang.NoSuchMethodException: No such accessible method: setFields() on object: java.util.ArrayList>java.lang.NoSuchMethodException: No such accessible method: setFields() on object: java.util.ArrayList

A simplified version of the XML I am using is as follows:

<job>
    <editorial>
        <articlegroup>
            <article>
                <text>
                    <content><![CDATA[This]]></content>
                </text>
                <text>
                    <content><![CDATA[is]]></content>
                </text>
                <text>
                    <content><![CDATA[a]]></content>
                </text>
                <text>
                    <content><![CDATA[test]]></content>
                </text>
            </article>
        </articlegroup>
    </editorial>
</job>

And the source code:

public class PPJob {

    List<String> fields;

    public List<String> getFields() {
        return fields;
    }
    public void setFields(List<String> fields) {
        this.fields = fields;
    }
}


addObjectCreate("job", PPJob.class);
addSetProperties("job");

addObjectCreate("job/editorial/articlegroup/article", ArrayList.class);
addCallMethod("job/editorial/articlegroup/article/text/content", "add", 1);
addCallParam("job/editorial/articlegroup/article/text/content", 0);
addSetNext("job/editorial/articlegroup/article", "setFields");

PPJob result = (PPJob)super.parse([THE XML]);

I’m pretty much a novice at using the Digester, and I’m having a hard time tracking down examples for what I need.

Can anyone see where I’m going wrong?

  • 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-16T01:31:17+00:00Added an answer on May 16, 2026 at 1:31 am

    Well, this question earned me the “Tumbleweed” badge, and I’m struggling to find some way to re-word the problem so it is easier to comprehend. So here’s an update on my progress:

    I decided to abandon the Commons Digester in the end, time constraints made it difficult to chase up the issue up further and as a result I haven’t logged a bug to the Digester project (if someone else does let me know and I’ll share my experience).

    The javax XPath functions proved more straightforward for achieving my requirement, I resolved to this solution:

    XPathFactory factory = XPathFactory.newInstance();
    XPath xPath = factory.newXPath();
    rootQuery = xPath.compile("/job");
    textFieldsQuery = xPath.compile("/job/editorial/articlegroup/article/text|/job/editorial/articlegroup/article/flashtext");
    
    Node rootNode = (Node)rootQuery.evaluate(new InputSource(is), XPathConstants.NODE);
    
    PPJob job = new PPJob();
    Map<String, String> jobTextFields = new HashMap<String, String>(); 
    NodeList fields = (NodeList)query.evaluate(rootNode, XPathConstants.NODESET);
    for (int i = 0; i < fields.getLength(); i++) {
        Node field = fields.item(i);
        String fieldName = field.getAttributes().getNamedItem("name").getNodeValue();
        String fieldContent = field.getNextSibling().getNodeValue();
        jobTextFields.put(fieldName, fieldContent);
    }       
    job.setTextFields(jobTextFields);
    

    If anyone has a suggestion for this problem I’m still interested to hear why I had so much trouble with the Digester.

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

Sidebar

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.