WSO2ESB - Building a CAR file with Maven - maven

Using WSO2 Developer Studio (version 3.7.0), I have created a WSO2 ESB proxy service with a sequence in a "ESB Config Project", this proxy service using a wsdl file located in a "Registry Resources Project". I also created a "Composite Application Project" to generate my .car file (including proxy service, sequence and resources), and deployed this file in my WSO2 ESB installation with success.
Now I am trying to generate (then deploy) the .car file using maven command.
I first tried this solution : https://docs.wso2.com/display/DVS370/Deploying+a+CAR+File+with+the+Maven+Plug-In.
When executing command "mvn clean install" on my ESB Config Project, I get this error :
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory ([ESB Config Project Path]\target\capp).
Please verify you invoked Maven from the correct directory. -> [Help 1]
Indeed, the install goal is configured to be executed in "target/capp" directory :
<directory>target/capp</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<extensions>true</extensions>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>clean</argument>
<argument>install</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
...
Then I tried to create a "Maven Multi Module Project", as suggested here : maven build for WSo2 artifacts, but I did not found any solution to make it work :
following the steps from this documentation (https://docs.wso2.com/display/DVS310/Using+Maven+with+Developer+Studio?src=search), I created a "Maven Multi Module Project", and selected my Config, Resources and Composite projects as children. Then I launched the "mvn clean install" command, but still getting the error on ESB Config Project (no POM in target/capp folder).
Actually, I just did not found any information about these errors, and do not understand why the WSO2 documented solution did not work for me.
Does anyone have a suggestion about that ? How does WSO2 Developer Studio generate the .car file ?
Thanks

I found another answer for this problem. The exec-maven-plugin version seems to be buggy. The WSO2 Developer Studio 3.7.0 add a buggy version (1.2) when creating the project. You just have to change the artifact from:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
to:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
See this as a complementary information:
exec-maven-plugin says cannot run specified program, even though it is on the PATH

I finally succeded in generating a .car file and creating a maven multi module project.
I was trying to create all my maven projects with WSO2 Developer Studio 3.7.0, although the sample said to use version 3.2.0. As the WSO2's maven plugins versions change, it now works fine for me, executing maven install with plugin v2.0.4.
And a maven multi module project is finally just a maven project with modules, so it is OK.

Related

OWASP dependency-check-maven: Why OSSIndex is called although <ossindexAnalyzerEnabled> is false?

We have several projects where we use the OWASP dependency-check-maven plugin. The plugin is defined in the build/plugins section; either with goal "check" or "aggregate". Latter in the parent pom for multi module projects.
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>7.2.1</version>
<configuration>
<formats>HTML,JSON</formats>
<cveValidForHours>168</cveValidForHours>
<ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
</configuration>
<executions>
<execution>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
In all we first ran in the problem that we couldn't access OSSIndex of Sonatype (we have no account there). We got this error (check is performed by Jenkins):
[ERROR] AnalysisException: OSS Index access forbidden
[ERROR] caused by TransportException: Unexpected response; status: 403
After some research we added <ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled> to our poms.
This solved the problem for all projects but the two multi module projects. Jenkins still received the above mentioned error.
Locally all runs smoothly.
We start the check with mvn clean org.owasp:dependency-check-maven:aggregate (or with "check" as goal).
Why is the OSS Index still called by our multi module projects although it should not be called according to the configuration?
===
In a first approach we defined the dependency-check-maven plugin for the multi module projects in a separate profile in the section reporting/plugins (same plugin configuration as above).
We started the check with mvn site -Pcheck-dependencies -P!default.
More strangely than now, the check of one multi module project didn't try to connect to OSS Index but the check of the other multi module project did.
After moving the plugin definition to the build/plugins section we got rid of this problem. But now both still tries to connect to OSSIndex.

Vaadin 8 + AudioVideo Addon: "Failed to load the widgetset"

I added the AudioVideo Addon to my Vaadin 8 (version 8.7.2, Maven 3, Tomcat) project and everything woks fine in my Eclipse development environment (I did run Maven clean install). But if I export the WAR file to the deployment server the app fails to start with the following error:
Failed to load the widgetset: ./VAADIN/widgetsets/AppWidgetset/AppWidgetset.nocache.js?1556793473728
I found the following in my Maven POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude an unnecessary file generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
I think I need to change something in the Maven config. I tried the "packagingIncludes" instead of "packagingExcludes" but this did not help.
I would be glad for your help since I cannot do "experiments" on the deployment server.
How do I have to configure Maven or what else do I have to do to get the following folder from the eclipse depolyment environment into my exported WAR file?
myApp\target\myApp-0.0.1-SNAPSHOT\WEB-INF\classes\VAADIN\widgetsets\AppWidgetset

Using maven-deploy-plugin to deploy Eclipse product

I am trying to deploy an Eclipse product to Nexus repository. I am somewhat successful, but still get some errors that I am not sure how to handle.
I am using maven-deploy-plugin in the feature (F) that builds product:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>snapshots</repositoryId>
<packaging>zip</packaging>
<generatePom>true</generatePom>
<url>http://repo:8081/nexus/content/repositories/snapshots</url>
<groupId>my.group</groupId>
<artifactId>my.artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<file>
target/products/product.zip
</file>
</configuration>
</execution>
</executions>
</plugin>
I execute 'mvn clean install' to build the product and then 'mvn deploy' on F. If I do that then I get error
Exception while publishing product /home/akravets/dev/workspaces/trunk/my.repository.feature/myProduct.product: publishing result: [Included element my.product.feature.feature.group 8.0.1.R20180301-1431 is missing. Cannot determine filter for requirement to this element.] -> [Help 1]
I've read discussions about this issue, but nothing seems relevant to my issue because I don't have any defined deploy phases besides the one in maven-deploy-plugin.
If I change phase of maven-deploy-plugin to 'install' I get almost satisfactory results. The zip file and generated pom get deployed to repository, but the build fails with error
product.qualifier-p2artifacts.xml. Return code is: 400, ReasonPhrase: Bad Request.
Why does this file even gets considered to be deployed to repository when it's not in file element of maven-deploy-plugin and it's not in the directory structure where zip file is: target/ vs target/product/product.zip? Is this because maven-deploy-plugin is executed during the install phase and it picks up all generated resources as candidates for deployment?
I simply recommend you to use Maven-Tycho to deploy Eclipse RCP product.Tycho determines the dependencies of a plug-in via the MANIFEST.MF file of the plug-in and fetches the required plugins-bundles through the online repositories.
You can check this git repository as an example; rcp - tycho

How to move my own archive file from Jenkins system to artifactory

Thanks in advance! I am new to Jenkins and Maven. Please clarify my query for better understanding.
After the build war getting deployed from Jenkins system to Artifactory location (created under the tags <distributionManagement>/<snapshotRepository> in parent pom.xml). How this is happening without any scripts configured in Jenkins?
Can I do the same for my own archive file to place in Artifactory from Jenkins system after the build? I exposed some jars and getting archived in Jenkins system during the build and expecting same to be placed in Artifactory after the build same as how war is getting placed in Artifactory.
PLugin details for deploy:
I have many webapps and parent/super pom.xml.All wars are getting deployed in artifactory repository.Now looking for solution to deploy common folder also (ProvidedDependencies_${version} - Created during build time) .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>/ProvidedDependencies_${version}</file>
</configuration>
</plugin>
Invoking mvn deploy deploys the artifact(s) that has (or have) been built during the current run to your local repository, Artifactory in your case. See Introduction to the Build Lifecycle.
A Jenkins Maven 2/3 project or a Free-style software project with an appropriate build step can be configured to invoke mvn deploy.

Generated project with gwt-maven-plugin : eclipse

I created a GWT project with
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.0
Imported the project in eclipse juno.
First error I get is this :
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:gwt-maven-
plugin:2.5.0:i18n (execution: default, phase: generate-sources)
In the pom file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see
gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>dashboard.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.farheap.jsi.dashboard.client.Messages</i18nMessagesBundle>
</configuration>
Also the code contains a GreetingServiceAsync that can not be found.
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
You have two options:
You can add special (non-trivial) org.eclipse.m2e:lifecycle-mapping plugin
configuration to your POM. See here: Why am I receiving a "Plugin execution not covered by lifecycle configuration with GWT" error?
Or mark this issue as to be ignored in Eclipse POM editor, and then call mvn gwt:i18n. You can create a handy short cut launcher for it. Eclipse remembers your decisions what to ignore, it stores it into .settings directory permanently for the project.
In course of typical development localization messages do not change often so the second option is usually more convenient and speeds up build.
This applies for most GWT plugin goals! Even GWT compilation is rarely necessary as DevMode works directly with Java code and not generated JavaScrips. So in practice, you have to call all the goals at least once on the beginning and then live weeks without them; basic Eclipse JDT compilation is sufficient.
If you later decide not to use GWT localization framework in your real app then you can remove goal i18n completely from POM. Calling goal i18n generates file {project}/target/generated-sources/gwt/my/code/client/Messages.java which is required by (vanilla) Sample.java.
Also the code contains a GreetingServiceAsync that can not be found.
Run the build mvn install from command line or Eclipse Run as -> Maven install menu.
In case of command line mvn gwt:generateAsync should be enough. This goal generates {project}\target\generated-sources\gwt\my\code\client\GreetingServiceAsync.java and that is what you missing. Eclipse did not do it for you automatically because it was blocked by previous issue of i18n not being covered by lifecycle configuration. So yes, issues you mention are correlated.

Resources