Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

DataBoundConstructor error #94

Open
jdamick opened this issue Oct 11, 2013 · 1 comment
Open

DataBoundConstructor error #94

jdamick opened this issue Oct 11, 2013 · 1 comment

Comments

@jdamick
Copy link
Member

jdamick commented Oct 11, 2013

I'm trying to extend the parameterizedtrigger plugin and i'm running the the following error (below), i have my annotation set for DataBoundConstructor but something must not be set right.. Any ideas would be appreciated. thanks

Caused by: java.lang.IllegalArgumentException: Failed to convert the configs parameter of the constructor public hudson.plugins.parameterizedtrigger.BuildTriggerConfig(java.lang.String,hudson.plugins.parameterizedtrigger.ResultCondition,boolean,java.util.List)
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:590)
    ... 61 more
Caused by: java.lang.IllegalArgumentException: Failed to instantiate class hudson.plugins.parameterizedtrigger.AbstractBuildParameters from {"stapler-class":"hudson.plugins.parameterizedtrigger.AbstractBuildParameters","kind":"BakeryIngredientsBuilder-IngredientsBuildParameters"}
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:596)
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:632)
    at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:391)
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:588)
    ... 61 more
Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class hudson.plugins.parameterizedtrigger.AbstractBuildParameters
    at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:176)
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:575)
    ... 64 more

My code is this:

include Java
java_import Java.hudson.plugins.parameterizedtrigger.AbstractBuildParameters
java_import Java.org.kohsuke.stapler.DataBoundConstructor;

class IngredientsBuildParameters < AbstractBuildParameters
  include Jenkins::Model
  include Jenkins::Model::Describable

  display_name "Bakery Ingredients Parameters"
  describe_as Java.hudson.plugins.parameterizedtrigger.AbstractBuildParameters

  java_annotation "DataBoundConstructor"
  def initialize(attrs={})

  end

  #public abstract Action getAction(AbstractBuild<?,?> build, TaskListener listener)
  #            throws IOException, InterruptedException, DontTriggerException;
  def getAction(build, listener)
  end
end
@kohsuke
Copy link
Member

kohsuke commented Oct 11, 2013

I had the conversation with @jdamick and he seems to think that injecting a Hash would be OK given that the constructor injection is hard with JRuby.

In the mean time, the work around is to override Descriptor.newInstance() but not sure how that translates to the Ruby runtime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants