How to make REST api call from React app bundled into Spring boot using frontend-maven-plugin? - reactjs

I create a spring boot project and added a react app (created using create react-app) into it. I want to bundle the REST Api and the frontend in single build (fat jar).
Created spring boot web project, at the root added the frontend folder containing the react code. Here is the plugins inside pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>ppa-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ppa-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<frontend-src-dir>${project.basedir}/src/main/frontend</frontend-src-dir>
<node.version>v15.7.0</node.version>
<npm.version>7.14.0</npm.version>
<frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<yarnVersion>${npm.version}</yarnVersion>
<workingDirectory>frontend</workingDirectory>
<installDirectory>${project.build.directory}</installDirectory>
</configuration>
<executions>
<execution>
<id>install-frontend-tools</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm-install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>build-frontend</id>
<goals>
<goal>npm</goal>
</goals>
<phase>compile</phase>
<configuration>
<arguments>run-script build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>frontend/build</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is the github repo link
The project is running on 8087 and http://localhost:80807 does render the App.js. But inside that I made an api call to http://localhost:8087/api/audits which is returning 404 error. I though the Rest controller can be used like this.
What am I doing wrong here?
#EnableWebMvc does expose the Rest endpoint but then the App.js content is not served by the build.

You were right, im sorry. I just cloned your repo and tried. It does just work. Response Code 200 with empty array.
Btw: you do not need the cors configuration. It is only needed if the frontend would be served by another webserver. But when deploying it alongside your spring in a fat-jar - its not necessary since it is not doing cors calls since its the same host.
I just clicked in to the repo and saw your front-end code. The path u
are querying within axios is just
axios.get("/audits")
but has to be
axios.get("/api/audits")
since the controller is annotated with a corresponding
RequestMapping.
#RequestMapping("/api")

Related

Gatling : Scala - Could not find or load main class Engine

I am getting error Could not find or load main class Engine while running the simulation through command line. I used below command to create the jar file.
mvn clean scala:compile assembly:single package
Folder Structure
src
test
resources
scala
testrunner
testsimuation1.scala
Engine
IDEPathHelper
Recorder
Maven - 3.6.3
Intellij - 2021.1
Scala - 2.13.10
Gatling - 3.9.0
JDK - 1.8
Below is the POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>io.gatling.demo</groupId>
<artifactId>gatling-maven-plugin-demo-scala</artifactId>
<version>3.9.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling.version>${project.version}</gatling.version>
<gatling-maven-plugin.version>4.2.9</gatling-maven-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<scala-maven-plugin.version>4.8.0</scala-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-mvn-plugin.version}</version>
<configuration>
<configFolder>src/test/resources</configFolder>
<simulationsFolder>src/test/scala</simulationsFolder>
<resultsFolder>src/results</resultsFolder>
<simulationClass>testrunner.testsimuation1</simulationClass>
<jvmArgs>
<jvmArg>-Dsimulation=testsimuation1</jvmArg>
<jvmArg>-Xmx6g</jvmArg>
<jvmArg>-Xms2g</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.4.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>io.gatling.app.Gatling</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I tried moving src/test -> src/main but it threw the compilation error. Using this tool for the first time and struggling to resolve the issues.
I tried few solutions from other threads. It didn't help.
Thanks
The Engine class is only supposed to be used as a helper to launch with a "Right Click" when using your IDE.
Using this tool for the first time and struggling to resolve the issues.
You're using maven. The way you're supposed to be running Gatling with maven is to run mvn gatling:test, see gatling-maven-plugin's documentation.
Whatever else you're doing with maven-assembly-plugin is custom development, not really related to Gatling.
Note: if you're looking for handling Gatling deployments, Gatling Enterprise is an option.

How can I correctly install the extend QrScanner

