Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
Null Pointer Exception during init method of groovy scripts
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message
Jonathan

Joined: 11 Aug 2008
Posts: 799

View user's profile

Back to top
Link to postPosted: Wed Oct 31, 2012 12:44 amPost subject: Null Pointer Exception during init method of groovy scripts Reply with quote

I've been getting NPEs on code during init calls fo groovy button scripts.

...

init = { widget ->  //line 34

    def rs = widget.form.resultSet  //line35

    def dataTree = rs.dataTree  //line 36

...

When I open the form, I get an NPE.  

java.lang.NullPointerException: Cannot get property 'resultSet' on null object

at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)

at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:156)

at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)

at script1351639868222387238318$_run_closure1.doCall(script1351639868222387238318.groovy:35)

 

Of course, this kills the rest of the operation (i.e. evaluate method) of the button.  Is there a race condition where the initialization of the button occurs before the form is initialized?  What should I do about it?

 

Jon

fzimandl

Joined: 23 Jun 2011
Posts: 434

View user's profile

Back to top
Link to postPosted: Wed Oct 31, 2012 11:26 amPost subject: Reply with quote

Hi Jon

Yes, the widget is created before the form is initialized. This does not affect evaluate method in my simple button script. It just did not continue with the init method...but still runs a code in evaluate section when clicking to button.

We are fixing this for 5.12 (maybe 5.11.4 depending on how the fix is going to look like).

I assume that you want to run a script right after the form is initialized. There is probably no workaround for this.

Thanks for letting us know.

Filip

fzimandl

Joined: 23 Jun 2011
Posts: 434

View user's profile

Back to top
Link to postPosted: Tue Nov 13, 2012 5:59 pmPost subject: Reply with quote

This is fixed in IJC 5.11.4 which is going out pretty soon.

Cheers!
Filip 

Jonathan

Joined: 11 Aug 2008
Posts: 799

View user's profile

Back to top
Link to postPosted: Wed Nov 14, 2012 2:38 amPost subject: Reply with quote

Thanks Filip.  So, how will it work in the new release?  Is the button's init method called after the initialization of the form.  I'll try it out when it is released.  

Is the init method called every time you open a form, or just the first time?  Is the destroy method called every time you close a form, or just the first time?

When using the destroy method are there limitations (such as missing resources like result sets or data trees)?  

(My apologies if it is already in the documentation, but I couldn't find it).

Jon

Martin
ChemAxon personnel
Joined: 24 May 2010
Posts: 35

View user's profile

Back to top
Link to postPosted: Wed Nov 14, 2012 4:32 pmPost subject: Reply with quote

Hi Jon,

It turned out destroy method is not called at all. It was fixed in development version just now and will work correctly in the IJC 5.11.4 as well.

The intended semantics are:

  • init method is called everytime the form is opened.
  • destroy method is called each time the form is closed.

In both cases resources, like result set, are ready and can be used at the time of method call.

We will ensure it is properly documented on the website.

Thanks for the feedback.
- Martin

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1


To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum