Artifactory & Groovy plugin - how to get a list of all repositories within Artifactory - plugins

I'm writing an Artifactory plugin using Groovy.
I need it to get a list of all the repositories within the Artifactory.
In the lib folder of the plugin I added the jar of:
artifactory-java-client-services-2.3.2.jar
And the Intellij knows to complete the methods of the artifactory objects:printscreen of the intellij
I was trying to write this in the groovy file:
import org.jfrog.artifactory.*
import org.jfrog.artifactory.client.*
....
....
def baseurl = <URL to the artifactory>
ArtifactoryClient artifactoryClient = new ArtifactoryClient();
def artifactory = artifactoryClient.create(baseurl, <the user name>, <the password>)
def allRepositories = artifactory.getRepositories()
But as I add the imports to the file, the console of the Artifactory is showing the following error:
2017-05-04 09:42:04,468 [art-groovy-plugins-reloader] [ERROR] (o.a.a.p.GroovyRunnerImpl:302) - Error loading script from '..\etc\plugins\test.groovy'.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: java.lang.NoClassDefFoundError: Unable to load class org.jfrog.artifactory.client.ArtifactoryClient due to missing dependency org/jfrog/artifactory/client/Artifactory
java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to load class org.jfrog.artifactory.client.ArtifactoryClient due to missing dependency org/jfrog/artifactory/client/Artifactory
at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1091)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1069)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.util.GroovyScriptEngine$ScriptClassLoader.doParseClass(GroovyScriptEngine.java:274)
at groovy.util.GroovyScriptEngine$ScriptClassLoader.parseClass(GroovyScriptEngine.java:243)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:212)
at groovy.util.GroovyScriptEngine.loadScriptByName(GroovyScriptEngine.java:555)
at org.artifactory.addon.plugin.GroovyRunnerImpl.loadScript(GroovyRunnerImpl.java:277)
at org.artifactory.addon.plugin.GroovyRunnerImpl.getScripts(GroovyRunnerImpl.java:257)
at org.artifactory.addon.plugin.GroovyRunnerImpl.reloadScripts(GroovyRunnerImpl.java:137)
at org.artifactory.addon.plugin.GroovyRunnerImpl$ScriptsReloader.run(GroovyRunnerImpl.java:451)
Caused by: java.lang.NoClassDefFoundError: Unable to load class org.jfrog.artifactory.client.ArtifactoryClient due to missing dependency org/jfrog/artifactory/client/Artifactory
at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:391)
Any idea what is going wrong here and how to fix it?

It looks like you are trying to develop an Artifactory user plugin and use the Artifactory client inside this plugin. While this is doable, it might not be the best approach.
User plugin should use the Artifactory public API (PAPI) for communicating with Artifactory.
For your use case you should be using the methods available in the Repositories class for getting the list of available repositories.
The Artifactory client is actually using the Artifactory REST API behind the scenes, which is doable from a user plugin but slower than calling the PAPI directly. In addition the client requires to specify your Artifactory URL, which is an additional concern you will need to care about when writing the plugin.
If you do want to use the client in a user plugin, you should place the relevant .jar files (client and dependencies) in the plugins lib directory.

Related

Failed to execute goal org.apache.uima:ruta-maven-plugin:2.6.1 generate