I already installed the extend, but the documentation says that I have to reload the app (I've tried everything and can't do it), before it was only necessary to refresh the CN1Libs, how should I do it now?
private void lectorCodigoQR() {
if (CodeScanner.isSupported()) {
CodeScanner.getInstance().scanQRCode(new ScanResult() {
#Override
public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
// Mostrar
}
#Override
public void scanCanceled() {
System.out.println("cancelled");
}
#Override
public void scanError(int errorCode, String message) {
System.out.println("err " + message);
}
});
} else {
Dialog.show("Error", "Su dispositivo no soporta el lector de QR", "Continuar", null);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.innova507.taxi507</groupId>
<artifactId>taxi507</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.innova507.taxi507</groupId>
<artifactId>taxi507-common</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- Add your cn1lib dependencies to this section -->
<dependencies>
<dependency>
<groupId>com.codenameone</groupId>
<artifactId>codenameone-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>taxi507-cn1-codescan</artifactId>
<groupId>com.innova507.taxi507</groupId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
<!-- INJECT DEPENDENCIES -->
</dependencies>
<!-- The following are profiles to cover special cases -->
<profiles>
<!-- A profile to install Codename One support libraries to your home directory
if they aren't installed yet. -->
<profile>
<id>install-codenameone</id>
<activation>
<file>
<missing>${user.home}/.codenameone/guibuilder.jar</missing>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="install-cn1">
<available file="${user.home}/.codenameone/guibuilder.jar" property="codenameone.present"/>
<mkdir dir="${user.home}/.codenameone"/>
<mkdir dir="${project.build.directory}/codenameone/tmpProject"/>
<get src="https://www.codenameone.com/files/updates/UpdateCodenameOne.jar"
dest="${user.home}/UpdateCodenameOne.jar"
skipexisting="true"/>
<java jar="${user.home}/UpdateCodenameOne.jar" fork="true">
<arg value="${project.build.directory}/codenameone/tmpProject"/>
<arg value="force"/>
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- A profile to add kotlin support. Activated if the src/main/kotlin
directory exists -->
<profile>
<id>kotlin</id>
<activation>
<file>
<!-- To enable Kotlin, add the following file to the project base dir -->
<exists>${basedir}/src/main/kotlin</exists>
</file>
</activation>
<properties>
<kotlin.version>1.3.72</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-annotations-jvm -->
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
</dependency>
<dependency>
<groupId>com.codenameone</groupId>
<artifactId>java-runtime</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/codenameone_settings.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
<args>
<arg>-no-reflect</arg>
<arg>-no-jdk</arg> <!-- No JDK -->
</args>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
<args>
<arg>-no-reflect</arg>
<arg>-no-jdk</arg> <!-- No JDK -->
</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>javase</id>
<activation>
<property>
<name>codename1.platform</name>
<value>javase</value>
</property>
</activation>
<properties>
<codename1.targetPlatform>javase</codename1.targetPlatform>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<longClasspath>true</longClasspath>
<arguments>
<argument>-Xmx1024M</argument>
<!--<argument>-Xdebug</argument>
<argument>-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n</argument>-->
<argument>-classpath</argument>
<classpath />
<argument>${exec.mainClass}</argument>
<argument>${cn1.mainClass}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!--
For running in simulator in process use:
mvn cn1:java -P simulator
Fro running in simulator in forked process use:
mvn cn1:simulator -P simulator
-->
<id>simulator</id>
<properties>
<codename1.targetPlatform>javase</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending iOS debug builds use:
mvn cn:build -P ios-debug
-->
<id>ios-debug</id>
<properties>
<!-- Build server target type -->
<codename1.targetType>iphone</codename1.targetType>
<!-- Used for identifying native interfaces. Should match correct subdirectory of native -->
<codename1.targetPlatform>ios</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending iOS debug builds use:
mvn cn:build -P ios-release
-->
<id>ios-release</id>
<properties>
<!-- Build server target type -->
<codename1.targetType>iphone</codename1.targetType>
<codename1.production>true</codename1.production>
<!-- Used for identifying native interfaces. Should match correct subdirectory of native -->
<codename1.targetPlatform>ios</codename1.targetPlatform>
<codename1.appStoreBuild>true</codename1.appStoreBuild>
</properties>
</profile>
<profile>
<!--
For sending Javascript builds use:
mvn cn:build -P javascript
-->
<id>javascript</id>
<properties>
<codename1.targetType>javascript</codename1.targetType>
<codename1.targetPlatform>javascript</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending Android builds use:
mvn cn:build -P android
-->
<id>android</id>
<properties>
<codename1.targetType>android</codename1.targetType>
<codename1.targetPlatform>android</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending Windows UWP builds use:
mvn cn:build -P uwp
-->
<id>uwp</id>
<properties>
<codename1.targetType>windows</codename1.targetType>
<codename1.targetPlatform>win</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending Windows desktop builds use:
mvn cn:build -P windows
-->
<id>windows</id>
<properties>
<codename1.targetType>desktop_windows</codename1.targetType>
<codename1.targetPlatform>javase</codename1.targetPlatform>
</properties>
</profile>
<profile>
<!--
For sending Mac Desktop builds use:
mvn cn:build -P mac
-->
<id>mac</id>
<properties>
<codename1.targetType>desktop_macosx</codename1.targetType>
<codename1.targetPlatform>javase</codename1.targetPlatform>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/codenameone_settings.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.codenameone</groupId>
<artifactId>codenameone-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-gui-sources</id>
<phase>process-sources</phase>
<goals>
<goal>generate-gui-sources</goal>
</goals>
</execution>
<execution>
<id>cn1-process-classes</id>
<phase>process-classes</phase>
<goals>
<goal>compliance-check</goal>
<goal>css</goal>
<!--<goal>compile-javase-sources</goal>-->
</goals>
</execution>
<execution>
<id>attach-test-artifact</id>
<phase>test</phase>
<goals>
<goal>attach-test-artifact</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have included an image of the tree where it shows the menu on the pom and I don't see a way to update it. I am also including the pom.xml (if it has the extension included)
https://drive.google.com/drive/folders/1LVBZPMCTTTEZxEYfwrh3S2_fPzyktTiN
This is an answer from Steve Hannha:
I just created a fresh project in the cn1 intializr with "NetBeans" selected as the IDE.
Opened project in NetBeans 12.3 on Windows 10.
Opened CN1 Settings.
Installed Codename One Scanner library.
Initially the text editor wasn't giving me any autocomplete or error-underlines on anything, even from cn1 core classes.
I right-clicked on the "common" module, and selected "Resolve Project Problems"
I got a dialog with errors like "Some dependency artifacts are not in the local repository".
When I pressed the "Resolve..." button in that dialog, it downloaded the dependencies and things started to magically work.

statefun is giving org.apache.flink.client.program.ProgramInvocationException classloader.parent-first-patterns.additional;

I am running stateful-fun 2.0 basic hello job with the following command
./bin/flink run -c org.apache.flink.statefun.flink.core.StatefulFunctionsJob ./stateful-sun-hello-java-1.0-SNAPSHOT-jar-with-dependencies.jar
and my POM.xml is
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>stateful-sun-hello-java</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>statefun-sdk</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>statefun-flink-distribution</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>statefun-kafka-io</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<defaultGoal>clean generate-sources compile install</defaultGoal>
<plugins>
<!-- compile proto file into java files. -->
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.6.0.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<includeMavenTypes>direct</includeMavenTypes>
<inputDirectories>
<include>src/main/protobuf</include>
</inputDirectories>
<outputTargets>
<outputTarget>
<type>java</type>
<outputDirectory>src/main/java</outputDirectory>
</outputTarget>
<outputTarget>
<type>grpc-java</type>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.15.0</pluginArtifact>
<outputDirectory>src/main/java</outputDirectory>
</outputTarget>
</outputTargets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>org.apache.flink.statefun.flink.core.StatefulFunctionsJob</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
It is giving the following exception
The program finished with the following exception:
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Invalid configuration: classloader.parent-first-patterns.additional; Must contain all of org.apache.flink.statefun, org.apache.kafka, com.google.protobuf
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:335)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:205)
at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:138)
at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:662)
at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:210)
at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:893)
at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:966)
at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30)
at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:966
Please suggest how to fix this.
You have to add below configuration parameters to your flink-conf.yaml file.
classloader.parent-first-patterns.additional: org.apache.flink.statefun;org.apache.kafka;com.google.protobuf
jobmanager.scheduler: legacy
https://ci.apache.org/projects/flink/flink-statefun-docs-release-2.0/deployment-and-operations/packaging.html#flink-jar --> Official document says:
The following configurations are strictly required for running StateFun application.
classloader.parent-first-patterns.additional: org.apache.flink.statefun;org.apache.kafka;com.google.protobuf
We need to add this jar
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>statefun-flink-distribution</artifactId>
<version>2.1.0</version>
</dependency>
Package a statefun job to submit to an existing Flink cluster deployment style is no longer mentioned in statefun 3.1 documents. Is this deployment style still possible or supported? If so, where should the module.yaml file be packaged?

How to use Apache Camel "direct" in quarkus camel

I have added io.quarkus:quarkus-camel-core to my application, but the direct start does not work within native-image. If I run quarkus in JVM, then it works.
There are projects in Github (https://github.com/apache/camel-quarkus/tree/master/extensions/direct) that somehow indicate that there is an extension planned in future, but it is not officially supported.
How can I make it run with minimal effort, e.g. create own extension project only for direct. If I am adding the existing projects to my Maven pom, I am getting problems with the different Maven coordinates, and at the end the native build tells me that there are duplicates.
What would be a good way to make the "direct" statement from Camel run in quarkus?
By the way, the native build works, i.e. I get an executable, but the injection of the direct statement does not work:
"org.apache.camel.ResolveEndpointFailedException: Failed to resolve
endpoint: direct://init due to: No component found with scheme:
direct"
Sources:
REST endpoint:
#Path("/hello")
public class GreetingResource {
#GET
#Produces(MediaType.TEXT_PLAIN)
public String hello() {
ExchangeBuilder exchangeBuilder = new ExchangeBuilder(context);
Exchange out = template.send("direct:init", exchangeBuilder.build());
return out.getOut().toString();
}
CamelRouteBuilder:
public class CamelSyncRouteBuilder extends RouteBuilder {
static final String HTTP_ROUTE_ID = "http:camel";
static long[] times = new long[1];
#Override
public void configure() throws Exception {
from("direct:init").routeId(HTTP_ROUTE_ID)
.setHeader(MyOrderService.class.getName(), MyOrderService::new)
.setHeader(Filler.class.getName(), Filler::new).process(fill(Filler.class.getName(), "fill"))
.split(body().tokenize("#"), CamelSyncRouteBuilder.this::aggregate)
.process(stateless(MyOrderService.class.getName(), "handleOrder")).end().to("log:foo?level=OFF");
}
pom.xml:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sap.it.graal</groupId>
<artifactId>getting-started</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<quarkus.version>0.19.1</quarkus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-camel-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
the direct component should work out of the box even without a dedicated extension, as example it is used to create the integration test for the jdbc component (https://github.com/apache/camel-quarkus/tree/master/integration-tests/jdbc).
Can you share more information about your project and set-up ?
I was facing the same problem because i didn't learn how exactly Camel works. As it said in logs - you have no Component that provides "direct" URI. So you have to add that Component. There is one in Camel Quarkus extensions:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>

Generate Javadoc for OSGi bundle

I'm newbie in OSGi world but I was able to do some Camel and OSGi bundles to do some tasks in a middleware. Everything I made since was a proof of concept, but now I want to refactor some part of my code and I start writing a OSGi bundle who will contain common functionalities shared among other OSGi bundles.
To make it clean, I decide to write comments and use javadoc to get sleek documentation, but I'm stuck with this error:
Error resolving version for plugin
'org.apache.maven.plugins:maven-javadoc-plugin' from the repositories
I was able to run javadoc for another Camel component;
We have a local repository with the dependency maven-javadoc-plugin in;
I add the dependency maven-javadoc-plugin to my project;
I'm running out of ideas why it doesn't work.
Maybe I'm wrong and I using OSGi bundle in a wrong way...
UPDATE
<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>org</groupId>
<artifactId>test</artifactId>
<version>0.0.1</version>
<packaging>bundle</packaging>
<name>uces OSGi Bundle</name>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.test.Activator</Bundle-Activator>
<Export-Package>org.test</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>build-for-felix</id>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>4.0.3</version>
<scope>provided</scope>
</dependency>
<!-- To include a shell:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.shell</artifactId>
<version>0.10.0</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<pathconvert property="plugins.jars" pathsep="${path.separator}">
<path refid="maven.runtime.classpath"/>
<map from="${project.build.directory}${file.separator}classes" to=""/>
</pathconvert>
<pathconvert pathsep=" " property="bundles">
<path path="${plugins.jars}"/>
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="file:modules/*" casesensitive="no"/>
</chainedmapper>
</mapper>
</pathconvert>
<propertyfile file="${project.build.directory}/config.properties">
<entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar"/>
<entry key="org.osgi.framework.bootdelegation" value="*"/>
</propertyfile>
<copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>create-executable-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
</descriptors>
<finalName>${project.build.finalName}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-on-felix</id>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>4.0.3</version>
<scope>provided</scope>
</dependency>
<!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<configuration>
<target>
<property name="vm.args" value=""/>
<pathconvert property="plugins.jars" pathsep="${path.separator}">
<path refid="maven.runtime.classpath"/>
<map from="${project.build.directory}${file.separator}classes" to=""/>
</pathconvert>
<makeurl property="urls" separator=" ">
<path path="${plugins.jars}"/>
<path location="${project.build.directory}/${project.build.finalName}.jar"/>
</makeurl>
<propertyfile file="${project.build.directory}/run.properties">
<entry key="felix.auto.start" value="${urls}"/>
<entry key="felix.auto.deploy.action" value="uninstall,install,update,start"/>
<entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache"/>
<entry key="org.osgi.framework.bootdelegation" value="*"/>
</propertyfile>
<makeurl property="run.properties.url" file="${project.build.directory}/run.properties"/>
<java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
<sysproperty key="felix.config.properties" value="${run.properties.url}"/>
<jvmarg line="${vm.args}"/>
</java>
</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Ok, i finally found my response after digging more deeply in javadoc page (Javadoc documentation) and add these lines into the build section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
</plugin>

Resources