Quarkus Eclipse Plugin

121 views
Skip to first unread message

Kum Verna

unread,
Aug 3, 2024, 2:44:00 PM8/3/24
to biahumphboumis

Select application.properties file -> right click and observe the default selected editor . the above mentioned stack overflow exception happen when the file name is 'application.properties' file and the defualt selected editor for properties file is 'Generic Text Editor'

Further this is happening when the file name is application.properties. If the file name is changed to some thing else for ex. application1.properties, the above issue is not seen (Microprofile properties collector stackover flow) But in this case the default selected text editor is some thing other than 'Generic Text Editor' ( in my case Jobss tools properties editor).

An internal error occurred during: "MicroProfile properties collector".
'void org.eclipse.jdt.internal.core.search.JavaSearchScope.add(org.eclipse.jdt.internal.core.JavaProject, int, java.util.HashSet)'

I have the exact same error, even when I use the "Generic Text Editor" or "Text Editor". Every key I type leads to this error. If I'm lucky I can perhaps type 2 or 3 characters before the error pops up, but it's effectively impossible to edit application.properties files. I've tried to remove the content type but it's locked. The only thing that worked was removing the Quarkus Tools plugin completely.

I've tried to debug my application after updating my Eclipse version and Quarkus Tools version, but it doesn't work anymore. The application runs but simply does not debug, it doesn't stop on the breakpoints.

In this tutorial, we'll see how to develop and integrate a very simple Quarkus 2 application with Kubernetes Maven Plugin (Eclipse JKube) to publish a native GraalVM image into Docker Hub and deploy it on Kubernetes.

In the first part, I describe how to build a very simple Quarkus application. Next, I describe how to build a Quarkus native executable with GraalVM. Finally, I show how to integrate the project with Kubernetes Maven Plugin and how to publish the application container images into Docker Hub and deploy them to Kubernetes.

However, if you don't have Maven installed, or if on the other hand, you prefer an interactive graphical user interface, you can navigate to code.quarkus.io to customize and download a bootstrapped project with your specific requirements.

As I already explained, the application will serve a random quote each time a user performs a request to an endpoint. The application will load these quotes from a JSON file located in the project resources folder. For this purpose, you'll add the file quotes.json to the src/main/resources/quotes/ directory.

Once we've got the resources set up, we can start with the code implementation. The first step is to create a Quote POJO that will be used to map the quotes defined in the JSON file when it's deserialized.

The method getRandomQuote uses an instance of the previously described QuoteService class to get a random quote and return its content in the HTTP response body. In addition, the author of the quote is also added as a Response header.

Jackson JSON deserialization uses reflection to create instances of the target classes when performing reads. Graal native image build requires to know ahead of time which kind of elements are reflectiveley accessed by the program.

Now that we've completed adapting the application to be fully GraalVM compatible, we can perform the build in native mode. If Graal VM with native-image support is available in our system, we can simply run the following command:

The configuration is as straightforward as adding a entry with groupId, artifactId & version to indicate that we want to use the Kubernetes Maven Plugin. In many cases, this may just be enough, as the plugin has a Zero-Config mode that takes care of defining most of the settings for us by analyzing the project's configuration inferring the recommended values.

First, we need to remove the boiler-plate Dockerfiles that Quarkus provides for us in the src/main/docker directory. Kubernetes Maven Plugin infers all of this configuration from the project, so there's no need to maintain these files and we can safely remove them.

Eclipse JKube's Zero-Config mode uses Generators and Enrichers which provide opinionated defaults. For this project, the only common setting we need to take care of is the one related to the authorization for the Docker Hub registry. In this case, we are configuring JKube to read the push credentials from the DOCKER_HUB_USER and DOCKER_HUB_PASSWORD environment variables.

In Quarkus 2, fast-jar is the default packaging for the JVM mode. This means, that unless stated otherwise (e.g. Maven Profile), the mvn package command will output the necessary files for this mode. Since I'm going to publish these images to Docker Hub, I will name this image marcnuri/kubernetes-maven-plugin-quarkus:jvm.

