hudson.Plugin's save()/load() not working, because it does not receive a PluginWrapper

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

hudson.Plugin's save()/load() not working, because it does not receive a PluginWrapper

Alexis Gallagher-2
Hi,

I am building a plugin which extends from hudson.Plugin, an abstract class which provides an implementation of save() and load().

However, on startup, the plugin generates NullPointerException's whenever load() is called. On investigation, it turns out this is because my plugin's PluginWrapper is never initialized. 

Is this some sort of a bug in hudson.Plugin? (The only reason I think this is possible, is that I can't find another plugin that extends from hudson.Plugin and uses load()/save().) I cannot find anything in the javadoc which indicates that I should be manually wrapping my plugin in a PluginWrapper, or telling me when I should do that, and other plugins do not seem to handle this on their own.

Or is this it the case that extending hudson.Plugin is the wrong way to build a plugin? In its javadoc ( http://javadoc.jenkins-ci.org/hudson/Plugin.html ), the class says "A plugin needs to derive from this class", which is where I got the idea to do this. But perhaps this is out of date?

Alexis


 p.s. the plugin is here: https://github.com/algal/cors

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: hudson.Plugin's save()/load() not working, because it does not receive a PluginWrapper

stephenconnolly
You don't call load() or save() from the constructor. For one thing, doing that kind of thing from a constructor is a bad plan anyways, but also, as you found, the plugin wrapper has not been instantiated until after the Plugin instance is fully constructed.

The correct place to call those methods is in your overridden start() method


On 23 April 2013 14:50, Alexis Gallagher <[hidden email]> wrote:
Hi,

I am building a plugin which extends from hudson.Plugin, an abstract class which provides an implementation of save() and load().

However, on startup, the plugin generates NullPointerException's whenever load() is called. On investigation, it turns out this is because my plugin's PluginWrapper is never initialized. 

Is this some sort of a bug in hudson.Plugin? (The only reason I think this is possible, is that I can't find another plugin that extends from hudson.Plugin and uses load()/save().) I cannot find anything in the javadoc which indicates that I should be manually wrapping my plugin in a PluginWrapper, or telling me when I should do that, and other plugins do not seem to handle this on their own.

Or is this it the case that extending hudson.Plugin is the wrong way to build a plugin? In its javadoc ( http://javadoc.jenkins-ci.org/hudson/Plugin.html ), the class says "A plugin needs to derive from this class", which is where I got the idea to do this. But perhaps this is out of date?

Alexis


 p.s. the plugin is here: https://github.com/algal/cors

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: hudson.Plugin's save()/load() not working, because it does not receive a PluginWrapper

Alexis Gallagher-2
Hi,

Thanks for this pointer. Very helpful.

I was using the HSTS plugin as a template ( https://wiki.jenkins-ci.org/display/JENKINS/HSTS+Filter+Plugin ), but I since that one is extending PageDecorator rather than Plugin, I suppose it is supposed to integrate with Jenkins differently.

A


On Tuesday, April 23, 2013 3:17:43 PM UTC+1, Stephen Connolly wrote:
You don't call load() or save() from the constructor. For one thing, doing that kind of thing from a constructor is a bad plan anyways, but also, as you found, the plugin wrapper has not been instantiated until after the Plugin instance is fully constructed.

The correct place to call those methods is in your overridden start() method


On 23 April 2013 14:50, Alexis Gallagher <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="LicZzxIigb8J">alexisg...@...> wrote:
Hi,

I am building a plugin which extends from hudson.Plugin, an abstract class which provides an implementation of save() and load().

However, on startup, the plugin generates NullPointerException's whenever load() is called. On investigation, it turns out this is because my plugin's PluginWrapper is never initialized. 

Is this some sort of a bug in hudson.Plugin? (The only reason I think this is possible, is that I can't find another plugin that extends from hudson.Plugin and uses load()/save().) I cannot find anything in the javadoc which indicates that I should be manually wrapping my plugin in a PluginWrapper, or telling me when I should do that, and other plugins do not seem to handle this on their own.

Or is this it the case that extending hudson.Plugin is the wrong way to build a plugin? In its javadoc ( http://javadoc.jenkins-ci.org/hudson/Plugin.html ), the class says "A plugin needs to derive from this class", which is where I got the idea to do this. But perhaps this is out of date?

Alexis


 p.s. the plugin is here: https://github.com/algal/cors

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="LicZzxIigb8J">jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: hudson.Plugin's save()/load() not working, because it does not receive a PluginWrapper

stephenconnolly
Plugin is special as that one, if an extension point in a plugin, is referenced by the PluginWrapper, all the other extension points are after that point in the startup lifecycle


On 24 April 2013 09:22, Alexis Gallagher <[hidden email]> wrote:
Hi,

Thanks for this pointer. Very helpful.

I was using the HSTS plugin as a template ( https://wiki.jenkins-ci.org/display/JENKINS/HSTS+Filter+Plugin ), but I since that one is extending PageDecorator rather than Plugin, I suppose it is supposed to integrate with Jenkins differently.

A


On Tuesday, April 23, 2013 3:17:43 PM UTC+1, Stephen Connolly wrote:
You don't call load() or save() from the constructor. For one thing, doing that kind of thing from a constructor is a bad plan anyways, but also, as you found, the plugin wrapper has not been instantiated until after the Plugin instance is fully constructed.

The correct place to call those methods is in your overridden start() method


On 23 April 2013 14:50, Alexis Gallagher <[hidden email]> wrote:
Hi,

I am building a plugin which extends from hudson.Plugin, an abstract class which provides an implementation of save() and load().

However, on startup, the plugin generates NullPointerException's whenever load() is called. On investigation, it turns out this is because my plugin's PluginWrapper is never initialized. 

Is this some sort of a bug in hudson.Plugin? (The only reason I think this is possible, is that I can't find another plugin that extends from hudson.Plugin and uses load()/save().) I cannot find anything in the javadoc which indicates that I should be manually wrapping my plugin in a PluginWrapper, or telling me when I should do that, and other plugins do not seem to handle this on their own.

Or is this it the case that extending hudson.Plugin is the wrong way to build a plugin? In its javadoc ( http://javadoc.jenkins-ci.org/hudson/Plugin.html ), the class says "A plugin needs to derive from this class", which is where I got the idea to do this. But perhaps this is out of date?

Alexis


 p.s. the plugin is here: https://github.com/algal/cors

--
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.

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

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.