How to debug in Eclipse?

Any issue about Cyclos 4 scripting and Webservices

Moderators: hugo, alexandre, rmvanarkel

Post Reply
jakob.schumann
Posts: 5
Joined: Thu Apr 23, 2020 5:37 pm

How to debug in Eclipse?

Post by jakob.schumann »

Cyclos: 4.12.6
Eclipse: 2020-03, also tried 2019-12

Hello,

I'm trying to get the debugging of Cyclos scripts in Eclipse running and followed the steps in the README.html that is in the zip-file you receive when downloading a script from the frontend.
So I prepared everything: extracted libs, running a cyclos DB, Eclipse + Groovy install, new Groovy project with the script (IBAN validator from the samples), cyclos.properties file.

But I am unable to run the script: The readme states "The first execution will fail, indicating there are missing parameters". This is not possible in the current eclipse version / my setup, it requires me to specify a run configuration right from the start, so "on the Arguments tab, in the "Program arguments" box there should be a bunch of text already filled in" isn't the case. Nethertheless if I add those manually I still can't run the script because Eclipse requires me to specify a "Main Class": http://prntscr.com/s53g6u

It neither allows me to select a Main Class, nor is one auto-detected, nor can I continue without one. What is the correct way to run those scripts in a current Eclipse version?

Thanks in advance,
J.Schumann

admin_de2
Posts: 38
Joined: Wed Dec 31, 1969 9:00 pm

Re: How to debug in Eclipse?

Post by admin_de2 »

Any hint / information about this issue would be highly appreciated.
Is there anyone from the dev-team and/or other cyclos integrators having this problem (solved), please?

Thank you.

andres
Posts: 4
Joined: Fri Dec 16, 2011 9:31 am
Location: Montevideo, Uruguay

Re: How to debug in Eclipse?

Post by andres »

In Eclipse, please go to Window -> Preferences, then Groovy -> Compiler
and ensure the Groovy Compiler is 2.4.xx

In the Groovy project you created, go to Properties and:
In "Groovy Compiler" ensure the setting "Groovy compiler level for this project" is 2.4
In "Java Build Path" -> Libraries -> "Add External JARs" add the the jar with the servlet API
(this jar is not present in the WEB-INF/lib but you can include it from the tomcat installation <TOMCAT_HOME>/lib/servlet-api.jar)

This is something we'll fix in the upcoming 4.13

Best regards
Andrés Meyer
Cyclos development team

jakob.schumann
Posts: 5
Joined: Thu Apr 23, 2020 5:37 pm

Re: How to debug in Eclipse?

Post by jakob.schumann »

Thanks alot for this tipps,
unfortunately I still could not get it working.

Eclipse still does not allow me to use a run configuration without a main(), and the servlet_api.jar doesn't seem to provide one as I can see the JAR in the list of available external jars in the run configuration menu, but still can't select a Main Class.

So I will be waiting for the new version 4.13 to fix this.

Best regards,
JS

luis
Posts: 185
Joined: Fri Feb 17, 2006 11:01 am

Re: How to debug in Eclipse?

Post by luis »

If you follow the steps in the README, you actually won't see a place to select a main class.
Instead, you'll right click the RunScript.groovy and select Run As > Groovy Script.
The servlet-api JAR is really missing in the README. This will be fixed on 4.13. In the meantime, you can download it from Maven Repository at https://repo1.maven.org/maven2/javax/se ... -4.0.1.jar. Select it as well in Eclipse, in project properties > Java Build Path > Libraries > Add external library.
Just be aware that the way the Eclipse Groovy Plugin works, it stores the entire classpath in the run configuration. So, if you have ever ran the Groovy script and changed something in the build path, you will have to go to the Run > Run configurations, remove the configuration and run again by right clicking the script. Just copy the program arguments before, so you can paste it in the new configuration again.
Luis Fernando Planella Gonzalez
Cyclos development team

jakob.schumann
Posts: 5
Joined: Thu Apr 23, 2020 5:37 pm

Re: How to debug in Eclipse?

Post by jakob.schumann »

Hello Luis,

thanks for your help! This option (Run as > Groovy Script) was not available for the file. I then created a completely new project which first also didn't have this option, just Run as > Groovy Console. After some tinkering suddenly Run as > Groovy Script appeared, so this seems to be solved.

But immediately the next problem popped up:

The WEB-INF/lib folder contains the cyclos-impl.jar and the cyclos-api.jar which seem to have colliding package declarations:
The package org.cyclos.server.utils is accessible from more than one module: cyclos.api, cyclos.impl
If I remove cyclos-api.jar from the external jars the following error appears:
The type org.cyclos.model.utils.TransactionLevel cannot be resolved. It is indirectly referenced from required .class files
If I instead remove the cyclos-impl.jar, expectedly many more of those errors show up.
What is the reason for this declaration collision, am I using the wrong JRE? Do I really have to set the compiler compliance to 1.8 like https://stackoverflow.com/a/55572922 suggests?

luis
Posts: 185
Joined: Fri Feb 17, 2006 11:01 am

Re: How to debug in Eclipse?

Post by luis »

"Module" is a concept that appeared in Java 9.
Cyclos up to 4.13 is built in Java 8, which is a LTS (long term support).
The current Java LTS is version 11, and it is planned that Cyclos 4.14, whose development should start soon, will switch to it.
For now you do need to set version 8 in your project. And you need both cyclos-api and cyclos-impl jars, or there will be missing classes in runtime.
I'll check the README, so in Cyclos 4.13 it will make it explicit that the project needs to use Java 8 (1.8).
Luis Fernando Planella Gonzalez
Cyclos development team

Post Reply