In order to tweak JKube's Quarkus generator opinionated default for the image name, we need to set the jkube.generator.name property. We can achieve this by adding the following entry to the pom.xml global properties section:

Regardless of the packaging mode we choose (JVM or native), pushing the image into Docker Hub's registry is as easy as running the following command (provided that we have the required environment variables available):

The main advantage of JKube is that you don't need to deal with YAML and configuration files yourself. The plugin takes care of generating everything for you, so you only need to run the following command:

This is a very simple project, so I didn't create an Ingress to expose the service which means that now the application remains inaccessible. I'll cover the process of creating an Ingress in an additional post. However, if you are running the application in minikube and want to access your application, with JKube is as easy as running:

In this post, I've shown you how to develop and integrate a very simple Quarkus 2 application with GraalVM native image support and the Kubernetes Maven Plugin. In the first section, I demonstrated how to bootstrap the application and create a very simple REST endpoint that will return a random quote for each request. Next, I showed you how to configure the application to be fully compatible with GraalVM to be able to generate a native binary. Finally, I showed you how to configure Kubernetes Maven Plugin to be able to build container images and push them into Docker Hub's registry. In addition, I showed you how simple it is to deploy your application to Kubernetes using Eclipse JKube.

Projects can be generated at code.quarkus.io. All of the Camel Quarkus extensions can be found under the 'Integration' category. Use the 'search' field to help with finding extensions that you are interested in.

Simply select the component extensions that you want to work with and click the 'Generate your application' button to download a basic skeleton project. There is also the option to push the project directly to GitHub.

Quarkus has plugins for most of the popular development IDEs. They provide Quarkus language support, code / config completion, project creation wizards and much more. The plugins are available at each respective IDE marketplace.

This command compiles the project, starts your application and lets the Quarkus tooling watch for changes in your workspace. Any modifications in your project will automatically take effect in the running application.

isEnabled() - determines whether the telemetry backend is functioning correctly. This can mean always returning true, or have more complex checks, for example, returning false when a connection property is missing.

Create a container image based on this code and expose it as a deployment in OpenShift in the eclipse-che namespace. The code for the example telemetry server is available at telemetry-server-example. To deploy the telemetry server, clone the repository and build the container:

Since org.my.group.AnalyticsManager and org.my.group.MainConfiguration are alternative beans, specify them using the quarkus.arc.selected-alternatives property in src/main/resources/application.properties.

To verify that the onEvent() method of AnalyticsManager receives events from the front-end plugin, press the l key to disable Quarkus live coding and edit any file within the IDE. The following output should be logged:

For the following example, the telemetry server application is deployed to OpenShift at the following URL: -telemetry-server-che.apps-crc.testing, where apps-crc.testing is the ingress domain name of the OpenShift cluster.

Quarkus is a container-first Kubernetes Java framework designed to have a super-fast start-up time and low memory usage. The container-first strategy emphasizes packaging the runtime environment along with the application code, allowing both to be tightly optimized and avoiding the endless updates and configuration problems that can come along with monolithic server systems. Quarkus was built from the beginning to support compilation to native code for use with Graal/SubstrateVM but also supports the good old JVM with OpenJDK HotSpot.

Quarkus is intended to be used in serverless and microservice environments and works with oth imperative and reactive programming paradigms. Its REST endpoints use JAX-RS, data models can be persisted using JPA, and CDI is used for dependency injection. Further, a large number of industry-standard libraries are supported like Vert.x, Hibernate, RESTEasy, Netty, Kubernetes, and Eclipse MicroProfile, just to name a few.

Java 11: This project uses Java 11. OpenJDK 11 will work just as well. Instructions are found on the OpenJDK website. OpenJDK can also be installed using Homebrew. Alternatively, SDKMAN is another great option for installing and managing Java versions.

Open a terminal and cd to an appropriate parent directory for your project. The command below uses the quarkus-maven-plugin to create a starter application and places it in the oauthdemo subdirectory.

An easy way to get an access token is to generate one using OpenID Connect Debugger. Open the site in a new window or tab. Fill in your client ID, and use yourOktaDomain/oauth2/default/v1/authorize for the Authorize URI. Select code for the response type and Use PKCE.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages