custom maven GWT build fails on openshift - maven

On RedHat OpenShift I have created a jenkins build server. To get it working for my custom build I've changed the config.xml to have numExecutors=1. Then I added a maven gwt project to build. The build fails because it can not create the user preferences directory. See this log snippet.
[INFO] --- gwt-maven-plugin:2.5.0-rc2:compile (default) # web ---
[INFO] auto discovered modules [de.hpfsc.parent]
[ERROR] Apr 09, 2014 2:06:42 AM java.util.prefs.FileSystemPreferences$1 run
[ERROR] WARNING: Couldn't create user preferences directory. User preferences are unusable.
[ERROR] Apr 09, 2014 2:06:42 AM java.util.prefs.FileSystemPreferences$1 run
[ERROR] WARNING: java.io.IOException: No such file or directory
To test the correct working of simple maven builds I created a new jenkins project on https://github.com/abroer/jsltSpringLocaleProblem.git. This maven project works correctly and is being built without errors.
The problem can be recreated by building the https://github.com/steinsag/gwt-maven-example.git project.
Here's the job configuration
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.plugins.openshift.OpenShiftApplicationUUIDJobProperty plugin="openshift#1.4">
<applicationUUID></applicationUUID>
</hudson.plugins.openshift.OpenShiftApplicationUUIDJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderSizeJobProperty plugin="openshift#1.4">
<builderSize>small</builderSize>
</hudson.plugins.openshift.OpenShiftBuilderSizeJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderTimeoutJobProperty plugin="openshift#1.4">
<builderTimeout>300000</builderTimeout>
</hudson.plugins.openshift.OpenShiftBuilderTimeoutJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderTypeJobProperty plugin="openshift#1.4">
<builderType></builderType>
</hudson.plugins.openshift.OpenShiftBuilderTypeJobProperty>
</properties>
<scm class="hudson.plugins.git.GitSCM" plugin="git#1.1.12">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>https://github.com/steinsag/gwt-maven-example.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>**</name>
</hudson.plugins.git.BranchSpec>
</branches>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Maven>
<targets>clean package</targets>
<mavenName>(Default)</mavenName>
<usePrivateRepository>false</usePrivateRepository>
<settings class="jenkins.mvn.DefaultSettingsProvider"/>
<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
</hudson.tasks.Maven>
</builders>
<publishers/>
<buildWrappers/>
</project>

AFAICT, these messages shouldn't fail the compilation.
GWT uses preferences only in one place: update checks, so store when it last checked for updates. This is done asynchronously in a dedicated thread, and shouldn't fail the build.
GWT supports disabling update checks by passing the -XdisableUpdateCheck to the Compiler, but the gwt-maven-plugin doesn't let you do it. Try using the exec-maven-plugin to call the GWT compiler and pass the -XdisableUpdateCheck as argument to see if it fixes your problem.

Related

Activating GWT Dev Mode on a GWT application built using Maven

