smallrye.jwt.sign.key-location is Unknown property in application.properties - java

I am currently trying to add JWT to my quarkus project but I have run into some roadblocks.
In my application.properties I have set the following settings:
mp.jwt.verify.publickey.location=publicKey.pem
smallrye.jwt.sign.key-location = privatetestKey.pem
mp.jwt.verify.issuer=https://example.com/issuer
but now I get the error:
Unknown property 'smallrye.jwt.sign.key-location'
I should have installed every necessary dependency in my pom.xml:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt-build</artifactId>
</dependency>
Or have I forgotten something?

The configuration name was renamed to smallrye.jwt.sign.key.location (no dash between key and location), but I believe that the old one should still work because it was only deprecated.
Please try with the new name: https://quarkus.io/guides/security-jwt#additional-smallrye-jwt-configuration

Related

java.lang.NoSuchFieldError: CLIENT_ENDPOINT for Amazon ECS

I tried to list the ECS clusters using the code as follow:
AmazonECS = amazonECS AmazonECSClientBuilder.standard().withRegion(region).withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build():
amazonECS.listClusters();
However, it gave the error
java.lang.NoSuchFieldError: CLIENT_ENDPOINT
The error stack is something like this:
com.amazonaws.services.ecs.AmazonECSClient in executeListClusters at
line 2220 com.amazonaws.services.ecs.AmazonECSClient in listClusters
at line 2202 com.amazonaws.services.ecs.AmazonECSClient in
listClusters at line 2245
I am not too sure why this error occurred as the other Amazon services did not give me any similar error whatsoever and I have set the region previously based on the client's preference. Any ideas?
Thanks to Nagaraj Trantri the error is caused by the version mismatched of the AWS SDK that I have according to https://github.com/aws/aws-sdk-java/issues/2509#issuecomment-779370672
I had different version for SQS and S3 in pom.xml. After I updated those to same versions, it worked.
It depends on where to look for these versions mismatch.
I am using spark to connect to secrets manager and thus we have 2 places to look at.
My Application dependencies (build.gradle)
spark.yarn.jars
The versions in the above 2 places should match and then it started working
Use this in the pom.xml file. Error is caused due to mismatch in the 'com.amazonaws' dependency versions declared in the pom.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.739</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sts</artifactId>
</dependency>
</dependencies>

How to fix problem of spring-boot-devtools with axon?

