ERROR: Stubs could not be found. Please make sure that spring-cloud-contract:convert was invoked - spring-cloud-contract

Using Spring Cloud Contract 2.1.3.RELEASE with spring-boot 2.1.1.RELEASE, I have added the dependency and plugin per explained in the guide:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
<version>${spring-cloud-contract.version}</version>
<scope>test</scope>
</dependency>
and
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
</plugin>
I have also added under: $rootDir/src/test/resources/contracts:
Groovy file:
package contracts
import org.springframework.cloud.contract.spec.Contract
Contract.make {
name("contract_updateNodeV4")
request {
method 'PUT'
url '/v4/nodes'
headers {
header 'Content-Type': 'application/vnd.org.springframework.cloud.contract.verifier.twitter-places-analyzer.v1+json'
}
body(file("updateNodeV4_request.json"))
}
response {
status OK()
body(file("updateNodeV4_response.json"))
}
}
And corresponding updateNodeV4_request.json and updateNodeV4_response.json (omitting their contents since these are large) valid JSON files.
When running mvn clean install I expected generated tests to be created (and fail for now) per the guide.
Instead I am getting the following error:
[ERROR] Failed to execute goal org.springframework.cloud:spring-cloud-contract-maven-plugin:1.0.0.RELEASE:generateStubs (default-generateStubs) on project xxx: Stubs could not be found: [C:\Users\xxx\git\xxx\target\stubs] .
[ERROR] Please make sure that spring-cloud-contract:convert was invoked

Most likely your contacts are not under the module's src/test/resources/contracts but under the root module's folder. If that's the case you need to tell the plugin that by seeing the contracts dir plugin property

I solved it by moving the plugin:
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
</plugin>
From the root pom.xml to the specific module's pom.xml in which I have created the contracts in. Now it works as expected.

Related

I created a JavaFX App and I get an the following error: "JavaFX runtime components are missing, and are required to run this application" [duplicate]

I'm trying to create a JFX11 self-containing jar using maven dependencies. From the research I've done, it seems the best way to do this is through the maven shade plugin. However, When I run it, I get the this error:
Error: JavaFX runtime components are missing, and are required to run this application
I don't understand why this is happening. What am I messing up? Is there a better way to do this? I've also tried the maven assembly plugin with the same message.
pom file for reference
<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>Application</groupId>
<artifactId>Main</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpaceRunner</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>Application.Main</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>
Application.Main
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Application.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
UPDATE 10/2021
Since JavaFX 16 a warning is displayed when JavaFX doesn't run on the module path, which is the case of an uber/fat jar:
$ java -jar myFatJar-1.0-SNAPSHOT.jar
Oct 02, 2021 1:45:21 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module #14c24f4c'
Also, you get a warning from the shade plugin itself:
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
While these warnings can be initially ignored, there is a reason for them.
As explained in this CSR:
JavaFX is built and distributed as a set of named modules, each in its own modular jar file, and the JavaFX runtime expects its classes to be loaded from a set of named javafx.* modules, and does not support loading those modules from the classpath.
And:
when the JavaFX classes are loaded from the classpath, it breaks encapsulation, since we no longer get the benefit of the java module system.
Therefore, even this widely accepted answer explains how can an uber/fat jar can be created on Maven projects, its use is discouraged, and other modern alternatives to distribute your application, like jlink, jpackage or native-image, should be used.
ORIGINAL ANSWER
This answer explains why a fat/uber jar fails on JavaFX 11. In short:
This error comes from sun.launcher.LauncherHelper in the java.base module. The reason for this is that the Main app extends Application and has a main method. If that is the case, the LauncherHelper will check for the javafx.graphics module to be present as a named module. If that module is not present, the launch is aborted.
And already proposes a fix for Gradle.
For Maven the solution is exactly the same: provide a new main class that doesn't extend from Application.
You will have new class in your application package (bad name):
// NewMain.java
public class NewMain {
public static void main(String[] args) {
Main.main(args);
}
}
And your existing Main class, as is:
//Main.java
public class Main extends Application {
#Override
public void start(Stage stage) {
...
}
public static void main(String[] args) {
launch(args);
}
}
Now you need to modify your pom and set your main class for the different plugins:
<mainClass>application.NewMain</mainClass>
Platform-specific Fat jar
Finally, with the shade plugin you are going to produce a fat jar, on your machine.
This means that, so far, your JavaFX dependencies are using a unique classifier. If for instance you are on Windows, Maven will be using internally the win classifier. This has the effect of including only the native libraries for Windows.
So you are using:
org.openjfx:javafx-controls:11
org.openjfx:javafx-controls:11:win
org.openjfx:javafx-graphics:11
org.openjfx:javafx-graphics:11:win <-- this contains the native dlls for Windows
org.openjfx:javafx-base:11
org.openjfx:javafx-base:11:win
Now, if you produce the fat jar, you will bundle all those dependencies (and those other regular third party dependencies from your project), and you will be able to run your project as:
java -jar myFatJar-1.0-SNAPSHOT.jar
While this is very nice, if you want to distribute you jar, be aware that this jar is not cross-platform, and it will work only on your platform, in this case Windows.
Cross-Platform Fat Jar
There is a solution to generate a cross-platform jar that you can distribute: include the rest of the native libraries of the other platforms.
This can be easily done, as you just need to include the graphics module dependencies for the three platforms:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>mac</classifier>
</dependency>
</dependencies>
Size
There is a main issue with this approach: the size. As you can see in this other answer, if you use the WebView control, you will be bundling around 220 MB due to the WebKit native libraries.