TL;DR: In order to debug the client-side, I ran gwt:run goal, launched the application on Chrome, and after login in, it threw the exception below, and GWT dev mode didn't launch (none of the client-side breakpoints worked)
javax.el.ELException: /pages/common/gwt/commonLayoutGWT.xhtml: setAttribute: Non-serializable attribute with name sessionBean
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:90)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
...
What should I do, or what should I check to get my GWT Dev mode working properly?
Some background: previously, our team used some ant scripts for compiling, debugging (server and client code), running and deploying our main application. It worked without a problem, although the process was really cumbersome and manual. We decided to make it a Maven application some months ago, and we were able to successfully execute all actions/goals after using
Maven. Compiling, running and deploying the application became fast and convenient, which was our goal.
But up until now we didn't notice that at some point in the process, our client side debugging stopped working. Only after we got some bug reports and started trying to debug them, we did notice the issue. So now I need to set the GWT Dev Mode, and haven't been able to do it no matter what I've tried.
I'm working with:
SmartGWT 4.0
JDK 1.8.0_121
GWT Eclipse Plugin 2.8.0
GlassFish 4.1
Maven 3.3
I tried to follow some instructions from gwtproject, using the default linker xsiframe into gwt.xml file.
But when I executed the gwt:compile goal, this error showed up:
[INFO] Linking into D:\Development\Repos\Git\Java\MyApp\myApp\target\classes\..\..\..\myApp\WebContent\pages\module\gwt\com.myapp.client.gwt.MyAppClient
[INFO] Invoking Linker Cross-Site-Iframe
[INFO] [ERROR] The Cross-Site-Iframe linker does not support <script> tags in the gwt.xml files, but the gwt.xml file (or the gwt.xml files which it includes) contains the following script tags:
To solve this, I used one of the recommended solutions by the error itself:
"...add this property to the gwt.xml file: <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>"
I ran the gwt:compile again, and it finished successfuly
I suggest running your server-side code in a separate server (could be mvn jetty:run), and run GWT Dev Mode only for the clientside code (use <noserver>true</noserver>).
That solves so many problems (with running webapps inside DevMode's embedded server) that's it's the recommended setup nowadays.

Does Bluemix devops build pipeline support java 8 apps?

Given the Bluemix announcement that java 8 is supported.
What do I need to do to get my java 8 app compiling in the IBM Bluesmix build pipeline (jazzhub build and deploy).
I have set the java8 environment variable and restaged the app using the following:
cf set-env <myApp> JBP_CONFIG_IBMJDK "version: 1.8.+"
cf restage <myApp>
The specific 'builder type' I am using is 'Maven' and the failures I receive are around the new date and time classes in java8.
[ERROR] <...>/services/TestHelperService.java:[3,17] package java.time does not exist
[ERROR] <...>/services/TestHelperService.java:[37,17] cannot find symbol
[ERROR] symbol: class LocalDateTime
[ERROR] location: class <...>.services.TestHelperService
To use Java 8 you need to change the JAVA_HOME environment variable in the build shell command:
export JAVA_HOME=~/java8
For example:
#!/bin/bash
#export JAVA_HOME=~/java8 - Bluemix have changed the java8 location
export JAVA_HOME=/opt/IBM/java8
mvn -B package
I also wanted to use Java8 in Bluemix Jazz build pipeline. Just changing $JAVA_HOME didn't work for me. I had to update the $PATH as well.
export JAVA_HOME=/opt/IBM/java8
export PATH=$JAVA_HOME/bin:$PATH
After that maven was run on java8.
Hi this solution does not work for me here is my build script
#!/bin/bash
echo "Java Home before $JAVA_HOME"
export JAVA_HOME=~/java8
echo "Java Home after $JAVA_HOME"
#mvn -B package -DskipTests
#mvn -B package
And here is the console output as you can see JAVA_HOME is not modified after "export" command.
Checking out Revision 86514c6dc277b6903fcd6f51ca7c97ea733b1d42 (detached)
[ba6eba91-33a3-4b67-8efd-48962cf063ba] $ /bin/bash /tmp/hudson7007424628517212775.sh
Java Home before /home/jenkins/java
Java Home after /home/jenkins/java
Base artifact directory /home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba/target does not exist or is not a valid directory.
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing JUnit
[xUnit] [INFO] - [JUnit] - No test report file(s) were found with the pattern 'target/surefire-reports/TEST-*.xml' relative to '/home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba' for the testing framework 'JUnit'. Did you enter a pattern relative to the correct directory? Did you generate the result report(s) for 'JUnit'?
[xUnit] [ERROR] - No test reports found for the metric 'JUnit' with the resolved pattern 'target/surefire-reports/TEST-*.xml'. Configuration error?.
[xUnit] [INFO] - There are errors when processing test results.
[xUnit] [INFO] - Skipping tests recording.
Finished: SUCCESS
I can confirm that setting JAVA_HOME to /opt/IBM/java8 in the build script does work (tried out on 2016-05-04):
#!/bin/bash
echo "Java home before: $JAVA_HOME"
export JAVA_HOME=/opt/IBM/java8
echo "Java home after: $JAVA_HOME"
mvn -B package
This results in the output:
Java home before: /opt/IBM/java
Java home after: /opt/IBM/java8
As noted before, the deploy stage must either have JBP_CONFIG_IBMJDK set to "version: 1.8.+" (cf set-env myApp JBP_CONFIG_IBMJDK "version: 1.8.+" or line in env: section of manifest.yml) or (that's what I do) you need to define buildpack: java_buildpack in manifest.yml. Since May 2015, java_buildpack uses to JDK8.
Last thing to be aware of is to change source version of maven-compiler-plugin in pom.xml, of course -- but that's not Bluemix-specific.
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>(whatever version is current)</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>

configuring maven beanstalker plugin beanstalk:wait-for-environment mojo

I've successsfully deployed my app to elastic beanstalk using
$ mvn beanstalk:upload-source-bundle beanstalk:create-application-version beanstalk:update-environment
I'm able to watch in the AWS console that the environment is updated correctly. When I try to chain beanstalk:wait-for-environment, maven polls every 90 seconds and never detects that the environment is Ready.
One thing I noticed is that it's waiting for 'environment null to get into Ready', and it's looking for the environment to have a specific domain **.elasticbeanstalk.com. I don't know how to change that, or disable that check
$ mvn beanstalk:upload-source-bundle beanstalk:create-application-version beanstalk:update-environment beanstalk:wait-for-environment
...
[INFO] Will wait until Thu Aug 22 10:59:37 PDT 2013 for environment null to get into Ready
[INFO] ... as well as having domain ********.elasticbeanstalk.com
[INFO] Sleeping for 90 seconds
My plugin config in pom.xml looks like this (company confidential names hidden)
<plugin>
<groupId>br.com.ingenieux</groupId>
<artifactId>beanstalk-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<applicationName>********-web-testing</applicationName>
<s3Key>********-2.0-${BUILDNUMBER}.war</s3Key>
<s3Bucket>********-web-deployments</s3Bucket>
<artifactFile>target/********-2.0-SNAPSHOT-${BUILDNUMBER}.war</artifactFile>
<environmentName>********-web-testing-fe</environmentName>
</configuration>
</plugin>
Does anyone have insight into using beanstalk:wait-for-environment to wait until the environment has been updated?
wait-for-environment is only needed (in part) when you need a build pipeline involving zero downtime (with cname replication). It all boils down to cnamePrefix currently. You can basically ignore this warning if you're not concerned about downtime (which is not really needed for testing environments)
Actually, the best way is to use fast-deploy. Use the archetype as an start:
$ mvn archetype:generate -Dfilter=elasticbeanstalk

Sonar-runner fails due to missing cxx-language plugin, although installed

I am very new to Sonar and in the process of setting up my first server/project.
Environment:
OS: Windows Server 2008 R2 / amd64 / 6.1
App Server: Tomcat/7.0.40I, deployed the Sonar WAR file (3.5.1).
DB: MySQL 5.6.11
(relevant) Plugins:
Sonar C++ Community Plugin (0.2)
The plugin is visible under General Settings --> Sonar C++ Community Plugin
sonar-project.properties
# Required metadata
sonar.projectKey=test:pmc
sonar.projectName=PMC
sonar.projectVersion=1.0
sonar.language=c++
# Comma-separated paths to directories with sources (required)
sonar.sources=c:/SVN/Development/test/PMC/trunk/AppServer,c:/SVN/Development/test/PMC/trunk/PmcShared,c:/SVN/Development/test/PMC/trunk/WebServer,c:/SVN/Development/test/PMC/trunk/Tools
# Optional path to the CppCheck program required to activate some CppCheck rules
sonar.cpp.cppcheck.path=C:/Program Files (x86)/Cppcheck/cppcheck.exe
# Encoding of the source files
sonar.sourceEncoding=UTF-8
The thing I do not understand is that it cannot find a plugin that supports the 'cxx' language:
C:\Users\Administrator\Documents\sonar-projects\PMC>sonar-runner
C:\Users\Administrator\Documents\sonar-runner-2.2.1
Sonar Runner 2.2.1
Java 1.7.0_21 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
INFO: Runner configuration file: C:\Users\Administrator\Documents\sonar-runner-2.2.1\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\Administrator\Documents\sonar-projects\PMC\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\Administrator\Documents\sonar-projects\PMC\.sonar
INFO: Sonar Server 3.5.1
15:20:54.231 INFO - Load batch settings
15:20:54.794 INFO - User cache: C:\Users\Administrator\.sonar\cache
15:20:54.797 INFO - Install plugins
15:20:55.742 INFO - ------------- Executing Project Scan
15:20:56.482 INFO - Install JDBC driver
15:20:56.487 INFO - Apply project exclusions
15:20:56.493 INFO - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
15:20:56.771 INFO - Initializing Hibernate
15:20:59.229 INFO - ------------- Inspecting PMC
15:20:59.229 INFO - Load module settings
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 6.162s
Final Memory: 13M/221M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'cxx'
ERROR:
ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.
ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.
I do have the Sonar C++ Community Plugin installed so I guess I am missing the obvious...could someone please help me getting started?
It seems I made a mistake in the configuration file. I re-created it and now the job runs! This issue is closed and the configurations above will work.
I had a similar error with the C# plugin:
ERROR: Caused by: You must install a plugin that supports the language 'cs '
Please remark the 'cs '
After long time I spotted the extra ' ' after 'cs'. When removing the extra space in the configuration file it worked. It seems like sonar-runner don't use "trim".
For new users, if you still getting this error (SonarQube 4+) start the server, go to the 'Settings' ( top right ) then search for 'Update center' there you add missing modules , next restart Server. it should works
Source: Link from official project website
To find the string required to activate any given SonarQube language plugin, go to "Settings" -> "System" -> "Update Center". For each plugin, the short name will be in square brackets to the right of the human-readable name.
C / C++ / Objective-C [cpp]
In this example, "cpp" is the name to use in the sonar.language property in your sonar-project.properties.

Jenkins multi configuration passing parameters when running Maven job

I'm trying to set up a Jenkins multi configuration job for the selenium tests of my project that runs against multiple browsers. I checked the different options and the multi configuration job seems to be a good fit, but I cannot make maven pass the parameters correctly to maven.
I have a few parameters I need to pass to maven, mainly browserName and appDomain, and also a Profile to run the tests. To configure the job I do the following:
Define the SVN repository from where the code will be checked out.
Set up browserName as a user define axis, with values FIREFOX, CHROME, IE.
Create a build step of type "Invoke top-level Maven targets", and here's where I get the problems. The configuration of this part is different from other job types, usually there's a field called Goals and Options where to put everything, but in this case is divided in different fields. So I don't know where exactly put the properties and the profile.
a) The logical thing, I put the goals in Goals field and the parameters and options in the properties field, like in the image:
In this case the job runs normally without executing the tests, because the profile is not executed.
b) If I put just the profile in the Goals field, the maven call in the log is:
/opt/apache-maven-2.2.1/bin/mvn -DbrowserName=CHROME "-D-Dappdomain=0 -Dtestenv=test -Drc=true -DsuiteXmlFile=testOne.xml -U -Dapp.instance.key=jenkins -Denv=default" clean verify -Pwebtests
And the exception is:
[INFO] [enforcer:enforce {execution: enforce-property}]
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must pass the appdomain as parameter! Example: -Dappdomain=20
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must pass the test environment as parameter! Example: -Dtestenv=beta
So is not getting the properties
c) Finally, if I put everything in the goals field, I get the following exception:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'property:merge'
[0] Inside the definition for plugin 'property-maven-plugin' specify the following:
<configuration>
...
<environment>VALUE</environment>
</configuration>
-OR-
on the command line, specify: '-Denv=VALUE'
I tried with a normal and parametrized job and works perfectly...
Jenkins version is: 1454 and Maven is 2.2.1
I found out that the Jenkins machine wasn't properly configured. I tried in another instance and was all good with the following configuration:
-Goals: clean verify Pwebtests
-Paramenters: (properties file format)
appDomain=0
testenv=test
env=default
....
And as a sidenote, the other jobs were working because they were using the Jenkins Maven plugin, which seems to use java to launch a Hudson class that calls Maven, instead of calling directly the mvn command, which is what happens when a build step of type "Invoke top-level Maven Targets"

Resources