Regarding plugin

29 views
Skip to first unread message

Irfan Sayed

unread,
Aug 15, 2015, 2:03:42 PM8/15/15
to jenkin...@googlegroups.com
Hi,

I am developing one custom plugin which triggers the build based on some condition.
i just looked at the code which you have written as a reference and got some doubts. 
just wanted to have your suggestion on that 

in the FilesFoundTriggerConfig class, i have found this :

@Override
public Descriptor<FilesFoundTriggerConfig> getDescriptor() {
return getClassDescriptor();
}
 when i used the getClassDescriptor , i am not able to resolve the same in eclipse
i am developing this plugin against Jenkins version 1.580.1
i have already imported all the Jenkins packages but still not able to resolve
further, if i just return null , will it work ? is there any specific reason to return getClassDescriptor
can you please help me in some pointers ?

Regards,
Irfan

Oleg Nenashev

unread,
Aug 16, 2015, 5:44:46 AM8/16/15
to Jenkins Developers
if i just return null , will it work ?

No. A descriptor instance should be returned. Old implementation is: 

@Override
    public XX getDescriptor() {
        final Jenkins jenkins = Jenkins.getInstance();
                  if (jenkins == null) {
                     throw new IllegalStateException("Jenkins is not ready or has been already shut down"); 
                 }
        return (XXX) jenkins.getDescriptorOrDie(getClass());
    }

 


суббота, 15 августа 2015 г., 21:03:42 UTC+3 пользователь Irfan Sayed написал:

Irfan Sayed

unread,
Aug 17, 2015, 12:41:42 AM8/17/15
to jenkin...@googlegroups.com
thanks.
it worked and moved ahead however, now it is failing while submitting the job config  please refer below the stack trace 

javax.servlet.ServletException: java.lang.InstantiationError: Unrecognized constructor parameter: class org.jenkinsci.plugins.deployment.DeploymentTrigger
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:795)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:875)
	at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:249)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:745)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:875)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:237)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:96)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:88)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:46)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:285)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:628)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
Caused by: java.lang.InstantiationError: Unrecognized constructor parameter: class org.jenkinsci.plugins.deployment.DeploymentTrigger
	at hudson.util.XStream2$AssociatedConverterImpl.findConverter(XStream2.java:326)
	at hudson.util.XStream2$AssociatedConverterImpl.canConvert(XStream2.java:354)
in the code, @DataBoundConstructor is already annotated for main public class still class is not able initialize somehow
please help me with some pointers. Thanks 


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/15a6beb7-97f3-4183-9a2d-ec0900f17186%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Sandell

unread,
Aug 17, 2015, 5:34:52 AM8/17/15
to jenkin...@googlegroups.com
If your constructor takes a custom object as a parameter the class of that parameter also needs a @DataBoundConstructor annotation.

/B


For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Irfan Sayed

unread,
Aug 17, 2015, 6:23:15 AM8/17/15
to jenkin...@googlegroups.com
thanks.
yes. i do have the @DataBoundConstructor annotation declared for the class where i have declared the custom parameters. there is no any other class where i have used these parameters. there is only single class, still it is throwing exception 

here it is :
@DataBoundConstructor
  public DeploymentTrigger(String spec, List<DeploymentTriggerConfig> configs) throws ANTLRException
  {
    super(spec);
    ArrayList<DeploymentTriggerConfig> configsCopy = new ArrayList<DeploymentTriggerConfig>(fixNull(configs));

    DeploymentTriggerConfig firstConfig;
    if (configsCopy.isEmpty())
    {
      firstConfig = new DeploymentTriggerConfig(null);
    }
    else
    {
      firstConfig = configsCopy.remove(0);
    }
    this.node = firstConfig.getNode();
    if (configsCopy.isEmpty())
    {
      configsCopy = null;
    }
    this.additionalConfigs = configsCopy;

  }

please suggest 

Regards,
Irfan





Irfan Sayed

unread,
Aug 17, 2015, 8:22:05 AM8/17/15
to jenkin...@googlegroups.com
gone through the docs: http://stapler.kohsuke.org/apidocs/org/kohsuke/stapler/DataBoundConstructor.html
found that, stapler will bind the field name by matching the constructor parameter name. 
in my code, i have declared the parameters in the constructor and bind them with this annotation. 
still not found where is the gap...

can someone please review the code?
 

Irfan Sayed

unread,
Aug 17, 2015, 8:36:37 AM8/17/15
to jenkin...@googlegroups.com
here is the repo: https://github.com/irfanjs/deployment

please suggest 

Irfan Sayed

unread,
Aug 17, 2015, 1:11:56 PM8/17/15
to jenkin...@googlegroups.com
please suggest.

Regards
Irfan

Irfan Sayed

unread,
Aug 19, 2015, 11:36:35 PM8/19/15
to jenkin...@googlegroups.com
this is fixed!!!
it was failing due to non having data binding to all parameters defined in the constructor 
now it is working as expected....
thanks to all for support

Regards
irfan
 
Reply all
Reply to author
Forward
0 new messages