Getting multiple table schema and returning them, using one helper method
Generics

When you say, ArrayList&lt;ArrayList&lt;?&gt;&gt;, you are saying that there is a type but that you don't know what it is.  So you write it as a ?.  

But in your code, you are putting ArrayList&lt;Attribute&gt; and ArrayList&lt;Group&gt; into the larger list.  These are not one type.  So it has to find a type that covers both Attribute and Group.  Absent both extending or implementing some common class or interface, that will be Object.  So ? is actually Object in your code.  

It is natural to think that ? is a wildcard that can match multiple things simultaneously.  But it is not.  It represents exactly one type at a time.  You just avoid having to say which type.  As such, I don't think that it is what you want to use here.  

Cast by element not collection

The general way to fix this warning on something like 


    ArrayList&lt;Attribute&gt; listAttrs = (ArrayList&lt;Attribute&gt;) lists.get(ATTRIBUTES);



would be something like 

    List&lt;Attribute&gt; listAttrs = new ArrayList&lt;&gt;();
    for (Object attr : lists.get(ATTRIBUTES)) {
        if (attr instanceof Attribute) {
            listAttrs.add((Attribute) attr);
        }
    }


You can often leave off the instanceof check because you know what the result should be.  

I changed from the implementation (ArrayList) to the interface (List), as is customary in Java when you aren't using implementation specific methods unavailable to the interface.  

But I wouldn't recommend that code for this specific problem.  You don't really need to cast here.  You control the code at both ends and in between.  Just write it without casts.  

Custom return type

The most direct way to fix this specific problem is to replace your return value with a custom class.  

class AttributesAndGroups {

    private List&lt;Attribute&gt; attributes;

    private List&lt;Group&gt; groups;

    public void setAttributes(List&lt;Attribute&gt; attributes) {
        this.attributes = attributes;
    }

    public List&lt;Attribute&gt; getAttributes() {
        return attributes;
    }

    public void setGroups(List&lt;Group&gt; groups) {
        this.groups = groups;
    }

    public List&lt;Group&gt; getGroups() {
        return groups;
    }

}


You can use this like 

        AttributesAndGroups result = new AttributesAndGroups();
        result.setAttributes(listAttrs);
        result.setGroups(listGroups);
        return result;


and in the caller 

        AttributesAndGroups lists = getAttributesAndGroups();
        List&lt;Attribute&gt; listAttrs = lists.getAttributes();
        List&lt;Group&gt; listGroups = lists.getGroups();


No casts (unchecked or otherwise).  

There's a lot of boilerplate code in the class.  It's possible to avoid that here.  

Pass to the method

Another alternative would be to pass the lists into the helper method rather than have the method initialize them.  

        List&lt;Attribute&gt; listAttrs = new ArrayList&lt;&gt;();
        List&lt;Group&gt; listGroups = new ArrayList&lt;&gt;();
        fillAttributesAndGroups(listAttrs, listGroups);
        request.setAttribute("listAttrs", listAttrs);
        request.setAttribute("listGroups", listGroups);


I changed the name to be more representative of the revised implementation.  

And then the method signature would be 

private void fillAttributesAndGroups(List&lt;Attribute&gt; listAttrs, List&lt;Group&gt; listGroups) {


Now just delete 


    ArrayList&lt;ArrayList&lt;?&gt;&gt; retList = new ArrayList&lt;ArrayList&lt;?&gt;&gt;();
        ArrayList&lt;Attribute&gt; listAttrs = new ArrayList&lt;Attribute&gt;();
        retList.add(listAttrs);
        ArrayList&lt;Group&gt; listGroups = new ArrayList&lt;Group&gt;();
        retList.add(listGroups);
    return retList;



And the remainder of your code should function normally.  

Again, no casts needed.  And this code is much terser, particularly if this is the only time you call it.  

Another alternative would be to pass request into the method, but I won't try to implement that here.  That would allow you to make the lists inside the method again.