How do I get Alfresco to use the alfresco-simple-content-stores plugin?

I've been trying to include the alfresco-simple-content-stores library (https://github.com/Acosix/alfresco-simple-content-stores) with Alfresco Community Edition, and it doesn't appear to be working. I've followed the documentation as best as I can, but I think I must be missing a step because my configuration appears to be completely ignored and there is no indication that it is running. I've done the following:
First, following this documentation (https://docs.alfresco.com/community/tasks/amp-install.html) I tried installing the amp using Alfresco mmt. That failed with the following message:
10250001 An error was encountered during deployment of the AMP into the WAR: 10250000 The following modules must first be installed: [acosix-utility-core:1.0.3.1-*]
However, no such artifact seems to exist.
As I couldn't get past that speed bump, I went down the following path:
I generated a keystore and a master key, referenced below in step 4
I included the following dependency in my alfresco/war/pom.xml (1.0.1.TEST is my locally compiled version of alfresco-simple-content-stores)
<dependency>
<groupId>de.acosix.alfresco.simplecontentstores</groupId>
<artifactId>de.acosix.alfresco.simplecontentstores.repo</artifactId>
<version>1.0.1.TEST</version>
<type>amp</type>
</dependency>
I copied the artifact to the Tomcat directory in my Dockerfile
COPY ./war/target/de.acosix.alfresco.simplecontentstores.repo-1.0.1.TEST.amp ${TOMCAT_DIR}/amps
I defined the following properties in my alfresco-global.properties
simpleContentStores.enabled=true
simpleContentStores.customStores=myEncryptingStore,defaultTenantFileContentStore
simpleContentStores.rootStore=myEncryptingStore
simpleContentStores.customStore.myEncryptingStore.type=encryptingFacadeStore
simpleContentStores.customStore.myEncryptingStore.ref.backingStore=defaultTenantFileContentStore
simpleContentStores.customStore.myEncryptingStore.value.keyStorePath=classpath:../keystore/keystore.jks
simpleContentStores.customStore.myEncryptingStore.value.keyStorePassword=masterkeystore
simpleContentStores.customStore.myEncryptingStore.value.masterKeyAlias=ssl
simpleContentStores.customStore.myEncryptingStore.value.masterKeyPassword=alfkeystore
simpleContentStores.customStore.myEncryptingStore.value.masterKeyStoreId=alfkeystore
Despite all of this, files continue to be stored unencrypted and I see no indication that anything has failed. I doubt that this library would fail silently, so I'm left to assume that I've missed some step required to make Alfresco use this plugin.
Any ideas?
Edit:
In response to a comment, here is the abbreviated pom of my alfresco/war project:
<dependencies>
...
<dependency>
<groupId>de.acosix.alfresco.utility</groupId>
<artifactId>de.acosix.alfresco.utility.share</artifactId>
<version>1.0.2.1</version>
<type>amp</type>
</dependency>
<dependency>
<groupId>de.acosix.alfresco.utility</groupId>
<artifactId>de.acosix.alfresco.utility.repo</artifactId>
<version>1.0.2.1</version>
<type>amp</type>
</dependency>
<dependency>
<groupId>de.acosix.alfresco.simplecontentstores</groupId>
<artifactId>de.acosix.alfresco.simplecontentstores.repo</artifactId>
<version>1.0.1.PST</version>
<type>amp</type>
</dependency>
...
</dependencies>
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay />
<overlay>
<groupId>${alfresco.groupId}</groupId>
<artifactId>${alfresco.share.artifactId}</artifactId>
<type>war</type>
<excludes />
</overlay>
<!-- other AMPs -->
<overlay>
<groupId>de.acosix.alfresco.utility</groupId>
<artifactId>de.acosix.alfresco.utility.repo</artifactId>
<type>amp</type>
</overlay>
<overlay>
<groupId>de.acosix.alfresco.utility</groupId>
<artifactId>de.acosix.alfresco.utility.share</artifactId>
<type>amp</type>
</overlay>
<overlay>
<groupId>de.acosix.alfresco.simplecontentstores</groupId>
<artifactId>de.acosix.alfresco.simplecontentstores.repo</artifactId>
<type>amp</type>
</overlay>
</overlays>
</configuration>
</plugin>
...
</plugins>
...
</build>
Now with that pom configuration, the maven install output shows as follows (shortened to hide irrelevant path information):
[INFO] Processing overlay [ id de.acosix.alfresco.utility:de.acosix.alfresco.utility.repo]
[WARNING] Skip unpacking dependency file [.../.m2/repository/de/acosix/alfresco/utility/de.acosix.alfresco.utility.repo/1.0.2.1/de.acosix.alfresco.utility.repo-1.0.2.1.amp with unknown extension [amp]
[INFO] Processing overlay [ id de.acosix.alfresco.utility:de.acosix.alfresco.utility.share]
[WARNING] Skip unpacking dependency file [.../.m2/repository/de/acosix/alfresco/utility/de.acosix.alfresco.utility.share/1.0.2.1/de.acosix.alfresco.utility.share-1.0.2.1.amp with unknown extension [amp]
[INFO] Processing overlay [ id de.acosix.alfresco.simplecontentstores:de.acosix.alfresco.simplecontentstores.repo]
[WARNING] Skip unpacking dependency file [.../.m2/repository/de/acosix/alfresco/simplecontentstores/de.acosix.alfresco.simplecontentstores.repo/1.0.1.PST/de.acosix.alfresco.simplecontentstores.repo-1.0.1.PST.amp with unknown extension [amp]

Getting bundle exception while deploying app to Apache Karaf

I'm developing simple application to demonstrate use of Apache Karaf.I have developed one simple maven based dynamic web project in eclipse.Now I want to deploy it in apache karaf.Following is that code-
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class DemoActivator implements BundleActivator {
#Override
public void start(BundleContext bundleContext) throws Exception {
System.out.println("STARTING DEMO: hello, world");
}
#Override
public void stop(BundleContext bundleContext) throws Exception {
System.out.println("STOPPING DEMO");
}
}
Dependancies in POM.Xml
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi_R4_core</artifactId>
<version>1.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi_R4_compendium</artifactId>
<version>1.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
MANIFEST.MF
Bundle-SymbolicName: osgi-example
Bundle-Version: 1.0.0.SNAPSHOT
Import-Package:com.psl.demo;version="1.0.0.SNAPSHOT",org.osgi.framework
Export-Package: com.psl.demo;version="1.0.0.SNAPSHOT"
Bundle-Activator: com.psl.demo.DemoActivator
Given path of custom MANIFEST file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Now whenever I'm trying to install application in karaf using-
install mvn:com.psl/osgi-demo-next/1.0.0-SNAPSHOT
Im getting error as-
Error executing command: Error installing bundles: Unable to install
bundle mvn:com.psl.demo/osgi-example/1.0.0.SNAPSHOT:
org.osgi.framework.BundleException: Unable to cache bundle:
mvn:com.psl.demo/osgi-example/1.0.0.SNAPSHOT
Any solution for this? TIA
This error is coming because maven coordinates in bundle install command are not correct. Following is syntax for the same:
karaf#root()> bundle:install mvn:<group-id>/<artifact-id>/<version>
Please validate the content of pom.xml and accordingly put values in above command.
From simplicity perspective, you could check local maven repository to find bundle location and accordingly put values in above bundle install command.

m2e-webby and provided dependencies with jetty

I have a maven project with some provided dependencies and I am trying to run the application with webby but it give me a java.lang.ClassNotFoundException exception.
In this link it says: "Webby allows to initialize a launch configuration from the configuration of the jetty-maven-plugin".
My question is it is possible to also pass the dependencies defined in the jetty-maven-plugin? If not how can webby resolve the provided dependencies?
Want I did was to create a profile in the pom project:
<profile>
<id>webby</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>
</dependency>
</dependencies>
</profile>
And then right click on the project -> properties -> Maven and added webby to the Active Maven Profiles

How to build flex resource module in flexmojos4.x

I use flexmojos plugin to manage my flex app. At first, I use flexmojos3.8, the following is fragment to create seperate resource module. If my app support en_US, zh_Ch, I can get MainApp_en_US.swf and MainApp_zh_CN.swf. In my app, I can load proper resource module according to browser's language.
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
</dependencies>
<configuration>
<sourceFile>MainApp.mxml</sourceFile>
<resourceBundlePath>
src/main/flex/locale/{locale}
</resourceBundlePath>
<runtimeLocales>${locales}</runtimeLocales>
<mergeResourceBundle>false</mergeResourceBundle>
<runtimeLocaleOutputPath>
/{contextRoot}/MainApp_{locale}.{extension}
</runtimeLocaleOutputPath>
<rslUrls>
<url>/{contextRoot}/rsl/{artifactId}.{extension}</url>
</rslUrls>
</configuration>
</plugin>
But when I upgrade flexmojos 4.0-RC2, I find the changes are big. The config changes to
.....
MainApp.mxml
src/main/flex/locale/{locale}
<localesRuntime>
<locale>en_US</locale>
<locale>fr_FR</locale>
<locale>zh_CN</locale>
</localesRuntime>
//Output resource module to current pathe (/target)
<localesOutputPath>
/
</localesOutputPath>
//Define your resource moudle name pattern
<resourceBundleNames>
MainApp_{locale}
</resourceBundleNames>
.....
</configuration>
It works after lots of trying. The last config like above.

Resources