Constantly getting NullPointerException when using gluon mobile in android app - gluon

I am getting following exception in my app when I run it on android device.
It it ok if I ignore it as it is logged as warning?
2019-06-26 13:24:49.942 W/System.err: java.lang.reflect.InvocationTargetException
2019-06-26 13:24:49.942 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2019-06-26 13:24:49.942 W/System.err: at javafxports.android.FXDalvikEntity.onGlobalLayout(FXDalvikEntity.java:389)
2019-06-26 13:24:49.943 W/System.err: at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
2019-06-26 13:24:49.943 W/System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2351)
2019-06-26 13:24:49.943 W/System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1465)
2019-06-26 13:24:49.943 W/System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7288)
2019-06-26 13:24:49.943 W/System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:979)
2019-06-26 13:24:49.943 W/System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:791)
2019-06-26 13:24:49.944 W/System.err: at android.view.Choreographer.doFrame(Choreographer.java:726)
2019-06-26 13:24:49.944 W/System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:965)
2019-06-26 13:24:49.944 W/System.err: at android.os.Handler.handleCallback(Handler.java:790)
2019-06-26 13:24:49.944 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
2019-06-26 13:24:49.944 W/System.err: at android.os.Looper.loop(Looper.java:164)
2019-06-26 13:24:49.944 W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6687)
2019-06-26 13:24:49.947 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2019-06-26 13:24:49.947 W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
2019-06-26 13:24:49.947 W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
2019-06-26 13:24:49.948 W/System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double javafx.scene.Scene.getHeight()' on a null object reference
2019-06-26 13:24:49.948 W/System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.adjustSize(TextFieldSkinAndroid.java:111)
2019-06-26 13:24:49.948 W/System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.lambda$showSoftwareKeyboard$643(TextFieldSkinAndroid.java:107)
2019-06-26 13:24:49.948 W/System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.access$lambda$2(Unknown Source:4)
2019-06-26 13:24:49.948 W/System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid$$Lambda$3.accept(Unknown Source:8)
2019-06-26 13:24:49.948 W/System.err: at com.sun.glass.ui.android.DalvikInput.keyboardSize(DalvikInput.java:72)
Here is my build.gradle file with my native Log service for different paltforms. I am using java 1.8 and gradle-5.1.1
What I observe is this exception is printed when I try to use PictureService or StorageService but I am not sure.
buildscript {
repositories {
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.16'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply from: 'ios-build.gradle'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = '<MAIN CLASS>'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'com.gluonhq:charm:5.0.2'
compile 'com.gluonhq:glisten-afterburner:1.4.1'
compile 'com.jfoenix:jfoenix:8.0.8'
// Remove after development
compile 'com.github.javafaker:javafaker:0.18'
// Desktop SQL -> https://github.com/xerial/sqlite-jdbc
desktopRuntime 'org.xerial:sqlite-jdbc:3.8.11.2'
// Embedded SQL -> https://github.com/xerial/sqlite-jdbc
embeddedRuntime 'org.xerial:sqlite-jdbc:3.7.2'
// Android SQL -> https://github.com/SQLDroid/SQLDroid
androidRuntime 'org.sqldroid:sqldroid:1.0.3'
// ios SQL -> https://github.com/robovm/robovm 1.8
}
jfxmobile {
downConfig {
version = '3.8.6'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'browser', 'dialer', 'display', 'lifecycle', 'local-notifications', 'pictures', 'position', 'push-notifications', 'runtime-args', 'settings', 'statusbar', 'storage', 'vibration'
}
android {
manifest = 'src/android/AndroidManifest.xml'
compileSdkVersion = 28
minSdkVersion = 15
dexOptions {
javaMaxHeapSize '3g'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*',
'SQLite.**.*'
]
}
}
task xcodebuild {
doLast {
xcodebuildIOS("$project.buildDir","$project.projectDir", "Log")
}
}
task installNativeLib (type:Copy, dependsOn: xcodebuild) {
from("$project.buildDir/native")
into("src/ios/jniLibs")
include("*.a")
}

Related

Problems with interaction between spring boot and extjs frontend

I set up a project with Spring Boot 2.7 as backend and extjs 7.0.0 GPL as frontend.
I can send requests from extjs store to the backend (via jsonp e.g.), but unfortunately I really don't achieve to send requests from the spring boot backend to the extjs controller, i.e. stores.
I tried some approaches like urlrewrite or the integration of php code in the /webapp folder, but nothing of this was a solution for my problem.
Anyboy could give me some hints in order to solve my problem, please?
Greetings and thanks in advance
UPDATE
Ok, after preparing and facing other issues, I'm back to the above mentioned issue only...
First of all here my project structure in Eclipse
Here the code of Spring Boot application.properties
server.port=8080
spring.application.name=MyBankingApp
server.servlet.context-path=/MyBankingApp
spring.jpa.open-in-view=false
#Database Configrations
spring.datasource.url=jdbc:postgresql://xxx/mybanking
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update
#Multipart
spring.servlet.multipart.enabled=true
spring.servlet.multipart.file-size-threshold=2KB
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=215MB
Here Spring Boot Application class with the main method
package com.mybanking;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
#SpringBootApplication
public class MyBankingApplication implements ApplicationRunner {
public static void main(String[] args) {
SpringApplication.run(MyBankingApplication.class, args);
}
#Override
public void run(ApplicationArguments arg0) throws Exception {
System.out.println("Hello World from MyBankingApp Runner");
}
}
Here the code of the extjs class of the relevant store
Ext.define('MyBankingApp.store.User', {
extend: 'Ext.data.Store',
xtype: 'userStore',
id:'userStoreID',
requires: [
'MyBankingApp.model.User'
],
autoLoad: false,
model: 'MyBankingApp.model.User',
proxy: {
type: 'jsonp',
url:'http://localhost:8080/MyBankingApp/user',
//scope: this,
callbackKey: 'callback'
},
callback: function(records, operation, success) {
alert(success);
alert(records);
},
scope: this
});
and its corresponding java controller
package com.mybanking.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.google.gson.Gson;
import com.mybanking.model.LoginUser;
import com.mybanking.model.User;
import com.mybanking.repository.UserRepository;
import com.mybanking.service.LoginUserService;
import com.mybanking.service.UserService;
#Controller
public class UserController {
#Autowired
private UserService userService;
#RequestMapping(value = "/user", method = RequestMethod.GET)
public String showUser(#RequestParam String _dc,
#RequestParam String callback,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws IOException {
var user = (List<User>) userService.showUser();
System.out.println("callback:\n");
System.out.println(callback);
String user_json = new Gson().toJson(user);
callback += user_json;
System.out.println(callback + '\n');
return callback;
}
}
Here the extjs view, where the UserStore is explicitely loaded in order to show the data retrieved from backend - what does not function
Ext.define('MyBankingApp.view.user.User', {
extend: 'Ext.container.Viewport',
xtype: 'userView',
renderTo: Ext.getBody(),
controller: 'userController',
layout: 'border',
title: 'User',
autoShow: true,
items: [{
xtype : 'tabpanel',
renderTo: Ext.getBody(),
title : 'MyBankingApp',
region : 'center',
controller: 'userController',
items : [{
title: 'User',
//collapsible: true,
items : [{
//xtype : 'grid',
xtype : 'window',
renderTo: Ext.getBody(),
region : 'center',
title : 'User List',
header : true,
store: 'MyBankingApp.store.User',
columns: [{
text: 'ID',
//width: 100,
sortable: false,
dataIndex: 'id'
},
{
text: 'Name',
//width: 100,
dataIndex: 'name'
},
{
text: 'Created',
flex: 1,
dataIndex: 'created',
renderer: Ext.util.Format.dateRenderer('Y-m-d')
}],
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'MyBankingApp.store.User',
dock: 'bottom',
displayInfo: true
}],
listeners: {
beforerender: function() {
var store = Ext.getStore('MyBankingApp.store.User');
store.load();
console.log(store);
var url = store.getProxy().url;
var params = store.getProxy().extraParams;
console.log(url);
console.log(params);
/*
Ext.data.StoreManager.each( function(store) {
console.log(store.id);
});
*/
}
}
}],
},
{
title: 'User',
html: 'Tab content User'
}],
buttons: [{
text: 'Hello',
listeners: {
click: 'onClickButton'
}
}],
buttons: [{
text: 'Logout',
listeners: {
click: 'onClickButton1'
}
}]
}]
});
Here the error message thrown by the backend when I visit the UserView, where the store should be loaded:
2022-07-07 20:31:19.024 INFO 8272 --- [alina-utility-1] com.mybanking.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT using Java 11.0.15.1 on WIN-86UTNGFROLK with PID 8272 (C:\Users\Administrator\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MyBankingApp\WEB-INF\classes started by Administrator in C:\Windows\system32)
2022-07-07 20:31:19.029 INFO 8272 --- [alina-utility-1] com.mybanking.ServletInitializer : No active profile set, falling back to 1 default profile: "default"
2022-07-07 20:31:20.545 INFO 8272 --- [alina-utility-1] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-07-07 20:31:20.667 INFO 8272 --- [alina-utility-1] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 98 ms. Found 2 JPA repository interfaces.
2022-07-07 20:31:21.498 INFO 8272 --- [alina-utility-1] o.a.c.c.C.[.[localhost].[/MyBankingApp] : Initializing Spring embedded WebApplicationContext
2022-07-07 20:31:21.498 INFO 8272 --- [alina-utility-1] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2348 ms
2022-07-07 20:31:22.432 INFO 8272 --- [alina-utility-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-07-07 20:31:22.643 INFO 8272 --- [alina-utility-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.9.Final
2022-07-07 20:31:23.154 INFO 8272 --- [alina-utility-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-07-07 20:31:23.399 INFO 8272 --- [alina-utility-1] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Starting...
2022-07-07 20:31:23.617 INFO 8272 --- [alina-utility-1] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Start completed.
2022-07-07 20:31:23.659 INFO 8272 --- [alina-utility-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-07-07 20:31:24.953 INFO 8272 --- [alina-utility-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-07-07 20:31:24.974 INFO 8272 --- [alina-utility-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-07-07 20:31:27.383 INFO 8272 --- [alina-utility-1] com.mybanking.ServletInitializer : Started ServletInitializer in 9.929 seconds (JVM running for 7520.221)
Hello World from MyBankingApp Runner
2022-07-07 20:31:27.436 INFO 8272 --- [alina-utility-1] o.a.c.c.C.[.[localhost].[/MyBankingApp] : Initializing Spring DispatcherServlet 'dispatcher'
2022-07-07 20:31:27.437 INFO 8272 --- [alina-utility-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcher'
2022-07-07 20:31:28.179 INFO 8272 --- [alina-utility-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 742 ms
2022-07-07 20:31:28.229 INFO 8272 --- [alina-utility-1] o.apache.catalina.core.StandardContext : Reloading Context with name [/MyBankingApp] is completed
2022-07-07 20:31:40.935 INFO 8272 --- [io-8080-exec-11] o.a.c.c.C.[.[localhost].[/MyBankingApp] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-07-07 20:31:40.936 INFO 8272 --- [io-8080-exec-11] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-07-07 20:31:40.937 INFO 8272 --- [io-8080-exec-11] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
callback:
Ext.data.JsonP.callback1
Ext.data.JsonP.callback1[{"id":1,"name":"user1","created":"2022-07-07 22:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]
2022-07-07 20:31:41.966 ERROR 8272 --- [io-8080-exec-11] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-11] Exception processing template "Ext.data.JsonP.callback1[{"id":1,"n[...]2:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]": Error resolving template [Ext.data.JsonP.callback1[{"id":1,"name":"user1","created":"2022-07-07 22:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [Ext.data.JsonP.callback1[{"id":1,"name":"user1","created":"2022-07-07 22:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1401) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1145) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1084) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.21.jar:5.3.21]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[servlet-api.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.21.jar:5.3.21]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[servlet-api.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-websocket.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.21.jar:5.3.21]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119) ~[spring-boot-2.7.1.jar:2.7.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.21.jar:5.3.21]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.21.jar:5.3.21]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[catalina.jar:9.0.63]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[catalina.jar:9.0.63]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[catalina.jar:9.0.63]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[catalina.jar:9.0.63]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[catalina.jar:9.0.63]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-coyote.jar:9.0.63]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-coyote.jar:9.0.63]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-util.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-util.jar:9.0.63]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:9.0.63]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
2022-07-07 20:31:41.969 ERROR 8272 --- [io-8080-exec-11] o.s.b.w.servlet.support.ErrorPageFilter : Forwarding to error page from request [/user] due to exception [Error resolving template [Ext.data.JsonP.callback1[{"id":1,"name":"user1","created":"2022-07-07 22:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]], template might not exist or might not be accessible by any of the configured Template Resolvers]
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [Ext.data.JsonP.callback1[{"id":1,"name":"user1","created":"2022-07-07 22:18:27.561538"},{"id":2,"name":"user2","created":"2022-07-07 22:18:39.292204"}]], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1401) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1145) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1084) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.21.jar:5.3.21]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.21.jar:5.3.21]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[servlet-api.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.21.jar:5.3.21]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[servlet-api.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-websocket.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.21.jar:5.3.21]
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119) ~[spring-boot-2.7.1.jar:2.7.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.21.jar:5.3.21]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.21.jar:5.3.21]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[catalina.jar:9.0.63]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[catalina.jar:9.0.63]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[catalina.jar:9.0.63]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687) ~[catalina.jar:9.0.63]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[catalina.jar:9.0.63]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[catalina.jar:9.0.63]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-coyote.jar:9.0.63]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-coyote.jar:9.0.63]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-coyote.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-util.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-util.jar:9.0.63]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:9.0.63]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
So now:
I'm testing on Windows 10 and Windows Server 2022, with same results
I'm developing in Eclipse / Spring Tool Suite 4
I'm testing with sencha app watch (localhost:1841) and Eclipse Tomcat 9 (localhost:8080) and also on a separate Tomcat 9 (localhost:80) instance
The exception shown above clearly says, that Spring tries to return the response to a Spring template and not to the sender (which isn't known by the backend)
But it also says, that the data could be retrieved successfully from the database, as it is shown in the built json string (2 sets)
But there do exist solutions in order to get what I want: Spring returns back its responses to Extjs, but I really don't know how I could achieve it.
Apart from the approaches I tried without success, I had to work with a similar project config like mine some years ago, but I really don't remember the details...

Routing to a https uri using Spring Cloud Gateway fails

My request flow is as follows
curl http://routerhostname:8080/details/endpoint1
Spring cloud gateway has a home route enabled to redirect this to
https://apigeehostname:443/details/endpoint1
My application.yml has the following
spring
cloud:
gateway:
httpclient:
ssl:
use-insecure-trust-manager: true
From the logs i see this
c.r.o.service.filter.LoggingFilter : Incoming request http://routerhostname:8080/details/endpoint1 is routed to id: home_route, uri:https://apigeehostname:443
NativeLibraryLoader : Successfully loaded the library /tmp/libnetty_tcnative_linux_x86_648982369872232257976.so
2022-03-23 23:31:50.070 DEBUG 8183 --- [or-http-epoll-3] i.n.util.internal.NativeLibraryLoader : Loaded library with name 'netty_tcnative_linux_x86_64'
2022-03-23 23:31:50.070 DEBUG 8183 --- [or-http-epoll-3] io.netty.handler.ssl.OpenSsl : Initialize netty-tcnative using engine: 'default'
2022-03-23 23:31:50.070 DEBUG 8183 --- [or-http-epoll-3] io.netty.handler.ssl.OpenSsl : netty-tcnative using native library: BoringSSL
3] i.n.util.ResourceLeakDetectorFactory : Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#13c80a98
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 => ECDHE-ECDSA-AES128-GCM-SHA256
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 => ECDHE-ECDSA-AES128-GCM-SHA256
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 => ECDHE-RSA-AES128-GCM-SHA256
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256 => ECDHE-RSA-AES128-GCM-SHA256
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 => ECDHE-ECDSA-AES256-GCM-SHA384
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 => ECDHE-ECDSA-AES256-GCM-SHA384
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 => ECDHE-RSA-AES256-GCM-SHA384
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384 => ECDHE-RSA-AES256-GCM-SHA384
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-ECDSA-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-ECDSA-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-RSA-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-RSA-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-PSK-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-PSK-CHACHA20-POLY1305
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA => ECDHE-ECDSA-AES128-SHA
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA => ECDHE-ECDSA-AES128-SHA
2022-03-23 23:31:50.120 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA => ECDHE-RSA-AES128-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA => ECDHE-RSA-AES128-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA => ECDHE-PSK-AES128-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_PSK_WITH_AES_128_CBC_SHA => ECDHE-PSK-AES128-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA => ECDHE-ECDSA-AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA => ECDHE-ECDSA-AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA => ECDHE-RSA-AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA => ECDHE-RSA-AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA => ECDHE-PSK-AES256-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_ECDHE_PSK_WITH_AES_256_CBC_SHA => ECDHE-PSK-AES256-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_RSA_WITH_AES_128_GCM_SHA256 => AES128-GCM-SHA256
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_RSA_WITH_AES_128_GCM_SHA256 => AES128-GCM-SHA256
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_RSA_WITH_AES_256_GCM_SHA384 => AES256-GCM-SHA384
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_RSA_WITH_AES_256_GCM_SHA384 => AES256-GCM-SHA384
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_RSA_WITH_AES_128_CBC_SHA => AES128-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_RSA_WITH_AES_128_CBC_SHA => AES128-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_PSK_WITH_AES_128_CBC_SHA => PSK-AES128-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_PSK_WITH_AES_128_CBC_SHA => PSK-AES128-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_RSA_WITH_AES_256_CBC_SHA => AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_RSA_WITH_AES_256_CBC_SHA => AES256-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_PSK_WITH_AES_256_CBC_SHA => PSK-AES256-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_PSK_WITH_AES_256_CBC_SHA => PSK-AES256-CBC-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: TLS_RSA_WITH_3DES_EDE_CBC_SHA => DES-CBC3-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] i.n.handler.ssl.CipherSuiteConverter : Cipher suite mapping: SSL_RSA_WITH_3DES_EDE_CBC_SHA => DES-CBC3-SHA
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] io.netty.handler.ssl.OpenSsl : Supported protocols (OpenSSL): [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2]
2022-03-23 23:31:50.121 DEBUG 8183 --- [or-http-epoll-3] io.netty.handler.ssl.OpenSsl : Default cipher suites (OpenSSL): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256]
2022-03-23 23:31:50.248 DEBUG 8183 --- [or-http-epoll-3] i.n.util.ResourceLeakDetectorFactory : Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#7867ea27
2022-03-23 23:31:50.407 DEBUG 8183 --- [or-http-epoll-3] i.n.h.s.ReferenceCountedOpenSslContext : verification of certificate failed
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387) ~[na:1.8.0_92]
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) ~[na:1.8.0_92]
at sun.security.validator.Validator.validate(Validator.java:260) ~[na:1.8.0_92]
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) ~[na:1.8.0_92]
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:281) ~[na:1.8.0_92]
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:136) ~[na:1.8.0_92]
at io.netty.handler.ssl.ReferenceCountedOpenSslClientContext$ExtendedTrustManagerVerifyCallback.verify(ReferenceCountedOpenSslClientContext.java:234) ~[netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.ReferenceCountedOpenSslContext$AbstractCertificateVerifier.verify(ReferenceCountedOpenSslContext.java:773) ~[netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.internal.tcnative.CertificateVerifierTask.runTask(CertificateVerifierTask.java:36) [netty-tcnative-classes-2.0.51.Final.jar!/:2.0.51.Final]
at io.netty.internal.tcnative.SSLTask.run(SSLTask.java:48) [netty-tcnative-classes-2.0.51.Final.jar!/:2.0.51.Final]
at io.netty.internal.tcnative.SSLTask.run(SSLTask.java:42) [netty-tcnative-classes-2.0.51.Final.jar!/:2.0.51.Final]
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.runAndResetNeedTask(ReferenceCountedOpenSslEngine.java:1484) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.access$700(ReferenceCountedOpenSslEngine.java:94) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine$TaskDecorator.run(ReferenceCountedOpenSslEngine.java:1459) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.runDelegatedTasks(SslHandler.java:1548) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1394) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1246) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1286) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510) [netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449) [netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) [netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.proxy.ProxyHandler.channelRead(ProxyHandler.java:252) [netty-handler-proxy-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.proxy.HttpProxyHandler$HttpClientCodecWrapper.channelRead(HttpProxyHandler.java:272) [netty-handler-proxy-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) [netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) [netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) [netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92]
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:1.8.0_92]
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[na:1.8.0_92]
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) ~[na:1.8.0_92]
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) ~[na:1.8.0_92]
... 44 common frames omitted
2022-03-23 23:31:50.459 DEBUG 8183 --- [or-http-epoll-3] a.w.r.e.AbstractErrorWebExceptionHandler : [2c5c9211-2] Resolved [SSLHandshakeException: General OpenSslEngine problem] for HTTP GET /details/endpoint1
2022-03-23 23:31:50.463 ERROR 8183 --- [or-http-epoll-3] a.w.r.e.AbstractErrorWebExceptionHandler : [2c5c9211-2] 500 Server Error for HTTP GET "/details/endpoint1"
javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.handshakeException(ReferenceCountedOpenSslEngine.java:1895) ~[netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
*__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
*__checkpoint ⇢ HTTP GET "/details/endpoint1" [ExceptionHandlingWebHandler]
Original Stack Trace:
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.handshakeException(ReferenceCountedOpenSslEngine.java:1895) ~[netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.wrap(ReferenceCountedOpenSslEngine.java:822) ~[netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:509) ~[na:1.8.0_92]
at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1040) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.wrapNonAppData(SslHandler.java:926) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1408) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1246) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1286) [netty-handler-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510) ~[netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449) ~[netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) ~[netty-codec-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.proxy.ProxyHandler.channelRead(ProxyHandler.java:252) ~[netty-handler-proxy-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.handler.proxy.HttpProxyHandler$HttpClientCodecWrapper.channelRead(HttpProxyHandler.java:272) ~[netty-handler-proxy-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) ~[netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) ~[netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-classes-epoll-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_92]
I am quite lost at the SSL configuration. I want to disable it completely but the call seems to expect the presence of a certificate.

Spring Boot MVC passing variables to model always null in html

I followed this code sample https://kotlinlang.org/docs/tutorials/spring-boot-restful.html to get a basic spring boot application working.
Now I want to add frontend components through thymleaf. Passing variables into the Model dont are always null in the outputted html
controller
#Controller
class IndexController {
#GetMapping("/")
fun index(#RequestParam(value = "name", defaultValue = "brian") name: String, model: Model): String {
model.addAttribute("name", name)
model.addAttribute("title", "some title")
return "index"
}
}
resources/templates/index.html
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="${title}"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div class="page-content">
<h1 th:text="|Hello ${name}!|"></h1>
<h2 th:text="|Welcome to ${title} application|"></h2>
</div>
</body>
</html>
spring seems to a lot of things under the hood so maybe i missing something obvious.
and the build gradle
plugins {
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
}
group = "com.ghost"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
//extra["springCloudVersion"] = "Greenwich.SR1"
dependencies {
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// implementation("org.springframework.cloud:spring-cloud-gcp-starter")
// implementation("org.springframework.cloud:spring-cloud-gcp-starter-storage")
// implementation("org.springframework.cloud:spring-cloud-starter-sleuth")
implementation("org.springframework.session:spring-session-core")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
//dependencyManagement {
// imports {
// mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
// }
//}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}

Spring Boot Security Login - "Wrong Credentials" Error

I am trying to implement login and registration. Registering users works fine, but when I attempt to log in I keep getting Wrong Credentials error. Below is my code. I want users to log in with their email and password, so I'm really not sure if I'm missing something or if this is the way to go, because all tutorials out there show login examples using username and password.
I am new to spring and still learning, so any help I get would be much appreciated.
My WebSecurityConfig class:
#Configuration
#EnableWebSecurity
#ComponentScan(basePackageClasses = CustomUserDetailsService.class)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
private UserDetailsService userDetailsService;
#Autowired
DataSource dataSource;
#Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/test").authenticated()
.and()
.formLogin()
.loginPage("/login")
.usernameParameter("email").passwordParameter("password")
.defaultSuccessUrl("/test")
.failureUrl("/login?error")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/authentication/login")
.permitAll();
}
#Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
#Bean
public PersistentTokenRepository persistentTokenRepository() {
JdbcTokenRepositoryImpl tokenRepo = new JdbcTokenRepositoryImpl();
tokenRepo.setDataSource(dataSource);
return tokenRepo;
}
#Bean
public UserDetailsService userDetailsService() {
return super.userDetailsService();
}
}
CustomUserDetailsService
#Service
public class CustomUserDetailsService implements UserDetailsService{
private final UserRepository userRepository;
private final RoleRepository roleRepository;
#Autowired
public CustomUserDetailsService(UserRepository userRepository, RoleRepository roleRepository) {
this.userRepository = userRepository;
this.roleRepository = roleRepository;
}
#Override
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
User user = userRepository.findByEmail(email);
if(user == null) {
throw new UsernameNotFoundException("User not found" + email);
}
else {
/*
List<String> userRoles = roleRepository.findRoleByUserId(user.getUserId());
return new CustomUserDetails(user, userRoles);
*/
List<Role> roles = new ArrayList<Role>();
roles.add(user.getRole());
return new CustomUserDetails(user, roles);
}
}
}
login.html
<div th:if="${success}" class="alert alert-success" role="alert" th:text="${success}"></div>
<div th:if="${error}" class="alert alert-danger" role="alert" th:text="${error}"></div>
<form method="post" th:action="#{/login}" th:object="${user}">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input class="form-control" id="exampleInputEmail1" name="email" type="email" th:field="*{email}" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input class="form-control" id="exampleInputPassword1" name="password" type="password" th:field="*{password}" placeholder="Password">
</div>
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="remember-me"> Remember Password</label>
</div>
</div>
<button class="btn btn-primary btn-block" type="submit">Login</button>
</form>
Stack trace:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.10.RELEASE)
2018-02-06 10:51:09.972 INFO 7116 --- [ main] c.b.app.SpringBootcampApplication : Starting SpringBootcampApplication on localhost.localdomain with PID 7116 (started by cuteowl in /home/cuteowl/Documents/Work/JAVA SPRING PROJECT/SpringBootcamp)
2018-02-06 10:51:09.975 INFO 7116 --- [ main] c.b.app.SpringBootcampApplication : No active profile set, falling back to default profiles: default
2018-02-06 10:51:10.287 INFO 7116 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#646be2c3: startup date [Tue Feb 06 10:51:10 CET 2018]; root of context hierarchy
2018-02-06 10:51:11.704 INFO 7116 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$319d2e5a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-06 10:51:12.285 INFO 7116 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-02-06 10:51:12.318 INFO 7116 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-02-06 10:51:12.320 INFO 7116 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-06 10:51:12.502 INFO 7116 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-02-06 10:51:12.502 INFO 7116 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2218 ms
2018-02-06 10:51:12.743 INFO 7116 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-06 10:51:12.743 INFO 7116 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-06 10:51:12.743 INFO 7116 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-06 10:51:12.743 INFO 7116 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-06 10:51:12.745 INFO 7116 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-02-06 10:51:12.745 INFO 7116 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-02-06 10:51:13.419 INFO 7116 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-02-06 10:51:13.438 INFO 7116 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-02-06 10:51:13.592 INFO 7116 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2018-02-06 10:51:13.593 INFO 7116 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-02-06 10:51:13.594 INFO 7116 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2018-02-06 10:51:13.632 INFO 7116 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-02-06 10:51:13.739 INFO 7116 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-02-06 10:51:14.232 INFO 7116 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2018-02-06 10:51:14.243 INFO 7116 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: roles
2018-02-06 10:51:14.244 INFO 7116 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: roles
2018-02-06 10:51:14.412 INFO 7116 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: users
2018-02-06 10:51:14.414 INFO 7116 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: users
2018-02-06 10:51:15.429 INFO 7116 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-02-06 10:51:16.419 INFO 7116 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#54895681, org.springframework.security.web.context.SecurityContextPersistenceFilter#28daf506, org.springframework.security.web.header.HeaderWriterFilter#5a47730c, org.springframework.security.web.csrf.CsrfFilter#440ef8d, org.springframework.security.web.authentication.logout.LogoutFilter#4e48462d, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#633ddc0c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#693f2213, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#7ac48f05, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#2dd0a0d0, org.springframework.security.web.session.SessionManagementFilter#1cde374, org.springframework.security.web.access.ExceptionTranslationFilter#46612bfc, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#3cc3f13e]
2018-02-06 10:51:16.709 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#646be2c3: startup date [Tue Feb 06 10:51:10 CET 2018]; root of context hierarchy
2018-02-06 10:51:16.795 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public java.lang.String com.bootcamp.app.controllers.LoginController.showLoginPage(org.springframework.ui.Model,com.bootcamp.app.models.User,java.util.Optional<java.lang.String>,java.util.Optional<java.lang.String>)
2018-02-06 10:51:16.797 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/register],methods=[GET]}" onto public java.lang.String com.bootcamp.app.controllers.RegisterController.showRegisterPage(org.springframework.ui.Model,com.bootcamp.app.models.User)
2018-02-06 10:51:16.797 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/register/new-user],methods=[POST]}" onto public java.lang.String com.bootcamp.app.controllers.RegisterController.postRegisterPage(org.springframework.ui.Model,com.bootcamp.app.models.User,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletRequest)
2018-02-06 10:51:16.797 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/confirm],methods=[GET]}" onto public java.lang.String com.bootcamp.app.controllers.RegisterController.showConfirmationPage(org.springframework.ui.Model,java.lang.String)
2018-02-06 10:51:16.797 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/confirm],methods=[POST]}" onto public java.lang.String com.bootcamp.app.controllers.RegisterController.processConfirmationForm(org.springframework.ui.Model,java.util.Map)
2018-02-06 10:51:16.798 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test],methods=[GET]}" onto public java.lang.String com.bootcamp.app.controllers.TestController.test()
2018-02-06 10:51:16.801 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-02-06 10:51:16.802 INFO 7116 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-02-06 10:51:16.841 INFO 7116 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-06 10:51:16.842 INFO 7116 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-06 10:51:16.882 INFO 7116 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-06 10:51:17.394 INFO 7116 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-02-06 10:51:17.458 INFO 7116 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-02-06 10:51:17.465 INFO 7116 --- [ main] c.b.app.SpringBootcampApplication : Started SpringBootcampApplication in 7.823 seconds (JVM running for 8.19)
2018-02-06 10:51:35.719 INFO 7116 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-02-06 10:51:35.720 INFO 7116 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-02-06 10:51:35.748 INFO 7116 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms
2018-02-06 10:51:47.792 INFO 7116 --- [nio-8080-exec-8] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2018-02-06 10:52:46.550 WARN 7116 --- [nio-8080-exec-8] o.s.s.c.bcrypt.BCryptPasswordEncoder : Empty encoded password
Change method configAuthentication() to:
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
This is what spring boot expects for default authentication provider. Then see if your user details service gets called on login attempt.
Also please post your CustomUserDetails implementation.

