frohoff/ysoserial · error · IllegalArgumentException

Invalid payload type

Error message

Invalid payload type '${payloadType}'

What it means

ObjectPayload.makePayloadObject() looks up the payload class by name via getPayloadClass(); if no class is registered under that name, or the class isn't an ObjectPayload subtype, it throws IllegalArgumentException naming the bad payload type. This is the entry-point validation for all ysoserial payload generation.

Solutions

  1. Run 'java -jar ysoserial.jar' with no args to list valid payload names and copy one exactly
  2. Check case-sensitivity — payload names are like 'C3P0', 'CommonsCollections1'
  3. Swap the arguments if payload type and command were reversed

Example fix

// before
ObjectPayload.makePayloadObject("c3p0", cmd);
// after
ObjectPayload.makePayloadObject("C3P0", cmd);
Defensive patterns

Strategy: validation

Validate before calling

if (ObjectPayload.Utils.getPayloadClass(name) == null) throw new IllegalArgumentException("unknown payload: " + name);

Try / catch

try { obj = ObjectPayload.makePayloadObject(type, arg); } catch (IllegalArgumentException e) { listPayloads(); }

Prevention

When it happens

Trigger: Calling ObjectPayload.makePayloadObject(payloadType, payloadArg) or the GeneratePayload CLI with a payloadType string that doesn't match a registered payload class (case-sensitive) or isn't an ObjectPayload.

Common situations: Typos or wrong case in payload names ('c3p0' vs 'C3P0'); listing payloads from a different ysoserial version than the one run; passing a payload argument in the payloadType slot.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of frohoff/ysoserial@218bcffcaa (2026-09-12). Data as JSON: /api/errors/dc3426977423cd79. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/ysoserial/payloads/ObjectPayload.java:62

            catch ( Exception e1 ) {}
            if ( clazz == null ) {
                try {
                    return clazz = (Class<? extends ObjectPayload>) Class
                            .forName(GeneratePayload.class.getPackage().getName() + ".payloads." + className);
                }
                catch ( Exception e2 ) {}
            }
            if ( clazz != null && !ObjectPayload.class.isAssignableFrom(clazz) ) {
                clazz = null;
            }
            return clazz;
        }


        public static Object makePayloadObject ( String payloadType, String payloadArg ) {
            final Class<? extends ObjectPayload> payloadClass = getPayloadClass(payloadType);
            if ( payloadClass == null || !ObjectPayload.class.isAssignableFrom(payloadClass) ) {
                throw new IllegalArgumentException("Invalid payload type '" + payloadType + "'");

            }

            final Object payloadObject;
            try {
                final ObjectPayload payload = payloadClass.newInstance();
                payloadObject = payload.getObject(payloadArg);
            }
            catch ( Exception e ) {
                throw new IllegalArgumentException("Failed to construct payload", e);
            }
            return payloadObject;
        }


        @SuppressWarnings ( "unchecked" )
        public static void releasePayload ( ObjectPayload payload, Object object ) throws Exception {
            if ( payload instanceof ReleaseableObjectPayload ) {

View on GitHub (pinned to 218bcffcaa)