How to use SSH sampler with Maven JMeter Plugin - jmeter-maven-plugin

I'm sure other people tried this usage, but I could't find good examples online. I hope someone can help and comment whether it's doable at all.
Part of my pom.xml file is given below. The problem is that Maven couldn't find the "jmeter-ssh-sampler" declared as one dependency for "meter-maven-plugin". Should I configure Maven to search a different repositry for it ?
thanks
Yulin
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0:jmeter (jmeter-tests) on project jmeter-test: Execution jmeter-tests of goal com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0:jmeter failed: Plugin com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0 or one of its dependencies could not be resolved: Failure to find org.apache.jmeter.protocol.ssh.sampler:jmeter-ssh-sampler:jar:0.1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<suppressJMeterOutput>false</suppressJMeterOutput>
<propertiesUser>
<host>${target_server}</host>
</propertiesUser>
<jmeterPlugins>
<plugin>
<groupId>org.apache.jmeter.protocol.ssh.sampler</groupId>
<artifactId>jmeter-ssh-sampler</artifactId>
</plugin>
</jmeterPlugins>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.51</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter.protocol.ssh.sampler</groupId>
<artifactId>jmeter-ssh-sampler</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

jmeter-ssh-sampler is not available in maven central:
http://search.maven.org/#search|ga|1|org.apache.jmeter.protocol.ssh.sampler
If this dependency can't be located, I don't think jmeter-maven-plugin will be able to make use of jmeter-ssh-sampler. It either needs to be made available in the repository maven is looking for, or you may end up with dirty hacks, which I'd suggest to avoid as much as possible (e.g. manipulate file system directly).

The JMeter SSH Sampler is not in any Maven repository. Most easy way to add it, clone the git repo, compile the code, and upload (deploy) the jar to your central Maven repository.

Related

Exception while building Scala-Maven project on IntelliJ

