RESTEASY003210: Could not find resource for full path - Quarkus - quarkus

I'm trying to configure Swagger in Quarkus.
My version of Quarkus: 1.9.2.Final
My dependency:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
And my properties resources:
quarkus.swagger-ui.path=/swagger-ui
quarkus.swagger-ui.always-include=true
When I launch my application with: mvn compile quarkus:dev and go to this url:
http://localhost:8080/swagger-ui_not_found/
A red page with the additional endpoints is shown (ok, this is what I want)
However, if I make a package with maven (mvn package) and then, launch the jar, the same url returns:
RESTEASY003210: Could not find resource for full path
This is the trace:
2020-11-10 07:58:08,244 DEBUG [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002315: PathInfo: /favicon.ico
2020-11-10 07:58:08,246 DEBUG [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002305: Failed executing GET /favicon.ico: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/favicon.ico
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:70)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:47)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:481)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:332)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:253)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
I've read in Quarkus guides that if you set:
quarkus.swagger-ui.always-include=true
You make it available in production too, but in my case It doesn't work.
Any ideas?
Thanks.

Are you looking for the swagger-ui page, or the 404 page with the links on ?
As far as I know, the 404 with the links is only available in DEV mode.

By adding quarkus.swagger-ui.always-include=true to application.properties, you will get SwaggerUI in the prod-mode jar as well (accessible at http://localhost:8080/swagger-ui/)
See the documentation for more details.
Also note that this property is a build-time property, therefore changing it at runtime has no effect.

Related

Unable to find a 'com.okta.sdk.impl.http.RequestExecutorFactory'

I have a java web application secured with OKTA. I have the below code which throws the below exception,
Client client = Clients.builder()
.setOrgUrl((String)SessionUtils.getSession().getAttribute("serverUrl"))
.setClientCredentials(new TokenClientCredentials((String)SessionUtils.getSession().getAttribute("apiKey")))
.build();
When I run it, I get the below error. I have tried adding the jar by going to the buildPath of eclipse project. I am using the below dependencies in my POM and this used to work before when my project had an ANT build. But I started getting this error when I moved to Maven.
java.lang.IllegalStateException: Unable to find a
'com.okta.sdk.impl.http.RequestExecutorFactory' implementation on the
classpath. Please ensure you have added the okta-sdk-httpclient.jar
file to your runtime classpath. at
com.okta.commons.lang.Classes.lambda$loadFromService$0(Classes.java:205)
at java.util.Optional.orElseThrow(Optional.java:290) at
com.okta.commons.lang.Classes.loadFromService(Classes.java:205) at
com.okta.sdk.impl.client.BaseClient.createRequestExecutor(BaseClient.java:103)
at com.okta.sdk.impl.client.BaseClient.(BaseClient.java:72) at
com.okta.sdk.impl.client.AbstractClient.(AbstractClient.java:60)
at
com.okta.sdk.impl.client.DefaultClient.(DefaultClient.java:117)
at
com.okta.sdk.impl.client.DefaultClientBuilder.build(DefaultClientBuilder.java:322)
I could resolve this by using the okta-sdk-httpclient :v1.5.2 to match some of the other OKTA dependencies that I had in my project.
Below are the dependencies that I had in my project prior to the fix.
-okta-authn-sdk-api :v1.0.0
-okta-authn-sdk-impl :v1.0.0
-okta-http-api :v1.2.8
-okta-commons-lang :v1.2.8
-okta-config-check :v1.2.8
-okta-http-okhttp :v1.2.8
-okta-jwt-verifier :v0.5.1
-okta-jwt-verifier-impl:v0.4.0
-okta-sdk :v0.0.4
-okta-sdk-api :v1.5.2
-okta-sdk-httpclient :v6.0.0
-okta-sdk-impl :v1.5.2

spring-boot 2.5.5 property "spring.config.import" not defined?

after upgrade spring-boot:2.3.11.RELEASE to spring-boot:2.5.5 and spring-cloud:Hoxton.SR11 to spring-cloud:2020.0.4, spring-boot:run is failing with:
***************************
APPLICATION FAILED TO START
***************************
Description:
No spring.config.import property has been defined
Action:
Add a spring.config.import=configserver: property to your configuration.
If configuration is not required add spring.config.import=optional:configserver: instead.
To disable this check, set spring.cloud.config.enabled=false or
spring.cloud.config.import-check.enabled=false.
Advices are pretty clear so I added
spring.cloud.config.enabled=false
spring.cloud.config.import-check.enabled=false
spring.config.import=optional:configserver:
to both application.properties and bootstrap.properties files
In application.properties I had to comment out line spring.config.import=optional:configserver: otherwise it failed with java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:' ......... Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader
As I didn't need to comment it out in bootstrap.properties, values are ignored completely there probably
However application itself failed the same way as without any new properties added.
Any ideas what is the problem? What is correct format for spring.config.import=... ?
EDIT:
after adding dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
it doesn't ignore properties in bootstrap.properties anymore so I had to comment out "spring.config.import=optional:configserver:" there as well. However application still failing with "No spring.config.import property has been defined"
In Spring Cloud 2020 you dont need bootstrap.properties anymore, importing spring-cloud-starter-bootstrap enable only a legacy way to use it.
Just remove it...
You need to add
spring.config.import=optional:configserver:http://your.config.server.com
into your application.properties. Howerver I not sure what you try to achieve, because of your
spring.cloud.config.enabled=false
More Info

Springdoc: got 404 when open swagger-ui.html

I got latest Spring Boot app and springdoc.swagger-ui on board.
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.32</version>
</dependency>
My application.properties contains springdoc.swagger-ui.path=/swagger-ui-openapi.html
When I run application via Intellij IDEA http://localhost:8080/swagger-ui-openapi.html brings me to http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
and Swagger UI page loads successfully.
But if I start the app via command line: "java -jar my-app.jar", I got 404 in browser and Error in logs 'Circular view path [error]' when trying to reach http://localhost:8080/swagger-ui-openapi.html
and it redirrects me to http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
However http://localhost:8080/v3/api-docs is reachable and schema is available at this address.
How can I fix this?
What worked in my case when your application is running behind a proxy, a load-balancer or in the cloud.
In your Spring Boot application make sure your application handles this header: X-Forwarded-For.
There are two ways to achieve this:
In your properties file add:
server.use-forward-headers=true
If this is not enough, Spring Framework provides a ForwardedHeaderFilter. You can register it as a Servlet Filter in your application by setting server.forward-headers-strategy is set to FRAMEWORK.
Since Spring Boot 2.2, this is the new property to handle reverse proxy headers:
In your properties file add
server.forward-headers-strategy=framework
And you can add the following bean to your application:
#Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
return new ForwardedHeaderFilter();
}
If you already have static content on your root, and you don’t want it to be overridden by springdoc-openapi-ui configuration, you can just define a custom configuration of the swagger-ui, in order not to override the configuration of your files from in your context-root:
For example use in your properties file:
springdoc.swagger-ui.path= /swagger-ui/api-docs.html
ref:
https://springdoc.org/
For this problem, my conclusion is:
(1) Starting it in IDEA is fine
(2) Repackaging the jar with spring-boot-maven-plugin and starting it with 'java -jar' is fine as well.
(3) if I tried to starting with such as 'java -classpath ".:.conf" DemoApplication', it does not work.
So, for packaging, i use the spring-boot-maven-plugin.
You don't need swagger-annotations v1.6.1 dependency for springdoc-openapi;
By default, with springdoc you need no additonal settings of any ViewResolver.
You can have a look at some sample code:
https://github.com/springdoc/springdoc-openapi-demos

