1 year ago

#304595

test-img

Rob

Getting a NoSuchMethodError on a Xstream.addPermission()

I'm trying to debug a issue I'm having on an application, we have a function to store a user's search criteria and the function used to work but recently we've been getting a NoSuchMethod Error whenever a user attempts to retrieve their saved search criteria. I've tried prowling through some other Xstream errors but the closest I found was an issue a couple of years back from the .alias method. I'm getting the error when attempting to use the .addPermission() method. I've attached one of the other methods that we use to "getXstream".


java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.addPermission(Lcom/thoughtworks/xstream/security/TypePermission;)V
    at com.u90785.aim.persistence.brokers.SavedSearchBroker.ParseXML(SavedSearchBroker.java:986)
    at com.u90785.aim.persistence.brokers.SavedSearchBroker.populateSearchCriteriaFromXML(SavedSearchBroker.java:840)
    at com.u90785.aim.persistence.brokers.SavedSearchBroker.RetrieveSavedSearchCriteria(SavedSearchBroker.java:384)
    at com.u90785.aim.persistence.brokers.SavedSearchBroker.RetrieveSavedSearchCriteria(SavedSearchBroker.java:330)
    at com.u90785.aim.domain.SavedSearchCriteria.GetSavedSearch(SavedSearchCriteria.java:56)

    protected static FindSearchCriteria ParseXML(String xml, XStream xstream, User user)
    {
        if (xml == null || xml.trim().length() == 0 || !xml.trim().startsWith("<")) return null;
        if (xstream == null) {
            xstream = GetXStream();
            xstream.addPermission(NoTypePermission.NONE);
            xstream.addPermission(NullPermission.NULL);
            xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        }


    private static XStream GetXStream()
    {
        XStream xstream = new XStream();
        //These converters used so that cached counties, states, and countries are used instead of 
        //creating new instances
        //If additional "cached" objects are added to the domain, converters should be created for 
        //them.
        xstream.registerConverter(new CountyConverter());
        xstream.registerConverter(new StateProvinceConverter());
        xstream.registerConverter(new CountryConverter());
        xstream.registerConverter(new DateConverter());
        xstream.registerConverter(new CategoryConverter());
        xstream.registerConverter(new SegmentConverter());
        xstream.registerConverter(new SubSegmentConverter());
        xstream.registerConverter(new AffiliationConverter());

        return xstream;
    }

I'm kind of stumped since this issue just cropped up relatively recently and we haven't touched this part of our application in a quite some time. From what I can tell we also haven't updated any of our dependencies recently either (Xstream is running 1.4.8 as far as I can tell). I've tried exploring the methods but I can't find anything that specifically sticks or is glaringly off. This application also predates my contributions so it's possible it's an unfamiliarity with parts of the code.

java

xstream

nosuchmethoderror

0 Answers

Your Answer

Accepted video resources