I am trying to build a Scala-Maven project on IntelliJ IDEA. Right after creating the project, it says build successful. This is how my pom.xml looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dbloads.pgms</groupId>
<artifactId>Arts</artifactId>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<properties>
<scala.version>2.7.0</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<additionalProjectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Next I tried to add the compiler options in project like below:
Once added and when I click the RUN button, I get the below error message:
[ERROR] Plugin net.alchim31.maven:scala-maven-plugin:3.4.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.alchim31.maven:scala-maven-plugin:jar:3.4.0: Could not transfer artifact net.alchim31.maven:scala-maven-plugin:pom:3.4.0 from/to central (https://repo.maven.apache.org/maven2): PITC-Zscaler-EMEA-Amsterdam3PR.proxy.corporate.ge.com: Unknown host PITC-Zscaler-EMEA-Amsterdam3PR.proxy.corporate.ge.com -> [Help 1]
I am using the jdk version: 1.8.0_172 and I have added the Scala plugin directly from the plugins. Hence it is the latest version of the Scala.
Could anyone let me know how can I fix this problem.
It looks like you need to configure Maven and IntelliJ to use network proxy settings, since it looks like you might be behind a corporate firewall.
Maven has the ability to configure a proxy through its settings (in ~/.m2/settings.xml on Unix-like systems, or %HOME%\.m2\settings.xml on Windows), as follows:
<settings ...>
.
.
<proxies>
<!-- You can have one of these for each possible proxy. -->
<proxy>
<active>true</active>
<!-- Pick some ID for your proxy here. -->
<id>corp-proxy</id>
<!-- Choose your protocol here. E.g. "http", "socks4" or "socks5" -->
<protocol>http</protocol>
<!-- Specify the proxy server name (or IP address) and port of your proxy here. -->
<host>proxy.example.com</host>
<port>8080</port>
<!-- Identify any hosts here that you can access directly. It's unlikely that you'll
need this unless you have a proxy repository (such as Nexus, Artifactory, etc.) on
your corporate network. -->
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
<!-- The following fields are only necessary if required by your proxy. If you need to
enter your own username and password, make sure you do not add this file to version
control! -->
<username>proxyuser</username>
<password>somepassword</password>
</proxy>
</proxies>
.
.
</settings>
Meanwhile, IntelliJ is configured to use proxies through its settings. Refer to this answer for further details. (Note that setting proxy information via the JAVA_OPTS environment variable will work for running any Java/Scala/JVM application that needs to access the Internet via a proxy.)
Alternatively, if your proxy settings are configured correctly or are not required, it might be a temporary network connection issue, so make sure you have an Internet connection and try again. (The exception is a failure by Maven to download the plugin from the Maven central repository.)
BTW, the version of Scala you have specified—2.7.0—is ancient and almost certainly will not work with JDK 8. Either use an older JDK or a more recent version of Scala (the current release is 2.12.6).
Note that if you need to work with the current version of Apache Spark, you must currently use Scala 2.11.x - the most recent release being 2.11.12.
UPDATE:
From your comments, it seems there is some confusion about the roles played by Maven, the scala-maven-plugin, IntelliJ and the IntelliJ Scala plugin, so I'll quickly summarize them here. Please bear with me if I cover topics you're already familiar with...
Maven is a system for building and publishing software. (It actually does a lot more than just that, which is why Maven describes itself as project management software.) It allows developers to specify, in a single place, all of their software's dependencies (third-party libraries used by the software), which Maven downloads as required from the Central Maven Repository—mostly open-source—or from other, private repositories, as required. Further settings control how compilers are configured, tests are run, reports generated, etc.
Maven was developed primarily for development of Java-language projects. The scala-maven-plugin provides support for the Scala language and compiler within Maven. It is this plugin that downloads the version of the Scala compiler specified by your project and uses it to compile and build your sources.
If you look at your Maven project's pom.xml file, you will notice the following lines in the build section:
<project ...>
...
<build>
...
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
...
</build>
...
</project>
and again in the reporting section:
<project ...>
...
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
In both cases, there is a line that reads <scalaVersion>${scala.version}</scalaVersion>, which tells Maven which version of Scala you want to use. The plugin then uses this version of the Scala compiler, and has Maven download it to a cached, local repository on your machine (typically, in C:\Users\{your account}\.m2 on a Windows machine). Note that both Maven and the scala-maven-plugin will ignore any versions of Scala you have installed on your machine.
So which version of Scala is the plugin going to download for you? The value ${scala.version} states that the version number is stored as the value of a property named scala.version. Your pom.xml file also has lines, near the top, that create this property:
<project ...>
...
<properties>
<scala.version>2.7.0</scala.version>
</properties>
...
</project>
So, you can see that you will use version 2.7.0 of the Scala compiler. If you want to use the latest Scala version, you should change this to:
<project ...>
...
<properties>
<scala.version>2.12.6</scala.version>
</properties>
...
</project>
OK, so now you will be using the latest version of the Scala compiler. Now let's move on to IntelliJ...
IntelliJ IDEA is an Integrated Development Environment (IDE), primarily aimed at development with the Java language. It provides syntax highlighting, smart code completion, and other features to simplify the process of writing code. In order to provide those features for the Scala programming language, you need to install its Scala plugin.
You can configure IntelliJ to use any version of Scala that you have installed on your machine. IntelliJ will then know how to compile, build and run your software and can work without using your Maven project object model (POM) file's build definition.
However, one of the reasons for using Maven is to ensure a consistent build environment for developing a project, so that it is not at the whim of whatever each developer may or may not have installed on their machine. For this reason, if a project uses Maven, it's a good idea to tell IntelliJ. That way, IntelliJ can use Maven's pom.xml file to specify the version of the compiler, download dependencies, configure the compiler settings, etc.
So, the above information should help you to get up-and-running with your project, working with your corporation's network proxy and using the latest version of Scala, using Maven and IntelliJ.

Running Eclipse inside Tycho using reactor artifacts

Is there a way to make the tycho-eclipserun-plugin:eclipse-run goal resolve dependencies against artifacts in the current reactor or in the local repository. I'm trying to run the Eclipse/CDT headless build application as a step in our Tycho build, but I cannot figure out how to populate the Eclipse instance with the newly-built toolchain plugins.
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<executions>
<execution>
<configuration>
<appArgLine>-application org.eclipse.cdt.managedbuilder.core.headlessbuild -import file:///... -cleanBuild all</appArgLine>
<repositories>
<repository>
<url>http://download.eclipse.org/releases/kepler/</url>
<layout>p2</layout>
</repository>
</repositories>
<dependencies>
...
<dependency>
<artifactId>my.toolchain.feature</artifactId>
<type>eclipse-feature</type>
</dependency>
</dependencies>
</configuration>
<goals>
<goal>eclipse-run</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
This will fail since my toolchain plugins are not present in the Eclipse instance which hosts the headless build application. I could, of course, point out an external update site which hosts the plugins, but I would like to be able to use the plugins which are already being built in the same reactor. Is that possible?
EDIT: Original question included "or local repository artifacts", but that was not what I actually meant.
No, this is not possible.
Earlier versions of Tycho allowed using artifacts from the reactor for the eclipserun-plugin, but this caused problems for projects which build upstream artifacts from the artifacts they used for the eclipserun-plugin, namely the Eclipse Platform. So to fix this, the artifacts used by the eclipserun-plugin were decoupled from the reactor & reactor dependencies in Tycho 0.17.0.
One could imagine ways to re-allow this use case, but this is currently just not implemented. AFAIK there are no concrete ideas yet how to do this. If you want to contribute one, you could file an enhancement in Tycho's issue tracker.
The easiest way I could find is to use the maven-dependency-plugin to copy the repository from the repository-module:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.iar</groupId>
<artifactId>my.toolchain.repository</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>zip</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
This will copy and unpack the repository locally. It can then be specified as a repository when calling the eclipserun target:
<repository>
<url>file://${project.build.directory}/dependency</url>
<layout>p2</layout>
</repository>
The only thing you need to know is the GAV of the "eclipse-repository" module which contains the repository you need.
EDIT: This turned out to not work as I expected. It will pull artifacts from the local repository, and not from the reactor as I expected.

Error in pom.xml Maven build

I am getting an error in my pom.xml when trying to build a maven project. The error is here on this plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
This is the error Eclipse shows:
Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.3.2:compile (execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not
be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-toolchain:jar:1.0:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-toolchain:pom:1.0 from http://repo.maven.apache.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-toolchain:pom:1.0 from/to central (http://
repo.maven.apache.org/maven2): The operation was cancelled.
Seems like the resolution failed.
Run mvn with the -U flag to disregard the cache and re-attempt resolution
(the alt+f5 dialog might help as well)
When I ran into this problem I figured out that it was due to a previous network problem. The local Maven repository avoids immediate reattempts. The best way to solve this was to use the eclipse "Update Maven Project" (ALT+F5) feature end check the option "Force Update of Snapshots/Releases".
This was not working for me , changing maven compiler version to 2.5.1 finally worked for me , hopefully this comes to rescue for anyone still struggling with this dependency
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases".
Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases". works for me also
Got similar issue. Maven update and force update of snapshot didn't work for me.
Did following steps, issue resolved:
Remove project in eclipse.
Delete .Project file and . Settings folder.
Import project as existing maven project again to eclipse.

Missing artifact log4j:log4j:bundle:1.2.17

I created a dynamic web application in eclipse Version: Kepler Service Release 1 using menu.
After that I converted it into a maven project using
configure -> convert to maven project. Then I did
maven->Add dependency and then searched for log4j.
After adding that on hovering over the tag
for log4j it displays Missing artifact log4j:log4j:bundle:1.2.17.
I can't update dependencies using maven. How to fix it?
Please also explain the reason for the error.
Here is the generated xml after adding log4j.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Healthcare</groupId>
<artifactId>Healthcare</artifactId>
<version>0.0.1-HEALTHCARE</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>bundle</type>
</dependency>
</dependencies>
</project>
First why did you changed the default source folder location? The default is src/main/java and for webapp src/main/webapp. Apart from that a bundle for log4j does not exist on Maven Central just remove the <type>bundle</type> from your dependency, cause in Maven Central only a jar is available.
I always do the following trick:
In the dependencies management i edit the dependencies properties (select the dependencies with problem and click on properties button) changing the type from bundled to jar and that fixs the problem.
Well i hope that this solution work for you :) regards,
I too played with all the options provided above but it did not helped. By updating Maven dependencies forcefully my issue got resolved.
Go to project >> Maven >> Update Project
select the project and click OK.
Project will automatically try to download required jar but if still you are getting same error then do below step.
Go to project >> Maven >> Update Project >> check in the checkbox 'Force Update of Snapshots/Releases'
select the project and click OK.
Please check if the dependencies are correct or if it is missing.
<properties>
<springframework.version>4.2.1.RELEASE</springframework.version>
<jackson.version>2.5.3</jackson.version>
<log4j.version>1.2.17</log4j.version>
</properties>
By default (and the common usage), Maven would consume jars as a dependency. Just change the bundle to jar in your pom.xml file in the given dependency which is giving you an error.

