Skip to content

Commit

Permalink
Native build fails when using quarkus-cxf-integration-tracing-opentel…
Browse files Browse the repository at this point in the history
…emetry and quarkus-jdbc-oracle, fix #1697
  • Loading branch information
ppalaga committed Feb 12, 2025
1 parent ea31bbc commit 8ac46e2
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@
<artifactId>quarkus-cxf-rt-features-metrics-deployment</artifactId>
<version>${quarkus-cxf.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management</artifactId>
<version>${quarkus-cxf.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management-deployment</artifactId>
<version>${quarkus-cxf.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-transports-http-hc5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-integration-tracing-opentelemetry</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/integration-tracing-opentelemetry/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-integration-tracing-opentelemetry</artifactId>
Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<module>saaj</module>
<module>santuario-xmlsec</module>
<module>woodstox</module>
<module>rt-management</module>
<module>core</module>
<module>features-logging</module>
<module>features-metrics</module>
Expand Down
43 changes: 43 additions & 0 deletions extensions/rt-management/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management-parent</artifactId>
<version>3.18.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>quarkus-cxf-rt-management-deployment</artifactId>
<name>Quarkus CXF - Runtime Management - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package io.quarkiverse.cxf.rt.management.deployment;

import java.util.function.BiFunction;
import java.util.stream.Stream;

import org.apache.cxf.management.jmx.InstrumentationManagerImpl;
import org.jboss.logging.Logger;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.gizmo.Gizmo;

public class QuarkusCxfRtManagementProcessor {

private static final Logger log = Logger.getLogger(QuarkusCxfRtManagementProcessor.class);

@BuildStep
void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexDependencies) {
Stream.of(
"org.apache.cxf:cxf-rt-management")
.forEach(ga -> {
String[] coords = ga.split(":");
indexDependencies.produce(new IndexDependencyBuildItem(coords[0], coords[1]));
});
}

@BuildStep(onlyIf = NativeBuild.class)
void transfromByteCode(
CombinedIndexBuildItem combinedIndex,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'combinedIndex' is never used.
BuildProducer<BytecodeTransformerBuildItem> bytecodeTransformers) {

/*
* Make InstrumentationManagerImpl.init() a no-op in native mode
* to avoid getting an MBean Server instance in the native image heap
* See https://github.com/quarkiverse/quarkus-cxf/issues/1697
*/
final BytecodeTransformerBuildItem transformation = new BytecodeTransformerBuildItem.Builder()
.setClassToTransform(InstrumentationManagerImpl.class.getName())
.setCacheable(true)
.setVisitorFunction(new NoInitTransformer())
.build();
bytecodeTransformers.produce(transformation);
}

static class NoInitTransformer implements BiFunction<String, ClassVisitor, ClassVisitor> {

@Override
public ClassVisitor apply(String t, ClassVisitor classVisitor) {
return new ClassVisitor(Gizmo.ASM_API_VERSION, classVisitor) {
private boolean initTransformed = false;

@Override
public MethodVisitor visitMethod(int access,
String name,
String descriptor,
String signature,
String[] exceptions) {
if (name.equals("init")
&& descriptor.equals("()V")
&& (access & Opcodes.ACC_PUBLIC) != 0) {
initTransformed = true;
final MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);

return new MethodVisitor(api, mv) {

@Override
public void visitCode() {
/* Replace method body with a single RETURN to make it do nothing */
visitInsn(Opcodes.RETURN);
visitMaxs(0, 0);
visitEnd();

Check warning

Code scanning / CodeQL

Subtle call to inherited method Warning

A
method declared in a superclass
is called instead of a
method with the same signature in an enclosing class
.
}
};
}
return super.visitMethod(access, name, descriptor, signature, exceptions);
}

@Override
public void visitEnd() {
if (!initTransformed) {
throw new IllegalStateException(
InstrumentationManagerImpl.class.getName() + ".init() method not found");
}
super.visitEnd();
}

};
}
}

}
20 changes: 20 additions & 0 deletions extensions/rt-management/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-extensions</artifactId>
<version>3.18.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>quarkus-cxf-rt-management-parent</artifactId>
<name>Quarkus CXF - Runtime Management - Parent</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>

</project>
59 changes: 59 additions & 0 deletions extensions/rt-management/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management-parent</artifactId>
<version>3.18.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>quarkus-cxf-rt-management</artifactId>
<name>Quarkus CXF - Runtime Management</name>
<description>Native support for CXF Runtime Management</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-management</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>extension-descriptor</goal>
</goals>
<phase>compile</phase>
<configuration>
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}
</deployment>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
artifact: ${project.groupId}:${project.artifactId}:${project.version}
name: "Quarkus CXF Runtime Management"
description: "Native support for CXf Runtime Management"
metadata:
unlisted: true
keywords:
- "jmx"
categories:
- "jmx"
guide: "https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/dev/index.html"
status: "stable"
4 changes: 4 additions & 0 deletions extensions/ws-rm/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-ws-security-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-ws-rm</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ FeatureBuildItem feature() {
@BuildStep
void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexDependencies) {
Stream.of(
"org.apache.cxf:cxf-rt-ws-rm",
"org.apache.cxf:cxf-rt-management")
"org.apache.cxf:cxf-rt-ws-rm")
.forEach(ga -> {
String[] coords = ga.split(":");
indexDependencies.produce(new IndexDependencyBuildItem(coords[0], coords[1]));
Expand Down
4 changes: 4 additions & 0 deletions extensions/ws-rm/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-ws-security</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-management</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-rm</artifactId>
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ quarkus.cxf.endpoint."/hello".implementor = io.quarkiverse.cxf.opentelemetry.it.

quarkus.cxf.client.hello.client-endpoint-url = http://localhost:${quarkus.http.test-port}/soap/hello
quarkus.cxf.client.hello.service-interface = io.quarkiverse.cxf.opentelemetry.it.HelloService
quarkus.devservices.enabled=false

0 comments on commit 8ac46e2

Please sign in to comment.