Menu

Logging Groovy Debug Output (or access to Groovy Console)

2016-04-05
2016-04-26
  • Mike Petonic

    Mike Petonic - 2016-04-05

    Hi --

    I tried to get the GroovyConsole working (wikdShell 0.2.0) at https://bitbucket.org/lcrees/wikdshell/ ... 1.addon.mm https://bitbucket.org/lcrees/wikdshell/downloads/wikdShell-0.2.1.addon.mm to work, but I kept on getting an error when trying to bring up the console. The error says:
    Error executing the script
    /Users/.../.freeplane/1.3.x/addons/wikdShell/scripts/wikdShell.groovy:5:unable to resolve class org.hardknots.wikd.wikdshell.WikdShell
    @ line 5, column 1.

    import org.hardknots.wikd.wikdshell.WikdShell
    ^
    

    Has anyone gotten this to work? All I did was install the Add-on, which added some keyboard shortcuts as well. I would assume that it would just work, right?

    Any help would be greatly appreciated. I’ve been working on a set of scripts to export a node-tree into Markdown into either an ASCII readable hierarchical outline or an RTF hierarchical outline. Almost done, and it looks pretty. I’ll share with the group as soon as I’m done.

    Thanks!

     
    • zipizap

      zipizap - 2016-04-05

      Not a clue about the error, but just came to show support for that future
      addon

       
  • Alexandre

    Alexandre - 2016-04-05

    Hi Mike,

    Maybe this could be useful for debugging groovy code, I am using this function:

    def d(message) {
        BufferedWriter bw = new BufferedWriter(new FileWriter("c:/temp/debug.txt", true));
        bw.write(message);
        bw.newLine();
        bw.flush();
        bw.close();
    }
    

    So just change the path to the file if needed, and put debug message like

    d('allo')
    d('here')
    etc...

    The messages will be appended to the file, then you may manually clear the file as needed.

    Hope it can be useful.

    Best regards,

    Alexandre

     

    Last edit: Alexandre 2016-04-05
    • Mike Petonic

      Mike Petonic - 2016-04-05

      Hi Alexandre. Thanks for this! Yes, it will be helpful, I'm guessing. I'd love the full console, but I can't underestimate the power of a simple printf() sparkled through the code :-) Thanks for your tip!

       

      Last edit: Mike Petonic 2016-04-05
  • Mike Petonic

    Mike Petonic - 2016-04-05

    I'm trying to fix it by myself while I wait for guidance. I found the .jar file wikdshell.jar and pit it in my ~//.freeplane/1.3.x/lib directory. Fired up FP again, and got a different error. Must've found the jar file, but this error is intriguing...

    An error occured during the script execution: reset of script classpath is forbidden.
    

    So then I went into FP=->Prefs->Plugins and blanked out my previous entry (I had "scripts" plugged in based on something else that I read).

    I still get that same error. :-(

     
  • Volker Börchers

    Mike please upload the relevant portion of the logfile containing the error and the scripting related startup messages.

    Volker

     
  • Mike Petonic

    Mike Petonic - 2016-04-05

    Here it is, Volker...

    I can get you earlier text in the log, but essentially, this is the new stuff that appeared after I selected "Groovy Console" from the menu.

    Thanks!

    Apr 05, 2016 4:10:14 PM org.freeplane.core.util.LogUtils warn
    WARNING: ExecuteScriptAction failed:
    java.lang.SecurityException: reset of script classpath is forbidden.
        at org.freeplane.plugin.script.ScriptResources.setClasspath(ScriptResources.java:54)
        at org.freeplane.plugin.script.ScriptingConfiguration.<init>(ScriptingConfiguration.java:128)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
        at org.hardknots.wikd.wikdshell.WikdShell.newScript(WikdShell.groovy:102)
        at org.hardknots.wikd.wikdshell.WikdShell$newScript.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
        at groovy.ui.Console.<init>(Console.groovy:217)
        at groovy.ui.Console.<init>(Console.groovy:209)
        at org.hardknots.wikd.wikdshell.WikdShell.<init>(WikdShell.groovy)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
        at wikdShell.run(wikdShell.groovy:7)
        at org.freeplane.plugin.script.GroovyScript.execute(GroovyScript.java:134)
        at org.freeplane.plugin.script.ExecuteScriptAction.actionPerformed(ExecuteScriptAction.java:90)
        at org.freeplane.core.ui.AccelerateableAction.actionPerformed(AccelerateableAction.java:177)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
        at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:125)
        at java.awt.MenuItem.processActionEvent(MenuItem.java:669)
        at java.awt.MenuItem.processEvent(MenuItem.java:628)
        at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
        at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    
    Apr 05, 2016 4:10:14 PM org.freeplane.core.util.LogUtils warn
    WARNING: error executing script /Users/petonic/.freeplane/1.3.x/addons/wikdShell/scripts/wikdShell.groovy - giving up
    java.lang.SecurityException: reset of script classpath is forbidden.
    Apr 05, 2016 4:10:14 PM org.freeplane.core.util.LogUtils warn
    WARNING: An error occured during the script execution: reset of script classpath is forbidden.
    ~/.freeplane/.../logs$
    
     
  • Dimitry Polivaev

    Hello Mike,

    thank you for the log.

    The problem you report arises from my current work on Freeplane security. It is work in progress and it was started in version 1.5.7_06. So I recommend that you use the earlier versions until I finish this part. Later it may be necessary to adjust some scripts according to the changes, but now it is too early to do so.

    Regards,
    Dimitry

     
  • zipizap

    zipizap - 2016-04-13

    Also felt this, after upgrade to 1.5.8 beta (git revision... 2016-04-10 22:32:27 +0200), with a couple of daily personal scripts

     
  • Dimitry Polivaev

    Version 1.5.8 beta has new restrictive implementation of scripting security. It is likely that some scripts fail to run because they do not have the permissions they need. In order to evaluate which permissions are required I need your bug reports with log files and failure messages for each case of missing permission like in Bug Report https://sourceforge.net/p/freeplane/bugs/2344/

    Regards,
    Dimitry

     
    • zipizap

      zipizap - 2016-04-13

      Ok, will reply when back to pc

       
    • Mike Petonic

      Mike Petonic - 2016-04-13

      I've logged my bug report with my original logfile. Thanks for all of
      your hard work!

      -Mike

      On 13 Apr 2016, at 3:58, Dimitry Polivaev wrote:

      Version 1.5.8 beta has new restrictive implementation of scripting
      security. It is likely that some scripts fail to run because they do
      not have the permissions they need. In order to evaluate which
      permissions are required I need your bug reports with log files and
      failure messages for each case of missing permission like in Bug
      Report https://sourceforge.net/p/freeplane/bugs/2344/

      Regards,
      Dimitry


      Logging Groovy Debug Output (or access to Groovy
      Console)


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/freeplane/discussion/758437/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Dimitry Polivaev

    Volker is going to try to modify wikdShell add-on so that it can work with Freeplane 1.5.x .
    Its current version can not be used.

     
  • Mike Petonic

    Mike Petonic - 2016-04-16

    Beautiful! Thank you. Getting this feature working again will be very helpful to me. I want to modify Freeplane, but I'm not so good at Groovy so any debug support is greatly appreciated. Good luck to Volker!

     
  • Volker Börchers

     

    Last edit: Volker Börchers 2016-04-24
  • Mike Petonic

    Mike Petonic - 2016-04-26

    Awesome. I'll check it out and see I can't be more productive with Groovy now. Thanks, Volker and Dimitry!