0

I'm trying to call a constructor in a groovy file. I've a constructor like

public class CreditCardDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements creditcard.CreditCardDocument
{
    // Constructor
    public CreditCardDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {  
        super(sType);
    }
}

When I try to access the constructor by calling ,

// Call the constructor
CreditCardDocument creditCardDocument = new CreditCardDocumentImpl(SchemaType);

It doesn't allow me

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: creditcard.impl.CreditCardDocumentImpl(java.lang.Class)

Any ideas would be greatly appreciated.

1 Answer 1

1

You should pass an instance of SchemaType, not the class itself.

CreditCardDocument creditCardDocument = new CreditCardDocumentImpl(new SchemaType());
Sign up to request clarification or add additional context in comments.

5 Comments

We cannot pass an instance like that. :(
The point is you have to pass an instance, or null. The groovy exception is saying you are passing a class object.
Can you help me what exactly I need to pass? I have tried to pass sType(null object of SchemaType), whereas SchemaType is an interface. Fighting with this since yesterday.
It depends on which schema you trying to use.if you have a XmlObject of this schema , you many try xmlObject.schemaType() to get the instance of the SchemaType. or XmlObject.type for anytype.
It is of org.apache.xmlbeans.SchemaType

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.