I have to use spring-boot-devtools & axon in spring-boot application. I have included both of them in pom.xml. It is not working. Application fails to start.
I have tried to run application without using spring-boot-devtools then it works perfectly as expected but not with spring-boot-devtools. I have read document of axon on https://docs.axoniq.io/reference-guide/setting-up/spring-boot where it is suggested not to use devtools with axon. I also refereed issue https://github.com/AxonFramework/AxonFramework/issues/976 where it is stated, removing the devtools dependency did the trick. I don't want to remove devtools as it is useful in development mode. Pom.xml content:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<version>4.0.3</version>
</dependency>
I expect application to start but got error :
Description:
The bean 'commandBus', defined in class path resource [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/axonframework/springboot/autoconfig/AxonServerAutoConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I have tried spring.main.allow-bean-definition-overriding=true but not working.

JENA error TurtleParseException when executing JAR

I made a program that parses turtle files with Jena library. These are the dependencies i use:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-iri</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-tdb</artifactId>
<version>3.10.0</version>
</dependency>
So the parsing is working well on my java program but when i create my jar and try to run it, i have these kind of errors :
ERROR JenaService:146 - org.apache.jena.n3.turtle.TurtleParseException: Line 28015, column 79: org.apache.jena.iri.impl.IRIImplException:
<http://www.reussir.fr,> Code: 28/NOT_DNS_NAME in HOST: The host component did not meet the restrictions on DNS names.
Any ideas ?
EDIT
I have a warning for the invalid IRI problem by running my program with the IDE, but still giving me errors with the generated jar.
<http://www.reussir.fr,>
There is a comma in the URI in a place where commas are not allowed.
It is better to find and fix the data problem because it can lead to other problems later if not fixed.
I found the problem, the only dependency i really needed was jena-arq, so i removed others dependencies (especially jena-iri which was throwing the TurtleParseException) and the bad-iri errors became warnings like in the IDE execution logs.

sikuli classpath UnsatisfiedLinkError no opencv_core with macosx intellij Junit

I have done previous searches trying to find an answer to this however my attempts failed so far. I think the error is quite simple its just not loading the classes.
I am running MacOSX 10 with intellij. I am using it with Junit Spring and Maven & Junit.
I followed the maven dependencies found mvnrepository.com - sikuli-api 1.2.0 so I was thinking that if the dependencies are added to the pom then all files should be in my class path? So I don't understand why its not working?
This previous answer looks close to mine - but its for windows im on a mac. However by using maven I should not need to add it to the class path?? or am I missing something. This similar unanswered question also looks similar uses mac like mine
POM Dependencies added
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-core</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-0.9</version>
<classifier>macosx-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-core</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-extras</artifactId>
<version>1.3.1</version>
</dependency>
My test
static {
System.setProperty("platform.dependency", "macosx-x86_64");
//System.setProperty("platform.dependency", "1"); // tried this also
}
#Test
public void testOne() throws Exception {
File file = new File(getClass().getClassLoader().getResource("camera_icon.png").getFile());
browse(new URL("http://code.google.com"));
ScreenRegion s = new DesktopScreenRegion();
Target target = new ColorImageTarget(file);
// ** Fails here **
ScreenRegion r = s.find(target);
....
The Error - ClassLoader
I followed the debugger and it fails on the class loader for open_core -- see screenshot
Update
I added the POM classifier per Samuel answer below. I also tried setting the system property. still getting the same error.
Also noticed the following error - I have tried to cut it down as much as possible.
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/qp/.../libjniopencv_core.dylib: dlopen(/private/var/....../libjniopencv_core.dylib, 1): Library not loaded: #rpath/libopencv_core.2.4.dylib
Referenced from: /private/var/.......libjniopencv_core.dylib
Reason: no suitable image found. Did find:
/private/va.....77/./libopencv_core.2.4.dylib: malformed mach-o image: load command #12 length (0) too small in /private/var/fo......./libopencv_core.2.4.dylib t java.lang.ClassLoader$NativeLibrary.load(Native Method)
The answer is basically in the README.md file, but I'll spell it out here. You will need to set either the platform.dependency system property to the desired platform, for example, macosx-x86_64, or to true the platform.dependencies one, to get dependencies for all platforms. I'm not sure how we're supposed to set that with JUnit Spring (it should be in the docs), but even that doesn't work with SBT anyway, so to work around these cases we can add the platform-specific dependencies manually. Since you're running on Mac OS X and interested in using OpenCV 2.4.9, adding this additional dependency to your pom.xml file should work:
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-0.9</version>
<classifier>macosx-x86_64</classifier>
</dependency>
For my work around I install opencv via homebrew. Open terminal and type the following.
brew tap homebrew/science
brew info opencv
brew install opencv
This allowed my POM to be much smaller
<?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>sikuliTest</groupId>
<artifactId>sikuliTest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-api</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
The test
#Test
public void testOne() throws IOException {
File file = new File(getClass().getClassLoader().getResource("image_to_click.jpeg").getFile());
browse(new URL("http://code.google.com"));
// click image that looks like image_to_click.jpeg
ScreenRegion s = new DesktopScreenRegion(1);
ScreenRegion s1 = s.find(new ImageTarget(file));
Mouse mouse = new DesktopMouse();
mouse.click(s1.getCenter());
// take a screenshot and save it
BufferedImage img = s.capture();
File outputfile = new File("screenshot_image.jpg");
ImageIO.write(img, "jpg", outputfile);
}

Trouble starting Hibernate Validator due to Bean Validation API

I'm trying to use Hibernate Validator in my project, but it isn't working. On the following line:
SessionFactory sessions = config.buildSessionFactory(builder.build());
I get the following exception:
org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:154)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
at net.myProject.server.util.HibernateUtil.<clinit>(HibernateUtil.java:32)
... 36 more
Caused by: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:119)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:217)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
I found this question which seems quite similar to my problem. He describes his solution as
I had yet another bean validator jar in the class path. But not from
maven, so i didn't realize it. Removing that solved the problem.
I think my problem is the same. On http://hibernate.org/validator/documentation/getting-started/ it says:
This transitively pulls in the dependency to the Bean Validation API
(javax.validation:validation-api:1.1.0.Final)
That must be causing this issue, since reverting to an older version (4.3.1.Final) fixes the issue. Is there a way to force Hibernate to not pull in the Bean Validation API?
Edit: I've tried to exclude the javax-validation api:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.3.Final</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
But it didn't seem to have any effect.
Try adding this dependency to your pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
If not consider using hibernate-validator4.2.0.Final I have that one in my config and it is working fine.
For me, the 1.1.0.Final version javax.validation.validation-api had worked. Because, the javax.validation.spi.ConfigurationState interface of 1.1.0.Final has getParameterNameProvider method, which was absent in 1.0.0.GA.
I added the below dependency in pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>test</scope>
</dependency>
I had the problem again. Thats how I've fixed that:
1-Exclude spring.validator from the 'web' dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
2-After insert the dependecy with a previous version:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
in my case i just deleted the hibernate-validator and it worked .(i also had a combo of both validation api and hibernate-validator and tried everything) or you can go to your maven repository-->org and then delete the hibernate folder and rebuild your project again..
hope it helps..
I thought it would be useful to explain what is going on here.
Hibernate is calling ConfigurationState.getParameterNameProvider:
ValidatorFactoryImpl.java:
public ValidatorFactoryImpl(ConfigurationState configurationState) {
...
configurationState.getParameterNameProvider()
...
}
You can find the documentation of getParameterNameProvider:
getParameterNameProvider
ParameterNameProvider getParameterNameProvider()
Returns the parameter name provider for this configuration.
Returns:
parameter name provider instance or null if not defined
Since:
1.1
So what's the problem? The problem is that the method didn't always exist. It was added at some point in the future.
And the rule when creating interfaces is that they are set in concrete: you shall not change an interface ever. Instead the JavaX validator changed the ConfigurationState interface, and added a few new methods over the years.
The java validation code is passing the Hiberate an outdated ConfiguationState interface; one that doesn't implement the required interfaces.
You need to ensure that javax.validation.Validation.buildDefaultValidatorFactory is updated to to support version 1.1.
Removing this jar javax.validation:validation-api:1.1.0.Final solved my problem.
Make sure you have only one validation jar. If we have two jars then they may conflict resulting in error.
Go to the dependecies project and delete, hibernate.validator, and reinstall that in the most recent version. It has solved the problem for me.

Categories