Error with webservices springboot

I have got an error with creating webservice from wsdl.
I have already configred a maven plugin
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
for creation of java classes.
In my wsdl I have got reference to swaref.xsd
<xs:import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="swaref.xsd"/>
When I launch springBoot app, I have got the following error:
Have you got any idea what's wrong? Maybe with apache cxf ?
Check if swaref.xsd exists along with the wsdl-file in the same location
Check if swaref.xsd contains the same namespace http://ws-i.org/profiles/basic/1.1/xsd, as referenced in wsdl-file
Check if swaref.xsd is a valid xml, then is a valid schema file.

I got ClassNotFoundException when i tried to switch spring to use load time weaving

I've added a <context:load-time-weaver/> in my application context. And i've added necessary libraries and javaagent to my pom.xml
Then i got following error
2014-05-23T17:48:11.549+0600 SEVERE Unable to find class 'com.myproject.dao.impl.BlobDataDaoTest$' in repository
java.lang.ClassNotFoundException: com.myproject.dao.impl.BlobDataDaoTest$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:485)
at org.aspectj.weaver.World.resolve(World.java:326)
How can i resolve it?
Obviously the weaver cannot find at least some of your application classes. This must be a class-loading issue. Maybe your aop.xml is not in the right location or configured in a wrong way - hard to tell with so little information.
There are external dependencies in my tests. They imported because in my tests i mock its. This Unable to find class errors all about this external classes.
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
...
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
...
2014-05-27T14:26:37.516+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
It was resolved when i've updated aspectj version from 1.6.12 to 1.8

Resources