I am trying to run the com.github.klieber.phantomjs-maven-plugin alone before trying to run it with com.github.searls.jasmine-maven-plugin.
The final goal is to be able to run Javascripts tests in maven then in Jenkins.
But I always have the same error :
[ERROR] Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:install (default) on project my-jasmine-project: Execution default of goal com.gith
ub.klieber:phantomjs-maven-plugin:0.7:install failed: Unable to load the mojo 'install' (or one of its required components) from the plugin 'com.github.klieber:
phantomjs-maven-plugin:0.7': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) Could not find a suitable constructor in com.github.klieber.phantomjs
.mojo.InstallPhantomJsMojo. Classes must have either one (and only one) constructor annotated with #Inject or a zero-argument constructor that is not private.
[ERROR] at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.class(Unknown
Source)
[ERROR] while locating com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo
[ERROR] at ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: sun.misc.Launcher$AppClassLoader#f4a24a]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with #com.google.inject.name.Named(value=com.github.klieber:phantomjs-maven-plugin:0.7:install)
[ERROR]
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: com.github.klieber:phantomjs-maven-plugin:0.7:install
I created a maven project with
mvn archetype:generate -DarchetypeGroupId=com.github.searls
-DarchetypeArtifactId=jasmine-archetype
-DarchetypeVersion=RELEASE
-DjasminePluginVersion=2.1
-DgroupId=com.acme
-DartifactId=my-jasmine-project
-Dversion=0.0.1-SNAPSHOT
and here is the pom where I try to only install Phantom JS
<build>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.7</version>
</configuration>
</plugin>
</plugins>
</build>
Could you tell me what I am doing wrong ?
Thanks in advance,
I think your issue is the same as this one: https://github.com/klieber/phantomjs-maven-plugin/issues/34
Solution: Make sure you are using Maven 3.1 or higher.
I found an other solution for running Javascripts tests in maven then in Jenkins
Below is how I use it in my POM:
<!-- Install phantom JS binaries. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.phantomjs</groupId>
<artifactId>phantomjs</artifactId>
<version>${phantomjs.version}</version>
<type>${phantomjs.packaging}</type>
<classifier>${phantomjs.classifier}</classifier>
<!-- Unpack the artifact in a directory at the same level than
the build directory. -->
<outputDirectory>${project.build.directory}/..</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Depending on the platform I activate different profile so that I download the correct artifact (the one for Windows or the one for Linux on where our Jenkins runs. Hope it helps ! :)
<!-- PhantomJS for Windows -->
<profile>
<id>phantomJS-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<phantomjs.classifier>windows</phantomjs.classifier>
<phantomjs.bin>phantomjs.exe</phantomjs.bin>
<phantomjs.packaging>zip</phantomjs.packaging>
<test.script.ext>bat</test.script.ext>
</properties>
</profile>
<!-- XXX: Jenkins instance runs on Linux 64 bits. -->
<!-- 64 bits. -->
<profile>
<id>phantomJS-bca-jenkins</id>
<activation>
<property>
<name>sun.arch.data.model</name>
<value>64</value>
</property>
</activation>
<properties>
<phantomjs.classifier>linux-x86_64</phantomjs.classifier>
<phantomjs.bin>bin/phantomjs</phantomjs.bin>
<phantomjs.packaging>tar.bz2</phantomjs.packaging>
<test.script.ext>sh</test.script.ext>
</properties>
</profile>
Related
I get this strange stacktrace when running mvn clean verify -P P1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.21.0:verify (default) on project prj-name: There are test failures.
[ERROR]
[ERROR] Please refer to C:\path\to\project\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] sun.reflect.annotation.TypeNotPresentExceptionProxy
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:658)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
What does it mean?
Maven pom.xml:
<profiles>
<profile>
<id>P1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<!-- Includes integration tests -->
<includes>
<include>**/integration/*.java</include>
<include>**/integration/*/*.java</include>
</includes>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
UPDATE
There's a surefire dumpstream file
ForkStarter IOException: For input string: "1;5".
org.apache.maven.plugin.surefire.booterclient.output.MultipleFailureException: For input string: "1;5"
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.<init>(ThreadedStreamConsumer.java:58)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.<init>(ThreadedStreamConsumer.java:110)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:596)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:200)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:196)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Because of garbage in string variables and occasional IndexOutOfBoundsException / ConcurrentModificationException in logs it seems like a concurrency issue.
This GitHub issue - [#6254] Maven-failsafe-plugin fails to execute integration tests - and the related discussion helped me to solve my problem.
It's a bug. It turns out that newer Failsafe plugin versions (2.19.0 and later) don't work well with Spring Boot 1.4 (or later). Workaround is to downgrade the maven-failsafe-plugin to 2.18.1. Here's the updated pom.xml:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<!-- I don't specify version at all (Spring Boot can autoconfigure plugin version) -->
<executions>
<execution>
<!-- changed <id> to <phase>, but I don't know whether it's important or not. -->
<phase>integration-test</phase>
<!-- ... no changes here: the same as in the question ... -->
</execution>
</executions>
</plugin>
</plugins>
I followed the solution proposed here:
https://github.com/spring-projects/spring-boot/issues/6254#issuecomment-307151464
Currently, I have failsafe plugin 2.22.0 and I'm able to use this version and not downgrade by explicitly configuring the classesDirectory property:
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
Example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<configuration>
...
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
...
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Another variant of the workaround is described later in the same Github issue thread: https://github.com/spring-projects/spring-boot/issues/6254#issuecomment-343470070
<classesDirectory>${project.build.directory}/${artifactId}.jar.original</classesDirectory>
Note (2020-02-27): maven-failsafe-plugin version 3.0.0-M4 still needs these workarounds :-(
My testng class was having LoginPageTest.java, I removed .java and worked perfectly fine. :)
<classes>
<class name="com.qa.Backend.tests.LoginPageTest"/>
</classes>
I used to get the problem and mostly the problem is initializing instance variables. Check your instance variables that are working in local and if working check when they are running in CI/CD pipeline.
Another workaround is to configure a classifier for the repackaged jar. This allows Failsafe to use the original jar:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
This problem is due to a combination of a change in the Failsafe plugin and a change in the layout of a repackaged jar file in Boot 1.4. As of Failsafe 2.19, target/classes is no longer on the classpath and the project's built jar is used instead. In the case of a Boot app, that's the repackaged jar. In 1.4, the application's classes were moved from the root of the jar to the BOOT-INF/classes directory. This prevents them from being loaded by Failsafe.
src: GitHub Issues
I want to override a particular plugin configuration that's defined in the pom.xml. I don't want to modify the pom.xml for various reasons. Is there a way to define a config attribute for that plugin in settings.xml that override corresponding pom.xml plugin config?
In the below example, you'll notice that the plugin xx-plugin is defined in profile1 in pom.xml. In my settings.xml I've already defined profile2 to override property prop1 from pom.xml. But how to override config3. I apologize if this is a silly question. I am a little new to maven.
This is what my pom.xml looks like:
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.xx.yyy</groupId>
<artifactId>xx-plugin</artifactId>
<executions>
<execution>
<id>xx-install</id>
<phase>install</phase>
<goals>
<goal>xx-install</goal>
</goals>
<configuration>
<config1>AAA</config1>
<config2>BBB</config2>
<config3>CCC</config3> <!-- I want to override this with value DDD -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
This is what my settings.xml looks like:
<profile>
<id>profile2</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<prop1>overriden-value</prop1> <!-- This works -->
</properties>
<!-- Somehow override config3 here -->
<!-- <config3>DDD</config3> -->
</profile>
AFAIK you can only override properties with settings.xml profiles. You'd have to change your plugin's configuration to use a property instead of a fixed value:
<!-- define your property -->
<properties>
<prop1>CCC</prop1>
</properties>
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.xx.yyy</groupId>
<artifactId>xx-plugin</artifactId>
<executions>
<execution>
<id>xx-install</id>
<phase>install</phase>
<goals>
<goal>xx-install</goal>
</goals>
<configuration>
<config1>AAA</config1>
<config2>BBB</config2>
<config3>${prop1}</config3> <!-- I want to override this with value DDD -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Remember that profiles with activeByDefault set to true will get deactivated if any other profile gets activated in your build invocation. See http://maven.apache.org/guides/introduction/introduction-to-profiles.html
If you do not want to change the pom.xml for a plugin you can set the configuration as JVM parameter when running maven as stated in the Generic Configuration chapter of the Maven Guide to Configuring Plugins.
Example:
mvn my-plugin:my-goal -Dplugin.property=ABC
Example for the wildfly plugin (this is where I needed it and did not want to change the pom.xml of a demo project when deploying to a server group in a domain context):
mvn clean install wildfly:deploy -Dwildfly.serverGroups=<server-group-name>
The maven documentation also states that most plugins define help goals to explain users how to configure them.
Exaple for the wildfly plugin:
mvn wildfly:help -Dgoal=deploy -Ddetail
I am trying to run tomcat though cargo. Tomcat is already installed. cargo:deploy is working fine but when I try cargo:run I get the following error
If you specify a containerId, you also need to specify a containerUrl.
If I specify a containerURL I get the following error
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-
plugin:1.4.13:run (default-cli) on project ctm: Unable to parse configuration
of mojo org.codehaus.cargo:cargo-maven2-plugin:1.4.13:run for parameter
containerURL: Cannot find 'containerURL' in class org.codehaus.cargo.maven2.configuration.Container
...
This is my Maven config
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.13</version>
<configuration>
<container>
<type>existing</type>
<containerId>${cargo.maven.containerId}</containerId>
<home>${container.home}</home>
</container>
<configuration>
<type>existing</type>
<home>${container.home}</home>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>example</context>
</properties>
</deployable>
</deployables>
</configuration>
<executions>
<execution>
<id>run</id>
<configuration>
<configuration>
<type>existing</type>
</configuration>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
this is my profile
<profile>
<id>developer-properties</id>
<properties>
<cargo.maven.containerId>tomcat7x</cargo.maven.containerId>
<container.home>C:/apache-tomcat-7.0.35</container.home>
</properties>
</profile>
According to cargo documentation; type "existing" should use an existing container installation. I don't think I need containerURL unless the type is "standalone". I don't understand why I'm getting the containerURL error.
Documentation on type is here: https://codehaus-cargo.github.io/cargo/Existing+Local+Configuration.html
I think the documentation is unclear. I think cargo:run always uses a standalone local configuration, hence the description
If the plugin configuration defines a container with a standalone
local configuration, it will create the configuration.
So it's probably ignoring your existing local configuration.
I am trying to deploy war on tomcat8 using cargo plugin my entry is as follows:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.8</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>tomcat</cargo.remote.username>
<cargo.remote.password>s3cret</cargo.remote.password>
<cargo.tomcat.manager.url>http://localhost:1234/manager/text</cargo.tomcat.manager.url>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>/auditAPP</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
when i trying to run this using mvn cargo:deploy its giving me the following error
Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.8:deploy (default-cli) on project Audit_Management_DS: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.8:deploy failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [remote]], configuration type[runtime]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]
Update to cargo-plugin version 1.4.13 solved this error message for me.
EDIT
The problem is the generate-resources goal is not executed by Maven in Unix.
With Maven 2.0.10, I execute that instruction : mvn resources:resources
On windows :
[INFO] [dependency:unpack {execution: unpack-filters}]
[INFO] Configured Artifact: com.viaccess.testtools:filters:1.0-SNAPSHOT:jar
[INFO] filters-1.0-SNAPSHOT.jar already unpacked.
On Unix :
[INFO] No goals needed for project - skipping
Strange ... Same maven, same conf.
OLD POST
I have a problem with filtering my maven project.
It works good on windows, but not on unix (redhat).
Though, maven version is the same, java version is the same and settings.xml of maven is the same. So, I don't see where is the problem.
The maven instruction is mvn clean package
On windows, it works good. On windows, it failed with the error Error loading property file '/var/tmp/test/target/filters/empty.properties'
And not target directory is created.
Somebody can help me ?
More information about the pom files.
Here info about the parent pom :
<properties>
<filters.path>${project.build.directory}/filters</filters.path>
<filter.default>empty.properties</filter.default>
</properties>
<profiles>
<profile>
<id>default</id>
<properties>
<filter.defaut>default.properties</filter.defaut>
</properties>
</profile>
<profile>
<id>windows</id>
<properties>
<filter.defaut>default.properties</filter.defaut>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>filters</directory>
<targetPath>${project.build.directory}/filters</targetPath>
</resource>
</resources>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-filters</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.viaccess.testtools</groupId>
<artifactId>filters</artifactId>
<version>1.0-SNAPSHOT</version>
<includes>*.properties</includes>
<outputDirectory>${filters.path}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
The filter project is like that :
<build>
<resources>
<resource>
<directory>src/filters</directory>
<targetPath>${project.build.directory}/classes</targetPath>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
</build>
And the main project is like that.
<parent>
<!-- link to my parent project -->
</parent>
<build>
<filters>
<filter>${filters.path}/${filter.defaut}</filter>
</filters>
Thanks for your help.
I have found the problem. No problem on the pom, a problem of nexus.
On windows, I used the last pom parent beacause it's my work desktop (and I make a pom install).
Unix is a remote server. The downloading of the pom parent was already done, so new version was never uploaded.
Noob problem, sorry ... :)
Thanks for your help.
Eric