Exclude package from Maven-PMD and Findbugs

Suppose, that you need to exclude the package from the maven-pmd-plugin, or you need to exclude the package from findbugs-maven-plugin.  maven-pmd-plugin Pmd definition in project pom.xml: Pmd configuration file pmd-exclude.xml: findbugs-maven-plugin Findbugs definition in project pom.xml: Findbugs configuration file findbugs-exclude.xml:

READ MORE

Unrecognized field JSON

Exception text: Most likely the code looks like this: The error is that the names of getter and setter are not consistent with the corresponding field. getVar2() and setVar2() should be named getVar1() and setVar1():

READ MORE

Spring Boot REST vs gRPC compatibility

Suppose you are using Spring Boot and you have a REST controller: At some point you need to connect the gRPC to the project without disabling REST controller. The gRPC code looks something like this: Then you find out that you can’t start REST server together with gRPC. gRPC will start, but REST will not. […]

READ MORE

Guava version compatibility issue

Spring Boot errors Pure Java exceptions Suggested solutions Method Guava version com.google.common.base.Preconditions.checkArgument 26.0-jre / 26.0-android com.google.common.base.Preconditions.checkState 21.0 com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor 18.0 / 19.0 Let me remind you that guava with maven is connected like this: If suggested verions don’t fix the problem, you can try connecting the specified versions in order: 18.0 / 19.0 / 21.0 / […]

READ MORE

Load x509 certificate from keystore Java

We have a keystore with an imported certificate and we need to work with it in code. We are going to import cert into an X509Certificate class object. After that, you can work with it further, or simply display some information about it, for example: Subject X500 Principal, Issuer X500 Principal Subject DN, Issuer DN […]

READ MORE

Failed to find reentrant lock with given name Ignite

Full text of the exception in Apache Ignite: The code that uses the reentrant lock looks something like this: Check that when creating a lock, the last argument = true is passed to the reentrantLock method: If the error is still repeated, then this is a bug: https://issues.apache.org/jira/browse/IGNITE-3386. It appears when one of the server […]

READ MORE

Error creating shaded jar target\classes (Access is denied)

The error looks like this: Stacktrace: maven-shade-plugin tries to open classes folder as zip file. This happens when one of the dependencies is found on the local filesystem and not in the local maven repository. Before unpacking, the plugin should check whether target\classes is a directory or a zip file, but it doesn’t. One solution […]

READ MORE

JAAS / Kerberos / Digest stub with Mockito

You need to test the functionality of method X. It does the following things: Performs authentication using JAAS; If authentication is successful, it continues to work. It’s often problematic to set up a working authentication mechanism in a unit test environment. One solution to the problem is to set a stub on the login() method […]

READ MORE

REST endpoint stub in Java

Making a REST server Let me remind you that earlier we talked about setting up a REST server for unit tests in JUnit. We will also be using the WireMock tool today. Information about adding WireMock to the project can be found in the previous article. Configuring server parameters For HTTP: For HTTPS: To use […]

READ MORE