Can no longer build my application due to an issue with a dependent class of ruta-maven-plugin:2.6.1. I've tried to use multiple version of ASM including 5.0.2 and 6.2. These version are dependencies of Apache Tika 1.17/18/19.
Here is the full build failure message:
Failed to execute goal org.apache.uima:ruta-maven-plugin:2.6.1:generate (default) on project DAnE-Pipeline: Execution default of goal org.apache.uima:ruta-maven-plugin:2.6.1:generate failed: Failed to read candidate component class: URL [jar:file:/home/fm/.m2/repository/org/apache/uima/ruta-core/2.6.1/ruta-core-2.6.1.jar!/org/apache/uima/ruta/resource/TrieXMLEventHandler.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: class path resource [org/xml/sax/helpers/DefaultHandler.class]; nested exception is java.lang.IllegalArgumentException -> [Help 1]
I feel like I've tried everything. Any help will be appreciated!
I re-read Peter's suggestion above. I was adding a newer Spring dependency in my project, but not in the "scope of the plugin". Once I created the Spring dependencies there, it worked! Thanks, Peter.

Can't use akka in IDEA plugin development

When I develop an IDEA plugin, I want to use akka, but have some problems.
I created a demo project here: https://github.com/freewind/idea-plugin-akka-demo
You can just clone it and reproduce the problem on your computer. (Notice the Setup section)
And I copy the problem here:
Problems
1. Can't use default akka configuration
If I removed:
src/main/resources/application.conf
src/main/scala/freewind/MyAkkaConfig
and run this plugin, it will report this error when starting:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
com.intellij.diagnostic.PluginException: No configuration setting found for key 'akka'
[Plugin: com.yourcompany.unique.plugin.id]
2. Can't load the configuration from file
Then I copied the reference.conf from akka jar, to src/main/resources/application.conf, but it still report the same error. Seems akka in IDEA plugin can't find this file automatically.
3. ClassNotFoundException: akka.actor.LightArrayRevolverScheduler
So I have to use MyAkkaConfig.scala to hardcode the configuration in scala code, but this time, it reports another error:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
com.intellij.diagnostic.PluginException: ClassNotFoundException: akka.actor.LightArrayRevolverScheduler
[Plugin: com.yourcompany.unique.plugin.id]
The akka.actor.LightArrayRevolverScheduler is used in MyAkkaConfig.scala, and is included in akka-actor_2.11:2.3.12:jar. But why IDEA can't load it?
For the 3rd problem, it can be fixed by passing the classloader:
val system = ActorSystem("my-actor", MyAkkaConfig.config, this.getClass.getClassLoader)
But we also can remove the MyAkkaConfig.config, to use the file application.conf under resources

How to Correctly use com.mattbertolini.hermes.Hermes to manage Constants at Server side (GWT)?

Ok, I want to manage Constants at Server level, so com.mattbertolini.hermes.Hermes is a solution.
Please see all my steps:
1- I downloaded hermes-1.2.0.jar & import into correct Library of eclipse (no problem)
2- Create MyConstantsWithLookup.java at client package
import com.google.gwt.i18n.client.ConstantsWithLookup;
public interface MyConstantsWithLookup extends ConstantsWithLookup {
String myMsg();
}
3- create MyConstantsWithLookup.properties file in the same client package. The file has this line:
myMsg=Deleted
4- In ServerData.java in Server package
MyConstantsWithLookup my = Hermes.get(MyConstantsWithLookup.class, "");
String extra=my.myMsg();
When tested in eclipse it works fine but I got Warnign message in eclipse:
[WARN] Server class 'com.ibm.icu.util.ULocale' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/eclipse-jee-juno-SR1-win32-x86_64/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201212122042-rel-r42/gwt-2.5.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/C:/Users/eclipse-jee-juno-SR1-win32-x86_64/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201212122042-rel-r42/gwt-2.5.0/doc/helpInfo/webAppClassPath.html
I am not sure what this warning's about? is it serious?
The code was running ok but why eclipse generated this warning?
This class (com.ibm.icu.util.ULocale) is a replacement for java.util.Locale, so it seems Hermes has a dependency on it.
Download the ICU4J jar from http://site.icu-project.org/download and add it to your project's build path.
Source: Matt Bertolini at https://github.com/mattbertolini/Hermes/issues/3
You need to add the ICU4j jar located at http://site.icu-project.org/
to your classpath. The reason you have the ICU classes inside the
gwt-dev.jar is because GWT includes them for its Java to JavaScript
compiler. This is regrettable since it often times falsely reports the
files on your classpath.

resty gwt:Deferred binding failed for 'com.gwt.demo.client.PersonResourceAsync

Hi i want to do project in gwt which is at client side and rest services at the server side,for this i am using resty gwt but i am getting an error:
com.google.gwt.event.shared.UmbrellaException: Exception caught: Deferred binding failed for 'com.gwt.demo.client.PersonResourceAsync' (did you forget to inherit a required module?).
Project description:-
ide:- eclipse
I am using resty gwt jar and i have included that jar from add external jar.I have also included in the gwt.xml as (<inherits name='org.fusesource.restygwt.RestyGWT'/>).I have also added that jar in war file lib folder. I have used one interface which extends restservice,in this interface while debugging i found that in the line i am getting nullpointerexception.
instance = GWT.create(PersonResourceAsync.class);
Please help me why i am getting this error?
Are you sure restyGWT jar is in your classpath ?
Can you post the code of your PersonResourceAsync ? Does it extends the RestService interface ?
Maybe you can have a look this tutorial

Issues debugging Errai app in Eclipse

When degugging an Errai application in Eclipse, I get the following error.
[WARN] failed com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload#1575d48{/,/home/matthew/git/PressGangCCMSUI/src/main/webapp}: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] failed RequestLogHandler#ad4bb0: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] Error starting handlers
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
Does anyone know how to fix this up?
It turns out the issue was because Eclipse was using a local Maven project as a dependency instead of the JAR file in the local repo cache. Once I close the project that my Errai app was dependant on, Eclipse reverted back to using the JAR in the local repo cache, and I could launch the debugger again.