How to automatically generate lexer+parser with ANTLR4 and Maven?

I'am new to ANTLR4, and it seems that there is no Eclipse-Plug-In for v4. So it would nice to build automatically the Java sources from the .g4 grammars. I have a simple, empty Maven-project with src/main/java, src/test/java. Where to place the .g4 files? How can I automatically build the grammars with Maven?
My own POM-test failed:
<repository>
<id>mvn-public</id>
<name>MVNRepository</name>
<url>http://mvnrepository.com</url>
</repository>
...
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Eclipse says:
Failure to find org.antlr:antlr4-maven-plugin:pom:4.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of
central has elapsed or updates are forced
I created the following Gist with a pom.xml designed solely for supporting automatic code generation from ANTLR 4 grammars during an Eclipse build. It includes the necessary lifecycle information for m2e to know that the code generation is necessary, and explicitly adds the code generation folder using the build-helper-maven-plugin since Eclipse seemed to have some trouble locating it otherwise.
In this configuration, grammar files (*.g4) are placed alongside the other Java source files. The Maven plugin will automatically add the proper package ... statement to the generated files, so you shouldn't include a #header{package ...} line in the grammar itself.
https://gist.github.com/sharwell/4979017
Check out this Antlr4 plugin for Eclipse
https://github.com/jknack/antlr4ide