Endpoint protection configuration via #EnableGlobalMethodSecurity in Spring Boot

While trying to recreate a sample from a book demonstrating how to restrict access to an endpoint, I'm getting an unexpected behavior - an admin with a permitting role is disallowed access:
$ curl -X POST \
> 'http://localhost:9090/oauth/token?grant_type=password&username=admin&password=password2' \
> -H 'authorization: Basic d2ViYXBwOndlYnNlY3JldA==' \
> -H 'cache-control: no-cache' \
> -d '"category":"test","document":"this is a test document"'
{"access_token":"6d149c21-6a48-41e8-885d-d6da70648b49","token_type":"bearer","expires_in":42860,"scope":"read,write,trust"}
$ curl -X GET \
> 'http://localhost:9090/resource?access_token=6d149c21-6a48-41e8-885d-d6da70648b49' \
> -H 'cache-control: no-cache' \
{"timestamp":1508464945487,"status":403,"error":"Forbidden","exception":"org.springframework.security.access.AccessDeniedException","message":"Access Denied","path":"/resource"}
Here are the relevant classes:
#Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
#Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManager();
}
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user1").password("password1").roles("USER")
.and().withUser("admin").password("password2").roles("ADMIN");
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().antMatchers("/**").permitAll().and()
// default protection for all resources (including /oauth/authorize)
.authorizeRequests()
.anyRequest().hasAnyRole("USER","ADMIN");
// ... more configuration, e.g. for form login
}
}
#Configuration
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
#Autowired
private AuthenticationManager authManager;
#Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authManager);
}
#Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("webapp").secret("websecret").authorizedGrantTypes("password")
.scopes("read,write,trust");
}
}
#SpringBootApplication
#EnableAuthorizationServer
#EnableResourceServer
#RestController
#EnableGlobalMethodSecurity(prePostEnabled=true)
public class OauthServerApplication {
#RequestMapping("/resource")
#PreAuthorize("hasRole('ADMIN')")
public String resourceEndpoint() {
return "This resource is protected by the resource server.";
}
public static void main(String[] args) {
SpringApplication.run(OauthServerApplication.class, args);
}
}
What am I missing here?
The goal is to have only adminuser to be able to access the resource endpoint, while the regular user user1is to be denied access.
N.B.: the below stanza is actually something I added:
#Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().antMatchers("/**").permitAll().and()
// default protection for all resources (including /oauth/authorize)
.authorizeRequests()
.anyRequest().hasAnyRole("USER","ADMIN");
// ... more configuration, e.g. for form login
}
as its absence produces the following during resource acquisition attempt (2nd request):
<html>
<head>
<title>Login Page</title>
</head>
<body onload='document.f.username.focus();'>
<h3>Login with Username and Password</h3>
<form name='f' action='/login' method='POST'>
<table>
<tr>
<td>User:</td>
<td>
<input type='text' name='username' value=''>
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type='password' name='password'/>
</td>
</tr>
<tr>
<td colspan='2'>
<input name="submit" type="submit" value="Login"/>
</td>
</tr>
<input name="_csrf" type="hidden" value="1cbdad0b-181e-496c-aed0-eb633b29eab7" />
</table>
</form>
</body>
</html>
After enabling web security log, as some of the commentators suggested, like so:
#Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.....
#Override
public void configure(WebSecurity web) throws Exception {
web.debug(true);
}
...}
here's the partial resulting server log from the 2 requests:
2017-10-20 07:17:27.836 WARN 12728 --- [ main] o.s.s.c.a.web.builders.WebSecurity :
********************************************************************
********** Security debugging is enabled. *************
********** This may include sensitive information. *************
********** Do not use in a production system! *************
********************************************************************
2017-10-20 07:17:29.116 INFO 12728 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2017-10-20 07:17:29.180 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-10-20 07:17:29.186 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2017-10-20 07:17:29.187 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2017-10-20 07:17:29.187 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2017-10-20 07:17:29.187 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2017-10-20 07:17:29.188 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2017-10-20 07:17:29.189 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2017-10-20 07:17:29.197 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'restartEndpoint': registering with JMX server as MBean [org.springframework.cloud.context.restart:name=restartEndpoint,type=RestartEndpoint]
2017-10-20 07:17:29.202 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2017-10-20 07:17:29.207 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=6f7923a5,type=ConfigurationPropertiesRebinder]
2017-10-20 07:17:29.211 INFO 12728 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2017-10-20 07:17:29.338 INFO 12728 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2017-10-20 07:17:29.402 INFO 12728 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9090 (http)
2017-10-20 07:17:29.406 INFO 12728 --- [ main] c.e.spring.cloud.OauthServerApplication : Started OauthServerApplication in 6.879 seconds (JVM running for 7.264)
2017-10-20 07:18:20.584 INFO 12728 --- [nio-9090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-10-20 07:18:20.584 INFO 12728 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2017-10-20 07:18:20.600 INFO 12728 --- [nio-9090-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
2017-10-20 07:18:20.606 INFO 12728 --- [nio-9090-exec-1] Spring Security Debugger :
************************************************************
Request received for POST '/oauth/token?grant_type=password&username=user1&password=password1':
org.apache.catalina.connector.RequestFacade#5ace935e
servletPath:/oauth/token
pathInfo:null
headers:
host: localhost:9090
connection: keep-alive
content-length: 54
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
cache-control: no-cache
origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
content-type: text/plain;charset=UTF-8
authorization: Basic d2ViYXBwOndlYnNlY3JldA==
postman-token: cd55952b-6c6f-6101-8f24-3942dee9b06a
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.8
cookie: JSESSIONID=F4526A8B6FD15FD35D3D84D25E2C3898
Security filter chain: [
WebAsyncManagerIntegrationFilter
SecurityContextPersistenceFilter
HeaderWriterFilter
LogoutFilter
BasicAuthenticationFilter
RequestCacheAwareFilter
SecurityContextHolderAwareRequestFilter
AnonymousAuthenticationFilter
SessionManagementFilter
ExceptionTranslationFilter
FilterSecurityInterceptor
]
************************************************************
2017-10-20 07:20:18.604 INFO 12728 --- [nio-9090-exec-4] Spring Security Debugger :
************************************************************
Request received for GET '/resource?access_token=5466dfff-f088-4097-8db9-4ed07f0b80a0':
org.apache.catalina.connector.RequestFacade#5ace935e
servletPath:/resource
pathInfo:null
headers:
host: localhost:9090
connection: keep-alive
cache-control: no-cache
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
postman-token: 394b6610-1d18-eec7-338b-ab1de65cfeeb
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.8
cookie: JSESSIONID=F4526A8B6FD15FD35D3D84D25E2C3898
Security filter chain: [
WebAsyncManagerIntegrationFilter
SecurityContextPersistenceFilter
HeaderWriterFilter
CsrfFilter
LogoutFilter
RequestCacheAwareFilter
SecurityContextHolderAwareRequestFilter
AnonymousAuthenticationFilter
SessionManagementFilter
ExceptionTranslationFilter
FilterSecurityInterceptor
]
************************************************************
2017-10-20 07:20:18.640 INFO 12728 --- [nio-9090-exec-4] Spring Security Debugger :
************************************************************
New HTTP session created: 1D899B6306F970E097CE746030A28E4A
Call stack:
at org.springframework.security.web.debug.Logger.info(Logger.java:44)
at org.springframework.security.web.debug.DebugRequestWrapper.getSession(DebugFilter.java:166)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:240)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:240)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:240)
at org.springframework.security.web.savedrequest.HttpSessionRequestCache.saveRequest(HttpSessionRequestCache.java:59)
at org.springframework.security.web.access.ExceptionTranslationFilter.sendStartAuthentication(ExceptionTranslationFilter.java:201)
at org.springframework.security.web.access.ExceptionTranslationFilter.handleSpringSecurityException(ExceptionTranslationFilter.java:177)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:133)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.security.web.debug.DebugFilter.invokeWithWrappedRequest(DebugFilter.java:90)
at org.springframework.security.web.debug.DebugFilter.doFilter(DebugFilter.java:77)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
************************************************************
When I comment out the #PreAuthorize("hasRole('ADMIN')") annotation on top of the resource endpoint, the resource request correctly displays "This resource is protected by the resource server." Also a breakpoint placed in there gets triggered. Re-enabling the #PreAuthorize annotation seems to introduce the improper behavior and skips the breakpoint. Where in the surrounding Spring infrastructure could I place the breakpoint to research deeper this effect of #PreAuthorize("hasRole('ADMIN')") annotation?
Thanks.
Because you are using OAuth2, instead of using the WebSecurityConfigurerAdapter you need to use the ResourceServerConfigurerAdapter. For example:
#Configuration
#EnableResourceServer
#EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
#Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll().and().cors().disable().csrf().disable().httpBasic().disable()
.exceptionHandling()
.authenticationEntryPoint(
(request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
.accessDeniedHandler(
(request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED));
}
}
Now you should be able to use the security methods.
Here is an implementation for OAuth2 with Spring Boot with custom UserDetails service and JWT token. The basic implementation is the same.
Here is the OAuth2Configuration for the Authorization Server
Here is the WebSecurityConfiguration for the Authorization Server

Resources